babylon.d.ts 2.1 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577
  1. declare module 'babylonjs' {
  2. export = BABYLON;
  3. }
  4. declare module BABYLON {
  5. /**
  6. * Defines how the parser contract is defined.
  7. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  8. */
  9. type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  10. /**
  11. * Defines how the individual parser contract is defined.
  12. * These parser can parse an individual asset
  13. */
  14. type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  15. /**
  16. * Base class of the scene acting as a container for the different elements composing a scene.
  17. * This class is dynamically extended by the different components of the scene increasing
  18. * flexibility and reducing coupling
  19. */
  20. abstract class AbstractScene {
  21. /**
  22. * Stores the list of available parsers in the application.
  23. */
  24. private static _BabylonFileParsers;
  25. /**
  26. * Stores the list of available individual parsers in the application.
  27. */
  28. private static _IndividualBabylonFileParsers;
  29. /**
  30. * Adds a parser in the list of available ones
  31. * @param name Defines the name of the parser
  32. * @param parser Defines the parser to add
  33. */
  34. static AddParser(name: string, parser: BabylonFileParser): void;
  35. /**
  36. * Gets a general parser from the list of avaialble ones
  37. * @param name Defines the name of the parser
  38. * @returns the requested parser or null
  39. */
  40. static GetParser(name: string): Nullable<BabylonFileParser>;
  41. /**
  42. * Adds n individual parser in the list of available ones
  43. * @param name Defines the name of the parser
  44. * @param parser Defines the parser to add
  45. */
  46. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  47. /**
  48. * Gets an individual parser from the list of avaialble ones
  49. * @param name Defines the name of the parser
  50. * @returns the requested parser or null
  51. */
  52. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  53. /**
  54. * Parser json data and populate both a scene and its associated container object
  55. * @param jsonData Defines the data to parse
  56. * @param scene Defines the scene to parse the data for
  57. * @param container Defines the container attached to the parsing sequence
  58. * @param rootUrl Defines the root url of the data
  59. */
  60. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  61. /**
  62. * Gets the list of root nodes (ie. nodes with no parent)
  63. */
  64. rootNodes: Node[];
  65. /** All of the cameras added to this scene
  66. * @see http://doc.babylonjs.com/babylon101/cameras
  67. */
  68. cameras: Camera[];
  69. /**
  70. * All of the lights added to this scene
  71. * @see http://doc.babylonjs.com/babylon101/lights
  72. */
  73. lights: Light[];
  74. /**
  75. * All of the (abstract) meshes added to this scene
  76. */
  77. meshes: AbstractMesh[];
  78. /**
  79. * The list of skeletons added to the scene
  80. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  81. */
  82. skeletons: Skeleton[];
  83. /**
  84. * All of the particle systems added to this scene
  85. * @see http://doc.babylonjs.com/babylon101/particles
  86. */
  87. particleSystems: IParticleSystem[];
  88. /**
  89. * Gets a list of Animations associated with the scene
  90. */
  91. animations: Animation[];
  92. /**
  93. * All of the animation groups added to this scene
  94. * @see http://doc.babylonjs.com/how_to/group
  95. */
  96. animationGroups: AnimationGroup[];
  97. /**
  98. * All of the multi-materials added to this scene
  99. * @see http://doc.babylonjs.com/how_to/multi_materials
  100. */
  101. multiMaterials: MultiMaterial[];
  102. /**
  103. * All of the materials added to this scene
  104. * In the context of a Scene, it is not supposed to be modified manually.
  105. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  106. * Note also that the order of the Material wihin the array is not significant and might change.
  107. * @see http://doc.babylonjs.com/babylon101/materials
  108. */
  109. materials: Material[];
  110. /**
  111. * The list of morph target managers added to the scene
  112. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  113. */
  114. morphTargetManagers: MorphTargetManager[];
  115. /**
  116. * The list of geometries used in the scene.
  117. */
  118. geometries: Geometry[];
  119. /**
  120. * All of the tranform nodes added to this scene
  121. * In the context of a Scene, it is not supposed to be modified manually.
  122. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  123. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  124. * @see http://doc.babylonjs.com/how_to/transformnode
  125. */
  126. transformNodes: TransformNode[];
  127. /**
  128. * ActionManagers available on the scene.
  129. */
  130. actionManagers: ActionManager[];
  131. /**
  132. * Textures to keep.
  133. */
  134. textures: BaseTexture[];
  135. }
  136. }
  137. declare module BABYLON {
  138. /**
  139. * Set of assets to keep when moving a scene into an asset container.
  140. */
  141. class KeepAssets extends AbstractScene {
  142. }
  143. /**
  144. * Container with a set of assets that can be added or removed from a scene.
  145. */
  146. class AssetContainer extends AbstractScene {
  147. /**
  148. * The scene the AssetContainer belongs to.
  149. */
  150. scene: Scene;
  151. /**
  152. * Instantiates an AssetContainer.
  153. * @param scene The scene the AssetContainer belongs to.
  154. */
  155. constructor(scene: Scene);
  156. /**
  157. * Adds all the assets from the container to the scene.
  158. */
  159. addAllToScene(): void;
  160. /**
  161. * Removes all the assets in the container from the scene
  162. */
  163. removeAllFromScene(): void;
  164. /**
  165. * Disposes all the assets in the container
  166. */
  167. dispose(): void;
  168. private _moveAssets;
  169. /**
  170. * Removes all the assets contained in the scene and adds them to the container.
  171. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  172. */
  173. moveAllFromScene(keepAssets?: KeepAssets): void;
  174. /**
  175. * Adds all meshes in the asset container to a root mesh that can be used to position all the contained meshes. The root mesh is then added to the front of the meshes in the assetContainer.
  176. * @returns the root mesh
  177. */
  178. createRootMesh(): Mesh;
  179. }
  180. }
  181. interface Window {
  182. mozIndexedDB: IDBFactory;
  183. webkitIndexedDB: IDBFactory;
  184. msIndexedDB: IDBFactory;
  185. webkitURL: typeof URL;
  186. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  187. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  188. WebGLRenderingContext: WebGLRenderingContext;
  189. MSGesture: MSGesture;
  190. CANNON: any;
  191. AudioContext: AudioContext;
  192. webkitAudioContext: AudioContext;
  193. PointerEvent: any;
  194. Math: Math;
  195. Uint8Array: Uint8ArrayConstructor;
  196. Float32Array: Float32ArrayConstructor;
  197. mozURL: typeof URL;
  198. msURL: typeof URL;
  199. VRFrameData: any;
  200. DracoDecoderModule: any;
  201. setImmediate(handler: (...args: any[]) => void): number;
  202. }
  203. interface WebGLProgram {
  204. context?: WebGLRenderingContext;
  205. vertexShader?: WebGLShader;
  206. fragmentShader?: WebGLShader;
  207. isParallelCompiled: boolean;
  208. onCompiled?: () => void;
  209. }
  210. interface WebGLRenderingContext {
  211. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  212. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  213. vertexAttribDivisor(index: number, divisor: number): void;
  214. createVertexArray(): any;
  215. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  216. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  217. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  218. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  219. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  220. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  221. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  222. createQuery(): WebGLQuery;
  223. deleteQuery(query: WebGLQuery): void;
  224. beginQuery(target: number, query: WebGLQuery): void;
  225. endQuery(target: number): void;
  226. getQueryParameter(query: WebGLQuery, pname: number): any;
  227. getQuery(target: number, pname: number): any;
  228. MAX_SAMPLES: number;
  229. RGBA8: number;
  230. READ_FRAMEBUFFER: number;
  231. DRAW_FRAMEBUFFER: number;
  232. UNIFORM_BUFFER: number;
  233. HALF_FLOAT_OES: number;
  234. RGBA16F: number;
  235. RGBA32F: number;
  236. R32F: number;
  237. RG32F: number;
  238. RGB32F: number;
  239. R16F: number;
  240. RG16F: number;
  241. RGB16F: number;
  242. RED: number;
  243. RG: number;
  244. R8: number;
  245. RG8: number;
  246. UNSIGNED_INT_24_8: number;
  247. DEPTH24_STENCIL8: number;
  248. drawBuffers(buffers: number[]): void;
  249. readBuffer(src: number): void;
  250. readonly COLOR_ATTACHMENT0: number;
  251. readonly COLOR_ATTACHMENT1: number;
  252. readonly COLOR_ATTACHMENT2: number;
  253. readonly COLOR_ATTACHMENT3: number;
  254. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  255. ANY_SAMPLES_PASSED: number;
  256. QUERY_RESULT_AVAILABLE: number;
  257. QUERY_RESULT: number;
  258. }
  259. interface Document {
  260. mozCancelFullScreen(): void;
  261. msCancelFullScreen(): void;
  262. webkitCancelFullScreen(): void;
  263. requestPointerLock(): void;
  264. exitPointerLock(): void;
  265. mozFullScreen: boolean;
  266. msIsFullScreen: boolean;
  267. readonly webkitIsFullScreen: boolean;
  268. readonly pointerLockElement: Element;
  269. mozPointerLockElement: HTMLElement;
  270. msPointerLockElement: HTMLElement;
  271. webkitPointerLockElement: HTMLElement;
  272. }
  273. interface HTMLCanvasElement {
  274. requestPointerLock(): void;
  275. msRequestPointerLock?(): void;
  276. mozRequestPointerLock?(): void;
  277. webkitRequestPointerLock?(): void;
  278. }
  279. interface CanvasRenderingContext2D {
  280. msImageSmoothingEnabled: boolean;
  281. }
  282. interface WebGLBuffer {
  283. references: number;
  284. capacity: number;
  285. is32Bits: boolean;
  286. }
  287. interface WebGLProgram {
  288. transformFeedback?: WebGLTransformFeedback | null;
  289. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  290. }
  291. interface MouseEvent {
  292. mozMovementX: number;
  293. mozMovementY: number;
  294. webkitMovementX: number;
  295. webkitMovementY: number;
  296. msMovementX: number;
  297. msMovementY: number;
  298. }
  299. interface Navigator {
  300. mozGetVRDevices: (any: any) => any;
  301. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  302. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  303. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  304. webkitGetGamepads(): Gamepad[];
  305. msGetGamepads(): Gamepad[];
  306. webkitGamepads(): Gamepad[];
  307. }
  308. interface HTMLVideoElement {
  309. mozSrcObject: any;
  310. }
  311. interface Math {
  312. fround(x: number): number;
  313. imul(a: number, b: number): number;
  314. }
  315. interface EXT_disjoint_timer_query {
  316. QUERY_COUNTER_BITS_EXT: number;
  317. TIME_ELAPSED_EXT: number;
  318. TIMESTAMP_EXT: number;
  319. GPU_DISJOINT_EXT: number;
  320. QUERY_RESULT_EXT: number;
  321. QUERY_RESULT_AVAILABLE_EXT: number;
  322. queryCounterEXT(query: WebGLQuery, target: number): void;
  323. createQueryEXT(): WebGLQuery;
  324. beginQueryEXT(target: number, query: WebGLQuery): void;
  325. endQueryEXT(target: number): void;
  326. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  327. deleteQueryEXT(query: WebGLQuery): void;
  328. }
  329. interface WebGLUniformLocation {
  330. _currentState: any;
  331. }
  332. interface XRDevice {
  333. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  334. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  335. }
  336. interface XRSession {
  337. getInputSources(): Array<any>;
  338. baseLayer: XRWebGLLayer;
  339. requestFrameOfReference(type: string): Promise<void>;
  340. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  341. end(): Promise<void>;
  342. requestAnimationFrame: Function;
  343. addEventListener: Function;
  344. }
  345. interface XRSessionCreationOptions {
  346. outputContext?: WebGLRenderingContext | null;
  347. immersive?: boolean;
  348. environmentIntegration?: boolean;
  349. }
  350. interface XRLayer {
  351. getViewport: Function;
  352. framebufferWidth: number;
  353. framebufferHeight: number;
  354. }
  355. interface XRView {
  356. projectionMatrix: Float32Array;
  357. }
  358. interface XRFrame {
  359. getDevicePose: Function;
  360. getInputPose: Function;
  361. views: Array<XRView>;
  362. baseLayer: XRLayer;
  363. }
  364. interface XRFrameOfReference {
  365. }
  366. interface XRWebGLLayer extends XRLayer {
  367. framebuffer: WebGLFramebuffer;
  368. }
  369. declare var XRWebGLLayer: {
  370. prototype: XRWebGLLayer;
  371. new (session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  372. };
  373. declare module BABYLON {
  374. /**
  375. * Defines how a node can be built from a string name.
  376. */
  377. type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  378. /**
  379. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  380. */
  381. class Node implements IBehaviorAware<Node> {
  382. private static _NodeConstructors;
  383. /**
  384. * Add a new node constructor
  385. * @param type defines the type name of the node to construct
  386. * @param constructorFunc defines the constructor function
  387. */
  388. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  389. /**
  390. * Returns a node constructor based on type name
  391. * @param type defines the type name
  392. * @param name defines the new node name
  393. * @param scene defines the hosting scene
  394. * @param options defines optional options to transmit to constructors
  395. * @returns the new constructor or null
  396. */
  397. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  398. /**
  399. * Gets or sets the name of the node
  400. */
  401. name: string;
  402. /**
  403. * Gets or sets the id of the node
  404. */
  405. id: string;
  406. /**
  407. * Gets or sets the unique id of the node
  408. */
  409. uniqueId: number;
  410. /**
  411. * Gets or sets a string used to store user defined state for the node
  412. */
  413. state: string;
  414. /**
  415. * Gets or sets an object used to store user defined information for the node
  416. */
  417. metadata: any;
  418. /**
  419. * For internal use only. Please do not use.
  420. */
  421. reservedDataStore: any;
  422. /**
  423. * Gets or sets a boolean used to define if the node must be serialized
  424. */
  425. doNotSerialize: boolean;
  426. /** @hidden */
  427. _isDisposed: boolean;
  428. /**
  429. * Gets a list of Animations associated with the node
  430. */
  431. animations: Animation[];
  432. protected _ranges: {
  433. [name: string]: Nullable<AnimationRange>;
  434. };
  435. /**
  436. * Callback raised when the node is ready to be used
  437. */
  438. onReady: (node: Node) => void;
  439. private _isEnabled;
  440. private _isParentEnabled;
  441. private _isReady;
  442. /** @hidden */
  443. _currentRenderId: number;
  444. private _parentRenderId;
  445. protected _childRenderId: number;
  446. /** @hidden */
  447. _waitingParentId: Nullable<string>;
  448. /** @hidden */
  449. _scene: Scene;
  450. /** @hidden */
  451. _cache: any;
  452. private _parentNode;
  453. private _children;
  454. /** @hidden */
  455. _worldMatrix: Matrix;
  456. /** @hidden */
  457. _worldMatrixDeterminant: number;
  458. /** @hidden */
  459. private _sceneRootNodesIndex;
  460. /**
  461. * Gets a boolean indicating if the node has been disposed
  462. * @returns true if the node was disposed
  463. */
  464. isDisposed(): boolean;
  465. /**
  466. * Gets or sets the parent of the node
  467. */
  468. parent: Nullable<Node>;
  469. private addToSceneRootNodes;
  470. private removeFromSceneRootNodes;
  471. private _animationPropertiesOverride;
  472. /**
  473. * Gets or sets the animation properties override
  474. */
  475. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  476. /**
  477. * Gets a string idenfifying the name of the class
  478. * @returns "Node" string
  479. */
  480. getClassName(): string;
  481. /**
  482. * An event triggered when the mesh is disposed
  483. */
  484. onDisposeObservable: Observable<Node>;
  485. private _onDisposeObserver;
  486. /**
  487. * Sets a callback that will be raised when the node will be disposed
  488. */
  489. onDispose: () => void;
  490. /**
  491. * Creates a new Node
  492. * @param name the name and id to be given to this node
  493. * @param scene the scene this node will be added to
  494. * @param addToRootNodes the node will be added to scene.rootNodes
  495. */
  496. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  497. /**
  498. * Gets the scene of the node
  499. * @returns a scene
  500. */
  501. getScene(): Scene;
  502. /**
  503. * Gets the engine of the node
  504. * @returns a Engine
  505. */
  506. getEngine(): Engine;
  507. private _behaviors;
  508. /**
  509. * Attach a behavior to the node
  510. * @see http://doc.babylonjs.com/features/behaviour
  511. * @param behavior defines the behavior to attach
  512. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  513. * @returns the current Node
  514. */
  515. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  516. /**
  517. * Remove an attached behavior
  518. * @see http://doc.babylonjs.com/features/behaviour
  519. * @param behavior defines the behavior to attach
  520. * @returns the current Node
  521. */
  522. removeBehavior(behavior: Behavior<Node>): Node;
  523. /**
  524. * Gets the list of attached behaviors
  525. * @see http://doc.babylonjs.com/features/behaviour
  526. */
  527. readonly behaviors: Behavior<Node>[];
  528. /**
  529. * Gets an attached behavior by name
  530. * @param name defines the name of the behavior to look for
  531. * @see http://doc.babylonjs.com/features/behaviour
  532. * @returns null if behavior was not found else the requested behavior
  533. */
  534. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  535. /**
  536. * Returns the latest update of the World matrix
  537. * @returns a Matrix
  538. */
  539. getWorldMatrix(): Matrix;
  540. /** @hidden */
  541. _getWorldMatrixDeterminant(): number;
  542. /**
  543. * Returns directly the latest state of the mesh World matrix.
  544. * A Matrix is returned.
  545. */
  546. readonly worldMatrixFromCache: Matrix;
  547. /** @hidden */
  548. _initCache(): void;
  549. /** @hidden */
  550. updateCache(force?: boolean): void;
  551. /** @hidden */
  552. _updateCache(ignoreParentClass?: boolean): void;
  553. /** @hidden */
  554. _isSynchronized(): boolean;
  555. /** @hidden */
  556. _markSyncedWithParent(): void;
  557. /** @hidden */
  558. isSynchronizedWithParent(): boolean;
  559. /** @hidden */
  560. isSynchronized(): boolean;
  561. /**
  562. * Is this node ready to be used/rendered
  563. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  564. * @return true if the node is ready
  565. */
  566. isReady(completeCheck?: boolean): boolean;
  567. /**
  568. * Is this node enabled?
  569. * If the node has a parent, all ancestors will be checked and false will be returned if any are false (not enabled), otherwise will return true
  570. * @param checkAncestors indicates if this method should check the ancestors. The default is to check the ancestors. If set to false, the method will return the value of this node without checking ancestors
  571. * @return whether this node (and its parent) is enabled
  572. */
  573. isEnabled(checkAncestors?: boolean): boolean;
  574. /** @hidden */
  575. protected _syncParentEnabledState(): void;
  576. /**
  577. * Set the enabled state of this node
  578. * @param value defines the new enabled state
  579. */
  580. setEnabled(value: boolean): void;
  581. /**
  582. * Is this node a descendant of the given node?
  583. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  584. * @param ancestor defines the parent node to inspect
  585. * @returns a boolean indicating if this node is a descendant of the given node
  586. */
  587. isDescendantOf(ancestor: Node): boolean;
  588. /** @hidden */
  589. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  590. /**
  591. * Will return all nodes that have this node as ascendant
  592. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  593. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  594. * @return all children nodes of all types
  595. */
  596. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  597. /**
  598. * Get all child-meshes of this node
  599. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  600. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  601. * @returns an array of AbstractMesh
  602. */
  603. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  604. /**
  605. * Get all child-transformNodes of this node
  606. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  607. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  608. * @returns an array of TransformNode
  609. */
  610. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  611. /**
  612. * Get all direct children of this node
  613. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  614. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered (Default: true)
  615. * @returns an array of Node
  616. */
  617. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  618. /** @hidden */
  619. _setReady(state: boolean): void;
  620. /**
  621. * Get an animation by name
  622. * @param name defines the name of the animation to look for
  623. * @returns null if not found else the requested animation
  624. */
  625. getAnimationByName(name: string): Nullable<Animation>;
  626. /**
  627. * Creates an animation range for this node
  628. * @param name defines the name of the range
  629. * @param from defines the starting key
  630. * @param to defines the end key
  631. */
  632. createAnimationRange(name: string, from: number, to: number): void;
  633. /**
  634. * Delete a specific animation range
  635. * @param name defines the name of the range to delete
  636. * @param deleteFrames defines if animation frames from the range must be deleted as well
  637. */
  638. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  639. /**
  640. * Get an animation range by name
  641. * @param name defines the name of the animation range to look for
  642. * @returns null if not found else the requested animation range
  643. */
  644. getAnimationRange(name: string): Nullable<AnimationRange>;
  645. /**
  646. * Will start the animation sequence
  647. * @param name defines the range frames for animation sequence
  648. * @param loop defines if the animation should loop (false by default)
  649. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  650. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  651. * @returns the object created for this animation. If range does not exist, it will return null
  652. */
  653. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  654. /**
  655. * Serialize animation ranges into a JSON compatible object
  656. * @returns serialization object
  657. */
  658. serializeAnimationRanges(): any;
  659. /**
  660. * Computes the world matrix of the node
  661. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  662. * @returns the world matrix
  663. */
  664. computeWorldMatrix(force?: boolean): Matrix;
  665. /**
  666. * Releases resources associated with this node.
  667. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  668. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  669. */
  670. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  671. /**
  672. * Parse animation range data from a serialization object and store them into a given node
  673. * @param node defines where to store the animation ranges
  674. * @param parsedNode defines the serialization object to read data from
  675. * @param scene defines the hosting scene
  676. */
  677. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  678. }
  679. }
  680. declare module BABYLON {
  681. /**
  682. * Define an interface for all classes that will hold resources
  683. */
  684. interface IDisposable {
  685. /**
  686. * Releases all held resources
  687. */
  688. dispose(): void;
  689. }
  690. /**
  691. * This class is used by the onRenderingGroupObservable
  692. */
  693. class RenderingGroupInfo {
  694. /**
  695. * The Scene that being rendered
  696. */
  697. scene: Scene;
  698. /**
  699. * The camera currently used for the rendering pass
  700. */
  701. camera: Nullable<Camera>;
  702. /**
  703. * The ID of the renderingGroup being processed
  704. */
  705. renderingGroupId: number;
  706. }
  707. /** Interface defining initialization parameters for Scene class */
  708. interface SceneOptions {
  709. /**
  710. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by Id
  711. * It will improve performance when the number of geometries becomes important.
  712. */
  713. useGeometryIdsMap?: boolean;
  714. /**
  715. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  716. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  717. */
  718. useMaterialMeshMap?: boolean;
  719. /**
  720. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  721. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  722. */
  723. useClonedMeshhMap?: boolean;
  724. }
  725. /**
  726. * Represents a scene to be rendered by the engine.
  727. * @see http://doc.babylonjs.com/features/scene
  728. */
  729. class Scene extends AbstractScene implements IAnimatable {
  730. private static _uniqueIdCounter;
  731. /** The fog is deactivated */
  732. static readonly FOGMODE_NONE: number;
  733. /** The fog density is following an exponential function */
  734. static readonly FOGMODE_EXP: number;
  735. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  736. static readonly FOGMODE_EXP2: number;
  737. /** The fog density is following a linear function. */
  738. static readonly FOGMODE_LINEAR: number;
  739. /**
  740. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  741. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  742. */
  743. static MinDeltaTime: number;
  744. /**
  745. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  746. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  747. */
  748. static MaxDeltaTime: number;
  749. /**
  750. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  751. */
  752. autoClear: boolean;
  753. /**
  754. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  755. */
  756. autoClearDepthAndStencil: boolean;
  757. /**
  758. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  759. */
  760. clearColor: Color4;
  761. /**
  762. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  763. */
  764. ambientColor: Color3;
  765. /** @hidden */
  766. _environmentBRDFTexture: BaseTexture;
  767. /** @hidden */
  768. protected _environmentTexture: Nullable<BaseTexture>;
  769. /**
  770. * Texture used in all pbr material as the reflection texture.
  771. * As in the majority of the scene they are the same (exception for multi room and so on),
  772. * this is easier to reference from here than from all the materials.
  773. */
  774. /**
  775. * Texture used in all pbr material as the reflection texture.
  776. * As in the majority of the scene they are the same (exception for multi room and so on),
  777. * this is easier to set here than in all the materials.
  778. */
  779. environmentTexture: Nullable<BaseTexture>;
  780. /** @hidden */
  781. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  782. /**
  783. * Default image processing configuration used either in the rendering
  784. * Forward main pass or through the imageProcessingPostProcess if present.
  785. * As in the majority of the scene they are the same (exception for multi camera),
  786. * this is easier to reference from here than from all the materials and post process.
  787. *
  788. * No setter as we it is a shared configuration, you can set the values instead.
  789. */
  790. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  791. private _forceWireframe;
  792. /**
  793. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  794. */
  795. forceWireframe: boolean;
  796. private _forcePointsCloud;
  797. /**
  798. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  799. */
  800. forcePointsCloud: boolean;
  801. /**
  802. * Gets or sets the active clipplane 1
  803. */
  804. clipPlane: Nullable<Plane>;
  805. /**
  806. * Gets or sets the active clipplane 2
  807. */
  808. clipPlane2: Nullable<Plane>;
  809. /**
  810. * Gets or sets the active clipplane 3
  811. */
  812. clipPlane3: Nullable<Plane>;
  813. /**
  814. * Gets or sets the active clipplane 4
  815. */
  816. clipPlane4: Nullable<Plane>;
  817. /**
  818. * Gets or sets a boolean indicating if animations are enabled
  819. */
  820. animationsEnabled: boolean;
  821. private _animationPropertiesOverride;
  822. /**
  823. * Gets or sets the animation properties override
  824. */
  825. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  826. /**
  827. * Gets or sets a boolean indicating if a constant deltatime has to be used
  828. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  829. */
  830. useConstantAnimationDeltaTime: boolean;
  831. /**
  832. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  833. * Please note that it requires to run a ray cast through the scene on every frame
  834. */
  835. constantlyUpdateMeshUnderPointer: boolean;
  836. /**
  837. * Defines the HTML cursor to use when hovering over interactive elements
  838. */
  839. hoverCursor: string;
  840. /**
  841. * Defines the HTML default cursor to use (empty by default)
  842. */
  843. defaultCursor: string;
  844. /**
  845. * This is used to call preventDefault() on pointer down
  846. * in order to block unwanted artifacts like system double clicks
  847. */
  848. preventDefaultOnPointerDown: boolean;
  849. /**
  850. * This is used to call preventDefault() on pointer up
  851. * in order to block unwanted artifacts like system double clicks
  852. */
  853. preventDefaultOnPointerUp: boolean;
  854. /**
  855. * Gets or sets user defined metadata
  856. */
  857. metadata: any;
  858. /**
  859. * For internal use only. Please do not use.
  860. */
  861. reservedDataStore: any;
  862. /**
  863. * Gets the name of the plugin used to load this scene (null by default)
  864. */
  865. loadingPluginName: string;
  866. /**
  867. * Use this array to add regular expressions used to disable offline support for specific urls
  868. */
  869. disableOfflineSupportExceptionRules: RegExp[];
  870. /**
  871. * An event triggered when the scene is disposed.
  872. */
  873. onDisposeObservable: Observable<Scene>;
  874. private _onDisposeObserver;
  875. /** Sets a function to be executed when this scene is disposed. */
  876. onDispose: () => void;
  877. /**
  878. * An event triggered before rendering the scene (right after animations and physics)
  879. */
  880. onBeforeRenderObservable: Observable<Scene>;
  881. private _onBeforeRenderObserver;
  882. /** Sets a function to be executed before rendering this scene */
  883. beforeRender: Nullable<() => void>;
  884. /**
  885. * An event triggered after rendering the scene
  886. */
  887. onAfterRenderObservable: Observable<Scene>;
  888. private _onAfterRenderObserver;
  889. /** Sets a function to be executed after rendering this scene */
  890. afterRender: Nullable<() => void>;
  891. /**
  892. * An event triggered before animating the scene
  893. */
  894. onBeforeAnimationsObservable: Observable<Scene>;
  895. /**
  896. * An event triggered after animations processing
  897. */
  898. onAfterAnimationsObservable: Observable<Scene>;
  899. /**
  900. * An event triggered before draw calls are ready to be sent
  901. */
  902. onBeforeDrawPhaseObservable: Observable<Scene>;
  903. /**
  904. * An event triggered after draw calls have been sent
  905. */
  906. onAfterDrawPhaseObservable: Observable<Scene>;
  907. /**
  908. * An event triggered when the scene is ready
  909. */
  910. onReadyObservable: Observable<Scene>;
  911. /**
  912. * An event triggered before rendering a camera
  913. */
  914. onBeforeCameraRenderObservable: Observable<Camera>;
  915. private _onBeforeCameraRenderObserver;
  916. /** Sets a function to be executed before rendering a camera*/
  917. beforeCameraRender: () => void;
  918. /**
  919. * An event triggered after rendering a camera
  920. */
  921. onAfterCameraRenderObservable: Observable<Camera>;
  922. private _onAfterCameraRenderObserver;
  923. /** Sets a function to be executed after rendering a camera*/
  924. afterCameraRender: () => void;
  925. /**
  926. * An event triggered when active meshes evaluation is about to start
  927. */
  928. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  929. /**
  930. * An event triggered when active meshes evaluation is done
  931. */
  932. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  933. /**
  934. * An event triggered when particles rendering is about to start
  935. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  936. */
  937. onBeforeParticlesRenderingObservable: Observable<Scene>;
  938. /**
  939. * An event triggered when particles rendering is done
  940. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  941. */
  942. onAfterParticlesRenderingObservable: Observable<Scene>;
  943. /**
  944. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  945. */
  946. onDataLoadedObservable: Observable<Scene>;
  947. /**
  948. * An event triggered when a camera is created
  949. */
  950. onNewCameraAddedObservable: Observable<Camera>;
  951. /**
  952. * An event triggered when a camera is removed
  953. */
  954. onCameraRemovedObservable: Observable<Camera>;
  955. /**
  956. * An event triggered when a light is created
  957. */
  958. onNewLightAddedObservable: Observable<Light>;
  959. /**
  960. * An event triggered when a light is removed
  961. */
  962. onLightRemovedObservable: Observable<Light>;
  963. /**
  964. * An event triggered when a geometry is created
  965. */
  966. onNewGeometryAddedObservable: Observable<Geometry>;
  967. /**
  968. * An event triggered when a geometry is removed
  969. */
  970. onGeometryRemovedObservable: Observable<Geometry>;
  971. /**
  972. * An event triggered when a transform node is created
  973. */
  974. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  975. /**
  976. * An event triggered when a transform node is removed
  977. */
  978. onTransformNodeRemovedObservable: Observable<TransformNode>;
  979. /**
  980. * An event triggered when a mesh is created
  981. */
  982. onNewMeshAddedObservable: Observable<AbstractMesh>;
  983. /**
  984. * An event triggered when a mesh is removed
  985. */
  986. onMeshRemovedObservable: Observable<AbstractMesh>;
  987. /**
  988. * An event triggered when a material is created
  989. */
  990. onNewMaterialAddedObservable: Observable<Material>;
  991. /**
  992. * An event triggered when a material is removed
  993. */
  994. onMaterialRemovedObservable: Observable<Material>;
  995. /**
  996. * An event triggered when a texture is created
  997. */
  998. onNewTextureAddedObservable: Observable<BaseTexture>;
  999. /**
  1000. * An event triggered when a texture is removed
  1001. */
  1002. onTextureRemovedObservable: Observable<BaseTexture>;
  1003. /**
  1004. * An event triggered when render targets are about to be rendered
  1005. * Can happen multiple times per frame.
  1006. */
  1007. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  1008. /**
  1009. * An event triggered when render targets were rendered.
  1010. * Can happen multiple times per frame.
  1011. */
  1012. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  1013. /**
  1014. * An event triggered before calculating deterministic simulation step
  1015. */
  1016. onBeforeStepObservable: Observable<Scene>;
  1017. /**
  1018. * An event triggered after calculating deterministic simulation step
  1019. */
  1020. onAfterStepObservable: Observable<Scene>;
  1021. /**
  1022. * An event triggered when the activeCamera property is updated
  1023. */
  1024. onActiveCameraChanged: Observable<Scene>;
  1025. /**
  1026. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  1027. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  1028. * If you wish to register an Observer only for a given set of renderingGroup, use the mask with a combination of the renderingGroup index elevated to the power of two (1 for renderingGroup 0, 2 for renderingrOup1, 4 for 2 and 8 for 3)
  1029. */
  1030. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  1031. /**
  1032. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  1033. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  1034. * If you wish to register an Observer only for a given set of renderingGroup, use the mask with a combination of the renderingGroup index elevated to the power of two (1 for renderingGroup 0, 2 for renderingrOup1, 4 for 2 and 8 for 3)
  1035. */
  1036. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  1037. /**
  1038. * This Observable will when a mesh has been imported into the scene.
  1039. */
  1040. onMeshImportedObservable: Observable<AbstractMesh>;
  1041. private _registeredForLateAnimationBindings;
  1042. /**
  1043. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  1044. */
  1045. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  1046. /**
  1047. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  1048. */
  1049. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  1050. /**
  1051. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  1052. */
  1053. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  1054. private _onPointerMove;
  1055. private _onPointerDown;
  1056. private _onPointerUp;
  1057. /** Callback called when a pointer move is detected */
  1058. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  1059. /** Callback called when a pointer down is detected */
  1060. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  1061. /** Callback called when a pointer up is detected */
  1062. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  1063. /** Callback called when a pointer pick is detected */
  1064. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  1065. /**
  1066. * This observable event is triggered when any ponter event is triggered. It is registered during Scene.attachControl() and it is called BEFORE the 3D engine process anything (mesh/sprite picking for instance).
  1067. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  1068. */
  1069. onPrePointerObservable: Observable<PointerInfoPre>;
  1070. /**
  1071. * Observable event triggered each time an input event is received from the rendering canvas
  1072. */
  1073. onPointerObservable: Observable<PointerInfo>;
  1074. /**
  1075. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  1076. */
  1077. readonly unTranslatedPointer: Vector2;
  1078. /** The distance in pixel that you have to move to prevent some events */
  1079. static DragMovementThreshold: number;
  1080. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  1081. static LongPressDelay: number;
  1082. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  1083. static DoubleClickDelay: number;
  1084. /** If you need to check double click without raising a single click at first click, enable this flag */
  1085. static ExclusiveDoubleClickMode: boolean;
  1086. private _initClickEvent;
  1087. private _initActionManager;
  1088. private _delayedSimpleClick;
  1089. private _delayedSimpleClickTimeout;
  1090. private _previousDelayedSimpleClickTimeout;
  1091. private _meshPickProceed;
  1092. private _previousButtonPressed;
  1093. private _currentPickResult;
  1094. private _previousPickResult;
  1095. private _totalPointersPressed;
  1096. private _doubleClickOccured;
  1097. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  1098. cameraToUseForPointers: Nullable<Camera>;
  1099. private _pointerX;
  1100. private _pointerY;
  1101. private _unTranslatedPointerX;
  1102. private _unTranslatedPointerY;
  1103. private _startingPointerPosition;
  1104. private _previousStartingPointerPosition;
  1105. private _startingPointerTime;
  1106. private _previousStartingPointerTime;
  1107. private _pointerCaptures;
  1108. private _timeAccumulator;
  1109. private _currentStepId;
  1110. private _currentInternalStep;
  1111. /** @hidden */
  1112. _mirroredCameraPosition: Nullable<Vector3>;
  1113. /**
  1114. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  1115. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  1116. */
  1117. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  1118. /**
  1119. * Observable event triggered each time an keyboard event is received from the hosting window
  1120. */
  1121. onKeyboardObservable: Observable<KeyboardInfo>;
  1122. private _onKeyDown;
  1123. private _onKeyUp;
  1124. private _onCanvasFocusObserver;
  1125. private _onCanvasBlurObserver;
  1126. private _useRightHandedSystem;
  1127. /**
  1128. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  1129. */
  1130. useRightHandedSystem: boolean;
  1131. /**
  1132. * Sets the step Id used by deterministic lock step
  1133. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1134. * @param newStepId defines the step Id
  1135. */
  1136. setStepId(newStepId: number): void;
  1137. /**
  1138. * Gets the step Id used by deterministic lock step
  1139. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1140. * @returns the step Id
  1141. */
  1142. getStepId(): number;
  1143. /**
  1144. * Gets the internal step used by deterministic lock step
  1145. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1146. * @returns the internal step
  1147. */
  1148. getInternalStep(): number;
  1149. private _fogEnabled;
  1150. /**
  1151. * Gets or sets a boolean indicating if fog is enabled on this scene
  1152. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1153. * (Default is true)
  1154. */
  1155. fogEnabled: boolean;
  1156. private _fogMode;
  1157. /**
  1158. * Gets or sets the fog mode to use
  1159. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1160. * | mode | value |
  1161. * | --- | --- |
  1162. * | FOGMODE_NONE | 0 |
  1163. * | FOGMODE_EXP | 1 |
  1164. * | FOGMODE_EXP2 | 2 |
  1165. * | FOGMODE_LINEAR | 3 |
  1166. */
  1167. fogMode: number;
  1168. /**
  1169. * Gets or sets the fog color to use
  1170. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1171. * (Default is Color3(0.2, 0.2, 0.3))
  1172. */
  1173. fogColor: Color3;
  1174. /**
  1175. * Gets or sets the fog density to use
  1176. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1177. * (Default is 0.1)
  1178. */
  1179. fogDensity: number;
  1180. /**
  1181. * Gets or sets the fog start distance to use
  1182. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1183. * (Default is 0)
  1184. */
  1185. fogStart: number;
  1186. /**
  1187. * Gets or sets the fog end distance to use
  1188. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1189. * (Default is 1000)
  1190. */
  1191. fogEnd: number;
  1192. private _shadowsEnabled;
  1193. /**
  1194. * Gets or sets a boolean indicating if shadows are enabled on this scene
  1195. */
  1196. shadowsEnabled: boolean;
  1197. private _lightsEnabled;
  1198. /**
  1199. * Gets or sets a boolean indicating if lights are enabled on this scene
  1200. */
  1201. lightsEnabled: boolean;
  1202. /** All of the active cameras added to this scene. */
  1203. activeCameras: Camera[];
  1204. private _activeCamera;
  1205. /** Gets or sets the current active camera */
  1206. activeCamera: Nullable<Camera>;
  1207. private _defaultMaterial;
  1208. /** The default material used on meshes when no material is affected */
  1209. /** The default material used on meshes when no material is affected */
  1210. defaultMaterial: Material;
  1211. private _texturesEnabled;
  1212. /**
  1213. * Gets or sets a boolean indicating if textures are enabled on this scene
  1214. */
  1215. texturesEnabled: boolean;
  1216. /**
  1217. * Gets or sets a boolean indicating if particles are enabled on this scene
  1218. */
  1219. particlesEnabled: boolean;
  1220. /**
  1221. * Gets or sets a boolean indicating if sprites are enabled on this scene
  1222. */
  1223. spritesEnabled: boolean;
  1224. private _skeletonsEnabled;
  1225. /**
  1226. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  1227. */
  1228. skeletonsEnabled: boolean;
  1229. /**
  1230. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  1231. */
  1232. lensFlaresEnabled: boolean;
  1233. /**
  1234. * Gets or sets a boolean indicating if collisions are enabled on this scene
  1235. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1236. */
  1237. collisionsEnabled: boolean;
  1238. private _workerCollisions;
  1239. /** @hidden */
  1240. collisionCoordinator: ICollisionCoordinator;
  1241. /**
  1242. * Defines the gravity applied to this scene (used only for collisions)
  1243. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1244. */
  1245. gravity: Vector3;
  1246. /**
  1247. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  1248. */
  1249. postProcessesEnabled: boolean;
  1250. /**
  1251. * The list of postprocesses added to the scene
  1252. */
  1253. postProcesses: PostProcess[];
  1254. /**
  1255. * Gets the current postprocess manager
  1256. */
  1257. postProcessManager: PostProcessManager;
  1258. /**
  1259. * Gets or sets a boolean indicating if render targets are enabled on this scene
  1260. */
  1261. renderTargetsEnabled: boolean;
  1262. /**
  1263. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  1264. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  1265. */
  1266. dumpNextRenderTargets: boolean;
  1267. /**
  1268. * The list of user defined render targets added to the scene
  1269. */
  1270. customRenderTargets: RenderTargetTexture[];
  1271. /**
  1272. * Defines if texture loading must be delayed
  1273. * If true, textures will only be loaded when they need to be rendered
  1274. */
  1275. useDelayedTextureLoading: boolean;
  1276. /**
  1277. * Gets the list of meshes imported to the scene through SceneLoader
  1278. */
  1279. importedMeshesFiles: String[];
  1280. /**
  1281. * Gets or sets a boolean indicating if probes are enabled on this scene
  1282. */
  1283. probesEnabled: boolean;
  1284. /**
  1285. * Gets or sets the current offline provider to use to store scene data
  1286. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1287. */
  1288. offlineProvider: IOfflineProvider;
  1289. /**
  1290. * Gets or sets the action manager associated with the scene
  1291. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1292. */
  1293. actionManager: ActionManager;
  1294. private _meshesForIntersections;
  1295. /**
  1296. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  1297. */
  1298. proceduralTexturesEnabled: boolean;
  1299. private _engine;
  1300. private _totalVertices;
  1301. /** @hidden */
  1302. _activeIndices: PerfCounter;
  1303. /** @hidden */
  1304. _activeParticles: PerfCounter;
  1305. /** @hidden */
  1306. _activeBones: PerfCounter;
  1307. private _animationRatio;
  1308. private _animationTimeLast;
  1309. private _animationTime;
  1310. /**
  1311. * Gets or sets a general scale for animation speed
  1312. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  1313. */
  1314. animationTimeScale: number;
  1315. /** @hidden */
  1316. _cachedMaterial: Nullable<Material>;
  1317. /** @hidden */
  1318. _cachedEffect: Nullable<Effect>;
  1319. /** @hidden */
  1320. _cachedVisibility: Nullable<number>;
  1321. private _renderId;
  1322. private _frameId;
  1323. private _executeWhenReadyTimeoutId;
  1324. private _intermediateRendering;
  1325. private _viewUpdateFlag;
  1326. private _projectionUpdateFlag;
  1327. private _alternateViewUpdateFlag;
  1328. private _alternateProjectionUpdateFlag;
  1329. /** @hidden */
  1330. _toBeDisposed: Nullable<IDisposable>[];
  1331. private _activeRequests;
  1332. private _pendingData;
  1333. private _isDisposed;
  1334. /**
  1335. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  1336. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  1337. */
  1338. dispatchAllSubMeshesOfActiveMeshes: boolean;
  1339. private _activeMeshes;
  1340. private _processedMaterials;
  1341. private _renderTargets;
  1342. /** @hidden */
  1343. _activeParticleSystems: SmartArray<IParticleSystem>;
  1344. private _activeSkeletons;
  1345. private _softwareSkinnedMeshes;
  1346. private _renderingManager;
  1347. /** @hidden */
  1348. _activeAnimatables: Animatable[];
  1349. private _transformMatrix;
  1350. private _sceneUbo;
  1351. private _alternateSceneUbo;
  1352. private _pickWithRayInverseMatrix;
  1353. private _viewMatrix;
  1354. private _projectionMatrix;
  1355. private _alternateViewMatrix;
  1356. private _alternateProjectionMatrix;
  1357. private _alternateTransformMatrix;
  1358. private _useAlternateCameraConfiguration;
  1359. private _alternateRendering;
  1360. private _wheelEventName;
  1361. /** @hidden */
  1362. _forcedViewPosition: Nullable<Vector3>;
  1363. /** @hidden */
  1364. readonly _isAlternateRenderingEnabled: boolean;
  1365. private _frustumPlanes;
  1366. /**
  1367. * Gets the list of frustum planes (built from the active camera)
  1368. */
  1369. readonly frustumPlanes: Plane[];
  1370. /**
  1371. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  1372. * This is useful if there are more lights that the maximum simulteanous authorized
  1373. */
  1374. requireLightSorting: boolean;
  1375. /** @hidden */
  1376. readonly useMaterialMeshMap: boolean;
  1377. /** @hidden */
  1378. readonly useClonedMeshhMap: boolean;
  1379. private _pointerOverMesh;
  1380. private _pickedDownMesh;
  1381. private _pickedUpMesh;
  1382. private _externalData;
  1383. private _uid;
  1384. /**
  1385. * @hidden
  1386. * Backing store of defined scene components.
  1387. */
  1388. _components: ISceneComponent[];
  1389. /**
  1390. * @hidden
  1391. * Backing store of defined scene components.
  1392. */
  1393. _serializableComponents: ISceneSerializableComponent[];
  1394. /**
  1395. * List of components to register on the next registration step.
  1396. */
  1397. private _transientComponents;
  1398. /**
  1399. * Registers the transient components if needed.
  1400. */
  1401. private _registerTransientComponents;
  1402. /**
  1403. * @hidden
  1404. * Add a component to the scene.
  1405. * Note that the ccomponent could be registered on th next frame if this is called after
  1406. * the register component stage.
  1407. * @param component Defines the component to add to the scene
  1408. */
  1409. _addComponent(component: ISceneComponent): void;
  1410. /**
  1411. * @hidden
  1412. * Gets a component from the scene.
  1413. * @param name defines the name of the component to retrieve
  1414. * @returns the component or null if not present
  1415. */
  1416. _getComponent(name: string): Nullable<ISceneComponent>;
  1417. /**
  1418. * @hidden
  1419. * Defines the actions happening before camera updates.
  1420. */
  1421. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  1422. /**
  1423. * @hidden
  1424. * Defines the actions happening before clear the canvas.
  1425. */
  1426. _beforeClearStage: Stage<SimpleStageAction>;
  1427. /**
  1428. * @hidden
  1429. * Defines the actions when collecting render targets for the frame.
  1430. */
  1431. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  1432. /**
  1433. * @hidden
  1434. * Defines the actions happening for one camera in the frame.
  1435. */
  1436. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  1437. /**
  1438. * @hidden
  1439. * Defines the actions happening during the per mesh ready checks.
  1440. */
  1441. _isReadyForMeshStage: Stage<MeshStageAction>;
  1442. /**
  1443. * @hidden
  1444. * Defines the actions happening before evaluate active mesh checks.
  1445. */
  1446. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  1447. /**
  1448. * @hidden
  1449. * Defines the actions happening during the evaluate sub mesh checks.
  1450. */
  1451. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  1452. /**
  1453. * @hidden
  1454. * Defines the actions happening during the active mesh stage.
  1455. */
  1456. _activeMeshStage: Stage<ActiveMeshStageAction>;
  1457. /**
  1458. * @hidden
  1459. * Defines the actions happening during the per camera render target step.
  1460. */
  1461. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  1462. /**
  1463. * @hidden
  1464. * Defines the actions happening just before the active camera is drawing.
  1465. */
  1466. _beforeCameraDrawStage: Stage<CameraStageAction>;
  1467. /**
  1468. * @hidden
  1469. * Defines the actions happening just before a render target is drawing.
  1470. */
  1471. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  1472. /**
  1473. * @hidden
  1474. * Defines the actions happening just before a rendering group is drawing.
  1475. */
  1476. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  1477. /**
  1478. * @hidden
  1479. * Defines the actions happening just before a mesh is drawing.
  1480. */
  1481. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  1482. /**
  1483. * @hidden
  1484. * Defines the actions happening just after a mesh has been drawn.
  1485. */
  1486. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  1487. /**
  1488. * @hidden
  1489. * Defines the actions happening just after a rendering group has been drawn.
  1490. */
  1491. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  1492. /**
  1493. * @hidden
  1494. * Defines the actions happening just after the active camera has been drawn.
  1495. */
  1496. _afterCameraDrawStage: Stage<CameraStageAction>;
  1497. /**
  1498. * @hidden
  1499. * Defines the actions happening just after a render target has been drawn.
  1500. */
  1501. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  1502. /**
  1503. * @hidden
  1504. * Defines the actions happening just after rendering all cameras and computing intersections.
  1505. */
  1506. _afterRenderStage: Stage<SimpleStageAction>;
  1507. /**
  1508. * @hidden
  1509. * Defines the actions happening when a pointer move event happens.
  1510. */
  1511. _pointerMoveStage: Stage<PointerMoveStageAction>;
  1512. /**
  1513. * @hidden
  1514. * Defines the actions happening when a pointer down event happens.
  1515. */
  1516. _pointerDownStage: Stage<PointerUpDownStageAction>;
  1517. /**
  1518. * @hidden
  1519. * Defines the actions happening when a pointer up event happens.
  1520. */
  1521. _pointerUpStage: Stage<PointerUpDownStageAction>;
  1522. /**
  1523. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  1524. */
  1525. private geometriesById;
  1526. /**
  1527. * Creates a new Scene
  1528. * @param engine defines the engine to use to render this scene
  1529. */
  1530. constructor(engine: Engine, options?: SceneOptions);
  1531. private _defaultMeshCandidates;
  1532. /**
  1533. * @hidden
  1534. */
  1535. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  1536. private _defaultSubMeshCandidates;
  1537. /**
  1538. * @hidden
  1539. */
  1540. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  1541. /**
  1542. * Sets the default candidate providers for the scene.
  1543. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  1544. * and getCollidingSubMeshCandidates to their default function
  1545. */
  1546. setDefaultCandidateProviders(): void;
  1547. /**
  1548. * Gets a boolean indicating if collisions are processed on a web worker
  1549. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#web-worker-based-collision-system-since-21
  1550. */
  1551. workerCollisions: boolean;
  1552. /**
  1553. * Gets the mesh that is currently under the pointer
  1554. */
  1555. readonly meshUnderPointer: Nullable<AbstractMesh>;
  1556. /**
  1557. * Gets the current on-screen X position of the pointer
  1558. */
  1559. readonly pointerX: number;
  1560. /**
  1561. * Gets the current on-screen Y position of the pointer
  1562. */
  1563. readonly pointerY: number;
  1564. /**
  1565. * Gets the cached material (ie. the latest rendered one)
  1566. * @returns the cached material
  1567. */
  1568. getCachedMaterial(): Nullable<Material>;
  1569. /**
  1570. * Gets the cached effect (ie. the latest rendered one)
  1571. * @returns the cached effect
  1572. */
  1573. getCachedEffect(): Nullable<Effect>;
  1574. /**
  1575. * Gets the cached visibility state (ie. the latest rendered one)
  1576. * @returns the cached visibility state
  1577. */
  1578. getCachedVisibility(): Nullable<number>;
  1579. /**
  1580. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  1581. * @param material defines the current material
  1582. * @param effect defines the current effect
  1583. * @param visibility defines the current visibility state
  1584. * @returns true if one parameter is not cached
  1585. */
  1586. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  1587. /**
  1588. * Gets the engine associated with the scene
  1589. * @returns an Engine
  1590. */
  1591. getEngine(): Engine;
  1592. /**
  1593. * Gets the total number of vertices rendered per frame
  1594. * @returns the total number of vertices rendered per frame
  1595. */
  1596. getTotalVertices(): number;
  1597. /**
  1598. * Gets the performance counter for total vertices
  1599. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1600. */
  1601. readonly totalVerticesPerfCounter: PerfCounter;
  1602. /**
  1603. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  1604. * @returns the total number of active indices rendered per frame
  1605. */
  1606. getActiveIndices(): number;
  1607. /**
  1608. * Gets the performance counter for active indices
  1609. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1610. */
  1611. readonly totalActiveIndicesPerfCounter: PerfCounter;
  1612. /**
  1613. * Gets the total number of active particles rendered per frame
  1614. * @returns the total number of active particles rendered per frame
  1615. */
  1616. getActiveParticles(): number;
  1617. /**
  1618. * Gets the performance counter for active particles
  1619. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1620. */
  1621. readonly activeParticlesPerfCounter: PerfCounter;
  1622. /**
  1623. * Gets the total number of active bones rendered per frame
  1624. * @returns the total number of active bones rendered per frame
  1625. */
  1626. getActiveBones(): number;
  1627. /**
  1628. * Gets the performance counter for active bones
  1629. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1630. */
  1631. readonly activeBonesPerfCounter: PerfCounter;
  1632. /**
  1633. * Gets the array of active meshes
  1634. * @returns an array of AbstractMesh
  1635. */
  1636. getActiveMeshes(): SmartArray<AbstractMesh>;
  1637. /**
  1638. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  1639. * @returns a number
  1640. */
  1641. getAnimationRatio(): number;
  1642. /**
  1643. * Gets an unique Id for the current render phase
  1644. * @returns a number
  1645. */
  1646. getRenderId(): number;
  1647. /**
  1648. * Gets an unique Id for the current frame
  1649. * @returns a number
  1650. */
  1651. getFrameId(): number;
  1652. /** Call this function if you want to manually increment the render Id*/
  1653. incrementRenderId(): void;
  1654. private _updatePointerPosition;
  1655. private _createUbo;
  1656. private _createAlternateUbo;
  1657. private _setRayOnPointerInfo;
  1658. /**
  1659. * Use this method to simulate a pointer move on a mesh
  1660. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1661. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1662. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1663. * @returns the current scene
  1664. */
  1665. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1666. private _processPointerMove;
  1667. private _checkPrePointerObservable;
  1668. /**
  1669. * Use this method to simulate a pointer down on a mesh
  1670. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1671. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1672. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1673. * @returns the current scene
  1674. */
  1675. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1676. private _processPointerDown;
  1677. /**
  1678. * Use this method to simulate a pointer up on a mesh
  1679. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1680. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1681. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1682. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  1683. * @returns the current scene
  1684. */
  1685. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  1686. private _processPointerUp;
  1687. /**
  1688. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  1689. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  1690. * @returns true if the pointer was captured
  1691. */
  1692. isPointerCaptured(pointerId?: number): boolean;
  1693. /** @hidden */
  1694. _isPointerSwiping(): boolean;
  1695. /**
  1696. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  1697. * @param attachUp defines if you want to attach events to pointerup
  1698. * @param attachDown defines if you want to attach events to pointerdown
  1699. * @param attachMove defines if you want to attach events to pointermove
  1700. */
  1701. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  1702. /** Detaches all event handlers*/
  1703. detachControl(): void;
  1704. /**
  1705. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  1706. * Delay loaded resources are not taking in account
  1707. * @return true if all required resources are ready
  1708. */
  1709. isReady(): boolean;
  1710. /** Resets all cached information relative to material (including effect and visibility) */
  1711. resetCachedMaterial(): void;
  1712. /**
  1713. * Registers a function to be called before every frame render
  1714. * @param func defines the function to register
  1715. */
  1716. registerBeforeRender(func: () => void): void;
  1717. /**
  1718. * Unregisters a function called before every frame render
  1719. * @param func defines the function to unregister
  1720. */
  1721. unregisterBeforeRender(func: () => void): void;
  1722. /**
  1723. * Registers a function to be called after every frame render
  1724. * @param func defines the function to register
  1725. */
  1726. registerAfterRender(func: () => void): void;
  1727. /**
  1728. * Unregisters a function called after every frame render
  1729. * @param func defines the function to unregister
  1730. */
  1731. unregisterAfterRender(func: () => void): void;
  1732. private _executeOnceBeforeRender;
  1733. /**
  1734. * The provided function will run before render once and will be disposed afterwards.
  1735. * A timeout delay can be provided so that the function will be executed in N ms.
  1736. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  1737. * @param func The function to be executed.
  1738. * @param timeout optional delay in ms
  1739. */
  1740. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  1741. /** @hidden */
  1742. _addPendingData(data: any): void;
  1743. /** @hidden */
  1744. _removePendingData(data: any): void;
  1745. /**
  1746. * Returns the number of items waiting to be loaded
  1747. * @returns the number of items waiting to be loaded
  1748. */
  1749. getWaitingItemsCount(): number;
  1750. /**
  1751. * Returns a boolean indicating if the scene is still loading data
  1752. */
  1753. readonly isLoading: boolean;
  1754. /**
  1755. * Registers a function to be executed when the scene is ready
  1756. * @param {Function} func - the function to be executed
  1757. */
  1758. executeWhenReady(func: () => void): void;
  1759. /**
  1760. * Returns a promise that resolves when the scene is ready
  1761. * @returns A promise that resolves when the scene is ready
  1762. */
  1763. whenReadyAsync(): Promise<void>;
  1764. /** @hidden */
  1765. _checkIsReady(): void;
  1766. /**
  1767. * Will start the animation sequence of a given target
  1768. * @param target defines the target
  1769. * @param from defines from which frame should animation start
  1770. * @param to defines until which frame should animation run.
  1771. * @param weight defines the weight to apply to the animation (1.0 by default)
  1772. * @param loop defines if the animation loops
  1773. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1774. * @param onAnimationEnd defines the function to be executed when the animation ends
  1775. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1776. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  1777. * @returns the animatable object created for this animation
  1778. */
  1779. beginWeightedAnimation(target: any, from: number, to: number, weight?: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean): Animatable;
  1780. /**
  1781. * Will start the animation sequence of a given target
  1782. * @param target defines the target
  1783. * @param from defines from which frame should animation start
  1784. * @param to defines until which frame should animation run.
  1785. * @param loop defines if the animation loops
  1786. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1787. * @param onAnimationEnd defines the function to be executed when the animation ends
  1788. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1789. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  1790. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  1791. * @returns the animatable object created for this animation
  1792. */
  1793. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean): Animatable;
  1794. /**
  1795. * Will start the animation sequence of a given target and its hierarchy
  1796. * @param target defines the target
  1797. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  1798. * @param from defines from which frame should animation start
  1799. * @param to defines until which frame should animation run.
  1800. * @param loop defines if the animation loops
  1801. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1802. * @param onAnimationEnd defines the function to be executed when the animation ends
  1803. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1804. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  1805. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  1806. * @returns the list of created animatables
  1807. */
  1808. beginHierarchyAnimation(target: any, directDescendantsOnly: boolean, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean): Animatable[];
  1809. /**
  1810. * Begin a new animation on a given node
  1811. * @param target defines the target where the animation will take place
  1812. * @param animations defines the list of animations to start
  1813. * @param from defines the initial value
  1814. * @param to defines the final value
  1815. * @param loop defines if you want animation to loop (off by default)
  1816. * @param speedRatio defines the speed ratio to apply to all animations
  1817. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1818. * @returns the list of created animatables
  1819. */
  1820. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable;
  1821. /**
  1822. * Begin a new animation on a given node and its hierarchy
  1823. * @param target defines the root node where the animation will take place
  1824. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  1825. * @param animations defines the list of animations to start
  1826. * @param from defines the initial value
  1827. * @param to defines the final value
  1828. * @param loop defines if you want animation to loop (off by default)
  1829. * @param speedRatio defines the speed ratio to apply to all animations
  1830. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1831. * @returns the list of animatables created for all nodes
  1832. */
  1833. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable[];
  1834. /**
  1835. * Gets the animatable associated with a specific target
  1836. * @param target defines the target of the animatable
  1837. * @returns the required animatable if found
  1838. */
  1839. getAnimatableByTarget(target: any): Nullable<Animatable>;
  1840. /**
  1841. * Gets all animatables associated with a given target
  1842. * @param target defines the target to look animatables for
  1843. * @returns an array of Animatables
  1844. */
  1845. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  1846. /**
  1847. * Gets all animatable attached to the scene
  1848. */
  1849. readonly animatables: Animatable[];
  1850. /**
  1851. * Will stop the animation of the given target
  1852. * @param target - the target
  1853. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  1854. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  1855. */
  1856. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  1857. /**
  1858. * Stops and removes all animations that have been applied to the scene
  1859. */
  1860. stopAllAnimations(): void;
  1861. private _animate;
  1862. /** @hidden */
  1863. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  1864. private _processLateAnimationBindingsForMatrices;
  1865. private _processLateAnimationBindingsForQuaternions;
  1866. private _processLateAnimationBindings;
  1867. /** @hidden */
  1868. _switchToAlternateCameraConfiguration(active: boolean): void;
  1869. /**
  1870. * Gets the current view matrix
  1871. * @returns a Matrix
  1872. */
  1873. getViewMatrix(): Matrix;
  1874. /**
  1875. * Gets the current projection matrix
  1876. * @returns a Matrix
  1877. */
  1878. getProjectionMatrix(): Matrix;
  1879. /**
  1880. * Gets the current transform matrix
  1881. * @returns a Matrix made of View * Projection
  1882. */
  1883. getTransformMatrix(): Matrix;
  1884. /**
  1885. * Sets the current transform matrix
  1886. * @param view defines the View matrix to use
  1887. * @param projection defines the Projection matrix to use
  1888. */
  1889. setTransformMatrix(view: Matrix, projection: Matrix): void;
  1890. /** @hidden */
  1891. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  1892. /**
  1893. * Gets the uniform buffer used to store scene data
  1894. * @returns a UniformBuffer
  1895. */
  1896. getSceneUniformBuffer(): UniformBuffer;
  1897. /**
  1898. * Gets an unique (relatively to the current scene) Id
  1899. * @returns an unique number for the scene
  1900. */
  1901. getUniqueId(): number;
  1902. /**
  1903. * Add a mesh to the list of scene's meshes
  1904. * @param newMesh defines the mesh to add
  1905. * @param recursive if all child meshes should also be added to the scene
  1906. */
  1907. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  1908. /**
  1909. * Remove a mesh for the list of scene's meshes
  1910. * @param toRemove defines the mesh to remove
  1911. * @param recursive if all child meshes should also be removed from the scene
  1912. * @returns the index where the mesh was in the mesh list
  1913. */
  1914. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  1915. /**
  1916. * Add a transform node to the list of scene's transform nodes
  1917. * @param newTransformNode defines the transform node to add
  1918. */
  1919. addTransformNode(newTransformNode: TransformNode): void;
  1920. /**
  1921. * Remove a transform node for the list of scene's transform nodes
  1922. * @param toRemove defines the transform node to remove
  1923. * @returns the index where the transform node was in the transform node list
  1924. */
  1925. removeTransformNode(toRemove: TransformNode): number;
  1926. /**
  1927. * Remove a skeleton for the list of scene's skeletons
  1928. * @param toRemove defines the skeleton to remove
  1929. * @returns the index where the skeleton was in the skeleton list
  1930. */
  1931. removeSkeleton(toRemove: Skeleton): number;
  1932. /**
  1933. * Remove a morph target for the list of scene's morph targets
  1934. * @param toRemove defines the morph target to remove
  1935. * @returns the index where the morph target was in the morph target list
  1936. */
  1937. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  1938. /**
  1939. * Remove a light for the list of scene's lights
  1940. * @param toRemove defines the light to remove
  1941. * @returns the index where the light was in the light list
  1942. */
  1943. removeLight(toRemove: Light): number;
  1944. /**
  1945. * Remove a camera for the list of scene's cameras
  1946. * @param toRemove defines the camera to remove
  1947. * @returns the index where the camera was in the camera list
  1948. */
  1949. removeCamera(toRemove: Camera): number;
  1950. /**
  1951. * Remove a particle system for the list of scene's particle systems
  1952. * @param toRemove defines the particle system to remove
  1953. * @returns the index where the particle system was in the particle system list
  1954. */
  1955. removeParticleSystem(toRemove: IParticleSystem): number;
  1956. /**
  1957. * Remove a animation for the list of scene's animations
  1958. * @param toRemove defines the animation to remove
  1959. * @returns the index where the animation was in the animation list
  1960. */
  1961. removeAnimation(toRemove: Animation): number;
  1962. /**
  1963. * Removes the given animation group from this scene.
  1964. * @param toRemove The animation group to remove
  1965. * @returns The index of the removed animation group
  1966. */
  1967. removeAnimationGroup(toRemove: AnimationGroup): number;
  1968. /**
  1969. * Removes the given multi-material from this scene.
  1970. * @param toRemove The multi-material to remove
  1971. * @returns The index of the removed multi-material
  1972. */
  1973. removeMultiMaterial(toRemove: MultiMaterial): number;
  1974. /**
  1975. * Removes the given material from this scene.
  1976. * @param toRemove The material to remove
  1977. * @returns The index of the removed material
  1978. */
  1979. removeMaterial(toRemove: Material): number;
  1980. /**
  1981. * Removes the given action manager from this scene.
  1982. * @param toRemove The action manager to remove
  1983. * @returns The index of the removed action manager
  1984. */
  1985. removeActionManager(toRemove: ActionManager): number;
  1986. /**
  1987. * Removes the given texture from this scene.
  1988. * @param toRemove The texture to remove
  1989. * @returns The index of the removed texture
  1990. */
  1991. removeTexture(toRemove: BaseTexture): number;
  1992. /**
  1993. * Adds the given light to this scene
  1994. * @param newLight The light to add
  1995. */
  1996. addLight(newLight: Light): void;
  1997. /**
  1998. * Sorts the list list based on light priorities
  1999. */
  2000. sortLightsByPriority(): void;
  2001. /**
  2002. * Adds the given camera to this scene
  2003. * @param newCamera The camera to add
  2004. */
  2005. addCamera(newCamera: Camera): void;
  2006. /**
  2007. * Adds the given skeleton to this scene
  2008. * @param newSkeleton The skeleton to add
  2009. */
  2010. addSkeleton(newSkeleton: Skeleton): void;
  2011. /**
  2012. * Adds the given particle system to this scene
  2013. * @param newParticleSystem The particle system to add
  2014. */
  2015. addParticleSystem(newParticleSystem: IParticleSystem): void;
  2016. /**
  2017. * Adds the given animation to this scene
  2018. * @param newAnimation The animation to add
  2019. */
  2020. addAnimation(newAnimation: Animation): void;
  2021. /**
  2022. * Adds the given animation group to this scene.
  2023. * @param newAnimationGroup The animation group to add
  2024. */
  2025. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  2026. /**
  2027. * Adds the given multi-material to this scene
  2028. * @param newMultiMaterial The multi-material to add
  2029. */
  2030. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  2031. /**
  2032. * Adds the given material to this scene
  2033. * @param newMaterial The material to add
  2034. */
  2035. addMaterial(newMaterial: Material): void;
  2036. /**
  2037. * Adds the given morph target to this scene
  2038. * @param newMorphTargetManager The morph target to add
  2039. */
  2040. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  2041. /**
  2042. * Adds the given geometry to this scene
  2043. * @param newGeometry The geometry to add
  2044. */
  2045. addGeometry(newGeometry: Geometry): void;
  2046. /**
  2047. * Adds the given action manager to this scene
  2048. * @param newActionManager The action manager to add
  2049. */
  2050. addActionManager(newActionManager: ActionManager): void;
  2051. /**
  2052. * Adds the given texture to this scene.
  2053. * @param newTexture The texture to add
  2054. */
  2055. addTexture(newTexture: BaseTexture): void;
  2056. /**
  2057. * Switch active camera
  2058. * @param newCamera defines the new active camera
  2059. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  2060. */
  2061. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  2062. /**
  2063. * sets the active camera of the scene using its ID
  2064. * @param id defines the camera's ID
  2065. * @return the new active camera or null if none found.
  2066. */
  2067. setActiveCameraByID(id: string): Nullable<Camera>;
  2068. /**
  2069. * sets the active camera of the scene using its name
  2070. * @param name defines the camera's name
  2071. * @returns the new active camera or null if none found.
  2072. */
  2073. setActiveCameraByName(name: string): Nullable<Camera>;
  2074. /**
  2075. * get an animation group using its name
  2076. * @param name defines the material's name
  2077. * @return the animation group or null if none found.
  2078. */
  2079. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  2080. /**
  2081. * get a material using its id
  2082. * @param id defines the material's ID
  2083. * @return the material or null if none found.
  2084. */
  2085. getMaterialByID(id: string): Nullable<Material>;
  2086. /**
  2087. * Gets a material using its name
  2088. * @param name defines the material's name
  2089. * @return the material or null if none found.
  2090. */
  2091. getMaterialByName(name: string): Nullable<Material>;
  2092. /**
  2093. * Gets a camera using its id
  2094. * @param id defines the id to look for
  2095. * @returns the camera or null if not found
  2096. */
  2097. getCameraByID(id: string): Nullable<Camera>;
  2098. /**
  2099. * Gets a camera using its unique id
  2100. * @param uniqueId defines the unique id to look for
  2101. * @returns the camera or null if not found
  2102. */
  2103. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  2104. /**
  2105. * Gets a camera using its name
  2106. * @param name defines the camera's name
  2107. * @return the camera or null if none found.
  2108. */
  2109. getCameraByName(name: string): Nullable<Camera>;
  2110. /**
  2111. * Gets a bone using its id
  2112. * @param id defines the bone's id
  2113. * @return the bone or null if not found
  2114. */
  2115. getBoneByID(id: string): Nullable<Bone>;
  2116. /**
  2117. * Gets a bone using its id
  2118. * @param name defines the bone's name
  2119. * @return the bone or null if not found
  2120. */
  2121. getBoneByName(name: string): Nullable<Bone>;
  2122. /**
  2123. * Gets a light node using its name
  2124. * @param name defines the the light's name
  2125. * @return the light or null if none found.
  2126. */
  2127. getLightByName(name: string): Nullable<Light>;
  2128. /**
  2129. * Gets a light node using its id
  2130. * @param id defines the light's id
  2131. * @return the light or null if none found.
  2132. */
  2133. getLightByID(id: string): Nullable<Light>;
  2134. /**
  2135. * Gets a light node using its scene-generated unique ID
  2136. * @param uniqueId defines the light's unique id
  2137. * @return the light or null if none found.
  2138. */
  2139. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  2140. /**
  2141. * Gets a particle system by id
  2142. * @param id defines the particle system id
  2143. * @return the corresponding system or null if none found
  2144. */
  2145. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  2146. /**
  2147. * Gets a geometry using its ID
  2148. * @param id defines the geometry's id
  2149. * @return the geometry or null if none found.
  2150. */
  2151. getGeometryByID(id: string): Nullable<Geometry>;
  2152. private _getGeometryByUniqueID;
  2153. /**
  2154. * Add a new geometry to this scene
  2155. * @param geometry defines the geometry to be added to the scene.
  2156. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  2157. * @return a boolean defining if the geometry was added or not
  2158. */
  2159. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  2160. /**
  2161. * Removes an existing geometry
  2162. * @param geometry defines the geometry to be removed from the scene
  2163. * @return a boolean defining if the geometry was removed or not
  2164. */
  2165. removeGeometry(geometry: Geometry): boolean;
  2166. /**
  2167. * Gets the list of geometries attached to the scene
  2168. * @returns an array of Geometry
  2169. */
  2170. getGeometries(): Geometry[];
  2171. /**
  2172. * Gets the first added mesh found of a given ID
  2173. * @param id defines the id to search for
  2174. * @return the mesh found or null if not found at all
  2175. */
  2176. getMeshByID(id: string): Nullable<AbstractMesh>;
  2177. /**
  2178. * Gets a list of meshes using their id
  2179. * @param id defines the id to search for
  2180. * @returns a list of meshes
  2181. */
  2182. getMeshesByID(id: string): Array<AbstractMesh>;
  2183. /**
  2184. * Gets the first added transform node found of a given ID
  2185. * @param id defines the id to search for
  2186. * @return the found transform node or null if not found at all.
  2187. */
  2188. getTransformNodeByID(id: string): Nullable<TransformNode>;
  2189. /**
  2190. * Gets a list of transform nodes using their id
  2191. * @param id defines the id to search for
  2192. * @returns a list of transform nodes
  2193. */
  2194. getTransformNodesByID(id: string): Array<TransformNode>;
  2195. /**
  2196. * Gets a mesh with its auto-generated unique id
  2197. * @param uniqueId defines the unique id to search for
  2198. * @return the found mesh or null if not found at all.
  2199. */
  2200. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  2201. /**
  2202. * Gets a the last added mesh using a given id
  2203. * @param id defines the id to search for
  2204. * @return the found mesh or null if not found at all.
  2205. */
  2206. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  2207. /**
  2208. * Gets a the last added node (Mesh, Camera, Light) using a given id
  2209. * @param id defines the id to search for
  2210. * @return the found node or null if not found at all
  2211. */
  2212. getLastEntryByID(id: string): Nullable<Node>;
  2213. /**
  2214. * Gets a node (Mesh, Camera, Light) using a given id
  2215. * @param id defines the id to search for
  2216. * @return the found node or null if not found at all
  2217. */
  2218. getNodeByID(id: string): Nullable<Node>;
  2219. /**
  2220. * Gets a node (Mesh, Camera, Light) using a given name
  2221. * @param name defines the name to search for
  2222. * @return the found node or null if not found at all.
  2223. */
  2224. getNodeByName(name: string): Nullable<Node>;
  2225. /**
  2226. * Gets a mesh using a given name
  2227. * @param name defines the name to search for
  2228. * @return the found mesh or null if not found at all.
  2229. */
  2230. getMeshByName(name: string): Nullable<AbstractMesh>;
  2231. /**
  2232. * Gets a transform node using a given name
  2233. * @param name defines the name to search for
  2234. * @return the found transform node or null if not found at all.
  2235. */
  2236. getTransformNodeByName(name: string): Nullable<TransformNode>;
  2237. /**
  2238. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  2239. * @param id defines the id to search for
  2240. * @return the found skeleton or null if not found at all.
  2241. */
  2242. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  2243. /**
  2244. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  2245. * @param id defines the id to search for
  2246. * @return the found skeleton or null if not found at all.
  2247. */
  2248. getSkeletonById(id: string): Nullable<Skeleton>;
  2249. /**
  2250. * Gets a skeleton using a given name
  2251. * @param name defines the name to search for
  2252. * @return the found skeleton or null if not found at all.
  2253. */
  2254. getSkeletonByName(name: string): Nullable<Skeleton>;
  2255. /**
  2256. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  2257. * @param id defines the id to search for
  2258. * @return the found morph target manager or null if not found at all.
  2259. */
  2260. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  2261. /**
  2262. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  2263. * @param id defines the id to search for
  2264. * @return the found morph target or null if not found at all.
  2265. */
  2266. getMorphTargetById(id: string): Nullable<MorphTarget>;
  2267. /**
  2268. * Gets a boolean indicating if the given mesh is active
  2269. * @param mesh defines the mesh to look for
  2270. * @returns true if the mesh is in the active list
  2271. */
  2272. isActiveMesh(mesh: AbstractMesh): boolean;
  2273. /**
  2274. * Return a unique id as a string which can serve as an identifier for the scene
  2275. */
  2276. readonly uid: string;
  2277. /**
  2278. * Add an externaly attached data from its key.
  2279. * This method call will fail and return false, if such key already exists.
  2280. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  2281. * @param key the unique key that identifies the data
  2282. * @param data the data object to associate to the key for this Engine instance
  2283. * @return true if no such key were already present and the data was added successfully, false otherwise
  2284. */
  2285. addExternalData<T>(key: string, data: T): boolean;
  2286. /**
  2287. * Get an externaly attached data from its key
  2288. * @param key the unique key that identifies the data
  2289. * @return the associated data, if present (can be null), or undefined if not present
  2290. */
  2291. getExternalData<T>(key: string): Nullable<T>;
  2292. /**
  2293. * Get an externaly attached data from its key, create it using a factory if it's not already present
  2294. * @param key the unique key that identifies the data
  2295. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  2296. * @return the associated data, can be null if the factory returned null.
  2297. */
  2298. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  2299. /**
  2300. * Remove an externaly attached data from the Engine instance
  2301. * @param key the unique key that identifies the data
  2302. * @return true if the data was successfully removed, false if it doesn't exist
  2303. */
  2304. removeExternalData(key: string): boolean;
  2305. private _evaluateSubMesh;
  2306. /**
  2307. * Clear the processed materials smart array preventing retention point in material dispose.
  2308. */
  2309. freeProcessedMaterials(): void;
  2310. private _preventFreeActiveMeshesAndRenderingGroups;
  2311. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  2312. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  2313. * when disposing several meshes in a row or a hierarchy of meshes.
  2314. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  2315. */
  2316. blockfreeActiveMeshesAndRenderingGroups: boolean;
  2317. /**
  2318. * Clear the active meshes smart array preventing retention point in mesh dispose.
  2319. */
  2320. freeActiveMeshes(): void;
  2321. /**
  2322. * Clear the info related to rendering groups preventing retention points during dispose.
  2323. */
  2324. freeRenderingGroups(): void;
  2325. /** @hidden */
  2326. _isInIntermediateRendering(): boolean;
  2327. /**
  2328. * Lambda returning the list of potentially active meshes.
  2329. */
  2330. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  2331. /**
  2332. * Lambda returning the list of potentially active sub meshes.
  2333. */
  2334. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  2335. /**
  2336. * Lambda returning the list of potentially intersecting sub meshes.
  2337. */
  2338. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  2339. /**
  2340. * Lambda returning the list of potentially colliding sub meshes.
  2341. */
  2342. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  2343. private _activeMeshesFrozen;
  2344. /**
  2345. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  2346. * @returns the current scene
  2347. */
  2348. freezeActiveMeshes(): Scene;
  2349. /**
  2350. * Use this function to restart evaluating active meshes on every frame
  2351. * @returns the current scene
  2352. */
  2353. unfreezeActiveMeshes(): Scene;
  2354. private _evaluateActiveMeshes;
  2355. private _activeMesh;
  2356. /**
  2357. * Update the transform matrix to update from the current active camera
  2358. * @param force defines a boolean used to force the update even if cache is up to date
  2359. */
  2360. updateTransformMatrix(force?: boolean): void;
  2361. /**
  2362. * Defines an alternate camera (used mostly in VR-like scenario where two cameras can render the same scene from a slightly different point of view)
  2363. * @param alternateCamera defines the camera to use
  2364. */
  2365. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  2366. /** @hidden */
  2367. _allowPostProcessClearColor: boolean;
  2368. private _renderForCamera;
  2369. private _processSubCameras;
  2370. private _checkIntersections;
  2371. /** @hidden */
  2372. _advancePhysicsEngineStep(step: number): void;
  2373. /**
  2374. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  2375. */
  2376. getDeterministicFrameTime: () => number;
  2377. /**
  2378. * Render the scene
  2379. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  2380. */
  2381. render(updateCameras?: boolean): void;
  2382. /**
  2383. * Freeze all materials
  2384. * A frozen material will not be updatable but should be faster to render
  2385. */
  2386. freezeMaterials(): void;
  2387. /**
  2388. * Unfreeze all materials
  2389. * A frozen material will not be updatable but should be faster to render
  2390. */
  2391. unfreezeMaterials(): void;
  2392. /**
  2393. * Releases all held ressources
  2394. */
  2395. dispose(): void;
  2396. /**
  2397. * Gets if the scene is already disposed
  2398. */
  2399. readonly isDisposed: boolean;
  2400. /**
  2401. * Call this function to reduce memory footprint of the scene.
  2402. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  2403. */
  2404. clearCachedVertexData(): void;
  2405. /**
  2406. * This function will remove the local cached buffer data from texture.
  2407. * It will save memory but will prevent the texture from being rebuilt
  2408. */
  2409. cleanCachedTextureBuffer(): void;
  2410. /**
  2411. * Get the world extend vectors with an optional filter
  2412. *
  2413. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  2414. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  2415. */
  2416. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  2417. min: Vector3;
  2418. max: Vector3;
  2419. };
  2420. /**
  2421. * Creates a ray that can be used to pick in the scene
  2422. * @param x defines the x coordinate of the origin (on-screen)
  2423. * @param y defines the y coordinate of the origin (on-screen)
  2424. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2425. * @param camera defines the camera to use for the picking
  2426. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2427. * @returns a Ray
  2428. */
  2429. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  2430. /**
  2431. * Creates a ray that can be used to pick in the scene
  2432. * @param x defines the x coordinate of the origin (on-screen)
  2433. * @param y defines the y coordinate of the origin (on-screen)
  2434. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2435. * @param result defines the ray where to store the picking ray
  2436. * @param camera defines the camera to use for the picking
  2437. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2438. * @returns the current scene
  2439. */
  2440. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  2441. /**
  2442. * Creates a ray that can be used to pick in the scene
  2443. * @param x defines the x coordinate of the origin (on-screen)
  2444. * @param y defines the y coordinate of the origin (on-screen)
  2445. * @param camera defines the camera to use for the picking
  2446. * @returns a Ray
  2447. */
  2448. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  2449. /**
  2450. * Creates a ray that can be used to pick in the scene
  2451. * @param x defines the x coordinate of the origin (on-screen)
  2452. * @param y defines the y coordinate of the origin (on-screen)
  2453. * @param result defines the ray where to store the picking ray
  2454. * @param camera defines the camera to use for the picking
  2455. * @returns the current scene
  2456. */
  2457. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  2458. private _internalPick;
  2459. private _internalMultiPick;
  2460. private _tempPickingRay;
  2461. /** Launch a ray to try to pick a mesh in the scene
  2462. * @param x position on screen
  2463. * @param y position on screen
  2464. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true
  2465. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  2466. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2467. * @returns a PickingInfo
  2468. */
  2469. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  2470. private _cachedRayForTransform;
  2471. /** Use the given ray to pick a mesh in the scene
  2472. * @param ray The ray to use to pick meshes
  2473. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must have isPickable set to true
  2474. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  2475. * @returns a PickingInfo
  2476. */
  2477. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  2478. /**
  2479. * Launch a ray to try to pick a mesh in the scene
  2480. * @param x X position on screen
  2481. * @param y Y position on screen
  2482. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true
  2483. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2484. * @returns an array of PickingInfo
  2485. */
  2486. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  2487. /**
  2488. * Launch a ray to try to pick a mesh in the scene
  2489. * @param ray Ray to use
  2490. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true
  2491. * @returns an array of PickingInfo
  2492. */
  2493. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  2494. /**
  2495. * Force the value of meshUnderPointer
  2496. * @param mesh defines the mesh to use
  2497. */
  2498. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  2499. /**
  2500. * Gets the mesh under the pointer
  2501. * @returns a Mesh or null if no mesh is under the pointer
  2502. */
  2503. getPointerOverMesh(): Nullable<AbstractMesh>;
  2504. /** @hidden */
  2505. _rebuildGeometries(): void;
  2506. /** @hidden */
  2507. _rebuildTextures(): void;
  2508. private _getByTags;
  2509. /**
  2510. * Get a list of meshes by tags
  2511. * @param tagsQuery defines the tags query to use
  2512. * @param forEach defines a predicate used to filter results
  2513. * @returns an array of Mesh
  2514. */
  2515. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  2516. /**
  2517. * Get a list of cameras by tags
  2518. * @param tagsQuery defines the tags query to use
  2519. * @param forEach defines a predicate used to filter results
  2520. * @returns an array of Camera
  2521. */
  2522. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  2523. /**
  2524. * Get a list of lights by tags
  2525. * @param tagsQuery defines the tags query to use
  2526. * @param forEach defines a predicate used to filter results
  2527. * @returns an array of Light
  2528. */
  2529. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  2530. /**
  2531. * Get a list of materials by tags
  2532. * @param tagsQuery defines the tags query to use
  2533. * @param forEach defines a predicate used to filter results
  2534. * @returns an array of Material
  2535. */
  2536. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  2537. /**
  2538. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  2539. * This allowed control for front to back rendering or reversly depending of the special needs.
  2540. *
  2541. * @param renderingGroupId The rendering group id corresponding to its index
  2542. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  2543. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  2544. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  2545. */
  2546. setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>): void;
  2547. /**
  2548. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  2549. *
  2550. * @param renderingGroupId The rendering group id corresponding to its index
  2551. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  2552. * @param depth Automatically clears depth between groups if true and autoClear is true.
  2553. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  2554. */
  2555. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  2556. /**
  2557. * Gets the current auto clear configuration for one rendering group of the rendering
  2558. * manager.
  2559. * @param index the rendering group index to get the information for
  2560. * @returns The auto clear setup for the requested rendering group
  2561. */
  2562. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  2563. private _blockMaterialDirtyMechanism;
  2564. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  2565. blockMaterialDirtyMechanism: boolean;
  2566. /**
  2567. * Will flag all materials as dirty to trigger new shader compilation
  2568. * @param flag defines the flag used to specify which material part must be marked as dirty
  2569. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  2570. */
  2571. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  2572. /** @hidden */
  2573. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  2574. /** @hidden */
  2575. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  2576. }
  2577. }
  2578. declare module BABYLON {
  2579. /**
  2580. * Groups all the scene component constants in one place to ease maintenance.
  2581. * @hidden
  2582. */
  2583. class SceneComponentConstants {
  2584. static readonly NAME_EFFECTLAYER: string;
  2585. static readonly NAME_LAYER: string;
  2586. static readonly NAME_LENSFLARESYSTEM: string;
  2587. static readonly NAME_BOUNDINGBOXRENDERER: string;
  2588. static readonly NAME_PARTICLESYSTEM: string;
  2589. static readonly NAME_GAMEPAD: string;
  2590. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  2591. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  2592. static readonly NAME_DEPTHRENDERER: string;
  2593. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  2594. static readonly NAME_SPRITE: string;
  2595. static readonly NAME_OUTLINERENDERER: string;
  2596. static readonly NAME_PROCEDURALTEXTURE: string;
  2597. static readonly NAME_SHADOWGENERATOR: string;
  2598. static readonly NAME_OCTREE: string;
  2599. static readonly NAME_PHYSICSENGINE: string;
  2600. static readonly NAME_AUDIO: string;
  2601. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  2602. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  2603. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  2604. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  2605. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  2606. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  2607. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  2608. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  2609. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  2610. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  2611. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  2612. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  2613. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  2614. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  2615. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  2616. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  2617. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  2618. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  2619. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  2620. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  2621. static readonly STEP_AFTERRENDER_AUDIO: number;
  2622. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  2623. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  2624. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  2625. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  2626. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  2627. static readonly STEP_POINTERMOVE_SPRITE: number;
  2628. static readonly STEP_POINTERDOWN_SPRITE: number;
  2629. static readonly STEP_POINTERUP_SPRITE: number;
  2630. }
  2631. /**
  2632. * This represents a scene component.
  2633. *
  2634. * This is used to decouple the dependency the scene is having on the different workloads like
  2635. * layers, post processes...
  2636. */
  2637. interface ISceneComponent {
  2638. /**
  2639. * The name of the component. Each component must have a unique name.
  2640. */
  2641. name: string;
  2642. /**
  2643. * The scene the component belongs to.
  2644. */
  2645. scene: Scene;
  2646. /**
  2647. * Register the component to one instance of a scene.
  2648. */
  2649. register(): void;
  2650. /**
  2651. * Rebuilds the elements related to this component in case of
  2652. * context lost for instance.
  2653. */
  2654. rebuild(): void;
  2655. /**
  2656. * Disposes the component and the associated ressources.
  2657. */
  2658. dispose(): void;
  2659. }
  2660. /**
  2661. * This represents a SERIALIZABLE scene component.
  2662. *
  2663. * This extends Scene Component to add Serialization methods on top.
  2664. */
  2665. interface ISceneSerializableComponent extends ISceneComponent {
  2666. /**
  2667. * Adds all the element from the container to the scene
  2668. * @param container the container holding the elements
  2669. */
  2670. addFromContainer(container: AbstractScene): void;
  2671. /**
  2672. * Removes all the elements in the container from the scene
  2673. * @param container contains the elements to remove
  2674. */
  2675. removeFromContainer(container: AbstractScene): void;
  2676. /**
  2677. * Serializes the component data to the specified json object
  2678. * @param serializationObject The object to serialize to
  2679. */
  2680. serialize(serializationObject: any): void;
  2681. }
  2682. /**
  2683. * Strong typing of a Mesh related stage step action
  2684. */
  2685. type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  2686. /**
  2687. * Strong typing of a Evaluate Sub Mesh related stage step action
  2688. */
  2689. type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  2690. /**
  2691. * Strong typing of a Active Mesh related stage step action
  2692. */
  2693. type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  2694. /**
  2695. * Strong typing of a Camera related stage step action
  2696. */
  2697. type CameraStageAction = (camera: Camera) => void;
  2698. /**
  2699. * Strong typing of a Render Target related stage step action
  2700. */
  2701. type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  2702. /**
  2703. * Strong typing of a RenderingGroup related stage step action
  2704. */
  2705. type RenderingGroupStageAction = (renderingGroupId: number) => void;
  2706. /**
  2707. * Strong typing of a Mesh Render related stage step action
  2708. */
  2709. type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  2710. /**
  2711. * Strong typing of a simple stage step action
  2712. */
  2713. type SimpleStageAction = () => void;
  2714. /**
  2715. * Strong typing of a render target action.
  2716. */
  2717. type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  2718. /**
  2719. * Strong typing of a pointer move action.
  2720. */
  2721. type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  2722. /**
  2723. * Strong typing of a pointer up/down action.
  2724. */
  2725. type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  2726. /**
  2727. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  2728. * @hidden
  2729. */
  2730. class Stage<T extends Function> extends Array<{
  2731. index: number;
  2732. component: ISceneComponent;
  2733. action: T;
  2734. }> {
  2735. /**
  2736. * Hide ctor from the rest of the world.
  2737. * @param items The items to add.
  2738. */
  2739. private constructor();
  2740. /**
  2741. * Creates a new Stage.
  2742. * @returns A new instance of a Stage
  2743. */
  2744. static Create<T extends Function>(): Stage<T>;
  2745. /**
  2746. * Registers a step in an ordered way in the targeted stage.
  2747. * @param index Defines the position to register the step in
  2748. * @param component Defines the component attached to the step
  2749. * @param action Defines the action to launch during the step
  2750. */
  2751. registerStep(index: number, component: ISceneComponent, action: T): void;
  2752. /**
  2753. * Clears all the steps from the stage.
  2754. */
  2755. clear(): void;
  2756. }
  2757. }
  2758. declare module BABYLON {
  2759. /** Alias type for value that can be null */
  2760. type Nullable<T> = T | null;
  2761. /**
  2762. * Alias type for number that are floats
  2763. * @ignorenaming
  2764. */
  2765. type float = number;
  2766. /**
  2767. * Alias type for number that are doubles.
  2768. * @ignorenaming
  2769. */
  2770. type double = number;
  2771. /**
  2772. * Alias type for number that are integer
  2773. * @ignorenaming
  2774. */
  2775. type int = number;
  2776. /** Alias type for number array or Float32Array */
  2777. type FloatArray = number[] | Float32Array;
  2778. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  2779. type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  2780. /**
  2781. * Alias for types that can be used by a Buffer or VertexBuffer.
  2782. */
  2783. type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  2784. /**
  2785. * Alias type for primitive types
  2786. * @ignorenaming
  2787. */
  2788. type Primitive = undefined | null | boolean | string | number | Function;
  2789. /**
  2790. * Type modifier to make all the properties of an object Readonly
  2791. */
  2792. type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  2793. /**
  2794. * Type modifier to make all the properties of an object Readonly recursively
  2795. */
  2796. type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  2797. /** @hidden */
  2798. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  2799. }
  2800. /** @hidden */
  2801. /** @hidden */
  2802. type DeepImmutableObject<T> = {
  2803. readonly [K in keyof T]: DeepImmutable<T[K]>;
  2804. };
  2805. }
  2806. declare module BABYLON {
  2807. /**
  2808. * The action to be carried out following a trigger
  2809. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  2810. */
  2811. class Action {
  2812. /** the trigger, with or without parameters, for the action */
  2813. triggerOptions: any;
  2814. /**
  2815. * Trigger for the action
  2816. */
  2817. trigger: number;
  2818. /**
  2819. * Internal only - manager for action
  2820. * @hidden
  2821. */
  2822. _actionManager: ActionManager;
  2823. private _nextActiveAction;
  2824. private _child;
  2825. private _condition?;
  2826. private _triggerParameter;
  2827. /**
  2828. * An event triggered prior to action being executed.
  2829. */
  2830. onBeforeExecuteObservable: Observable<Action>;
  2831. /**
  2832. * Creates a new Action
  2833. * @param triggerOptions the trigger, with or without parameters, for the action
  2834. * @param condition an optional determinant of action
  2835. */
  2836. constructor(
  2837. /** the trigger, with or without parameters, for the action */
  2838. triggerOptions: any, condition?: Condition);
  2839. /**
  2840. * Internal only
  2841. * @hidden
  2842. */
  2843. _prepare(): void;
  2844. /**
  2845. * Gets the trigger parameters
  2846. * @returns the trigger parameters
  2847. */
  2848. getTriggerParameter(): any;
  2849. /**
  2850. * Internal only - executes current action event
  2851. * @hidden
  2852. */
  2853. _executeCurrent(evt?: ActionEvent): void;
  2854. /**
  2855. * Execute placeholder for child classes
  2856. * @param evt optional action event
  2857. */
  2858. execute(evt?: ActionEvent): void;
  2859. /**
  2860. * Skips to next active action
  2861. */
  2862. skipToNextActiveAction(): void;
  2863. /**
  2864. * Adds action to chain of actions, may be a DoNothingAction
  2865. * @param action defines the next action to execute
  2866. * @returns The action passed in
  2867. * @see https://www.babylonjs-playground.com/#1T30HR#0
  2868. */
  2869. then(action: Action): Action;
  2870. /**
  2871. * Internal only
  2872. * @hidden
  2873. */
  2874. _getProperty(propertyPath: string): string;
  2875. /**
  2876. * Internal only
  2877. * @hidden
  2878. */
  2879. _getEffectiveTarget(target: any, propertyPath: string): any;
  2880. /**
  2881. * Serialize placeholder for child classes
  2882. * @param parent of child
  2883. * @returns the serialized object
  2884. */
  2885. serialize(parent: any): any;
  2886. /**
  2887. * Internal only called by serialize
  2888. * @hidden
  2889. */
  2890. protected _serialize(serializedAction: any, parent?: any): any;
  2891. /**
  2892. * Internal only
  2893. * @hidden
  2894. */
  2895. static _SerializeValueAsString: (value: any) => string;
  2896. /**
  2897. * Internal only
  2898. * @hidden
  2899. */
  2900. static _GetTargetProperty: (target: Scene | Node) => {
  2901. name: string;
  2902. targetType: string;
  2903. value: string;
  2904. };
  2905. }
  2906. }
  2907. declare module BABYLON {
  2908. /**
  2909. * ActionEvent is the event being sent when an action is triggered.
  2910. */
  2911. class ActionEvent {
  2912. /** The mesh or sprite that triggered the action */
  2913. source: any;
  2914. /** The X mouse cursor position at the time of the event */
  2915. pointerX: number;
  2916. /** The Y mouse cursor position at the time of the event */
  2917. pointerY: number;
  2918. /** The mesh that is currently pointed at (can be null) */
  2919. meshUnderPointer: Nullable<AbstractMesh>;
  2920. /** the original (browser) event that triggered the ActionEvent */
  2921. sourceEvent?: any;
  2922. /** additional data for the event */
  2923. additionalData?: any;
  2924. /**
  2925. * Creates a new ActionEvent
  2926. * @param source The mesh or sprite that triggered the action
  2927. * @param pointerX The X mouse cursor position at the time of the event
  2928. * @param pointerY The Y mouse cursor position at the time of the event
  2929. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  2930. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  2931. * @param additionalData additional data for the event
  2932. */
  2933. constructor(
  2934. /** The mesh or sprite that triggered the action */
  2935. source: any,
  2936. /** The X mouse cursor position at the time of the event */
  2937. pointerX: number,
  2938. /** The Y mouse cursor position at the time of the event */
  2939. pointerY: number,
  2940. /** The mesh that is currently pointed at (can be null) */
  2941. meshUnderPointer: Nullable<AbstractMesh>,
  2942. /** the original (browser) event that triggered the ActionEvent */
  2943. sourceEvent?: any,
  2944. /** additional data for the event */
  2945. additionalData?: any);
  2946. /**
  2947. * Helper function to auto-create an ActionEvent from a source mesh.
  2948. * @param source The source mesh that triggered the event
  2949. * @param evt The original (browser) event
  2950. * @param additionalData additional data for the event
  2951. * @returns the new ActionEvent
  2952. */
  2953. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  2954. /**
  2955. * Helper function to auto-create an ActionEvent from a source sprite
  2956. * @param source The source sprite that triggered the event
  2957. * @param scene Scene associated with the sprite
  2958. * @param evt The original (browser) event
  2959. * @param additionalData additional data for the event
  2960. * @returns the new ActionEvent
  2961. */
  2962. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  2963. /**
  2964. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  2965. * @param scene the scene where the event occurred
  2966. * @param evt The original (browser) event
  2967. * @returns the new ActionEvent
  2968. */
  2969. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  2970. /**
  2971. * Helper function to auto-create an ActionEvent from a primitive
  2972. * @param prim defines the target primitive
  2973. * @param pointerPos defines the pointer position
  2974. * @param evt The original (browser) event
  2975. * @param additionalData additional data for the event
  2976. * @returns the new ActionEvent
  2977. */
  2978. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  2979. }
  2980. /**
  2981. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  2982. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  2983. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  2984. */
  2985. class ActionManager {
  2986. /**
  2987. * Nothing
  2988. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2989. */
  2990. static readonly NothingTrigger: number;
  2991. /**
  2992. * On pick
  2993. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2994. */
  2995. static readonly OnPickTrigger: number;
  2996. /**
  2997. * On left pick
  2998. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2999. */
  3000. static readonly OnLeftPickTrigger: number;
  3001. /**
  3002. * On right pick
  3003. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3004. */
  3005. static readonly OnRightPickTrigger: number;
  3006. /**
  3007. * On center pick
  3008. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3009. */
  3010. static readonly OnCenterPickTrigger: number;
  3011. /**
  3012. * On pick down
  3013. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3014. */
  3015. static readonly OnPickDownTrigger: number;
  3016. /**
  3017. * On double pick
  3018. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3019. */
  3020. static readonly OnDoublePickTrigger: number;
  3021. /**
  3022. * On pick up
  3023. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3024. */
  3025. static readonly OnPickUpTrigger: number;
  3026. /**
  3027. * On pick out.
  3028. * This trigger will only be raised if you also declared a OnPickDown
  3029. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3030. */
  3031. static readonly OnPickOutTrigger: number;
  3032. /**
  3033. * On long press
  3034. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3035. */
  3036. static readonly OnLongPressTrigger: number;
  3037. /**
  3038. * On pointer over
  3039. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3040. */
  3041. static readonly OnPointerOverTrigger: number;
  3042. /**
  3043. * On pointer out
  3044. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3045. */
  3046. static readonly OnPointerOutTrigger: number;
  3047. /**
  3048. * On every frame
  3049. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3050. */
  3051. static readonly OnEveryFrameTrigger: number;
  3052. /**
  3053. * On intersection enter
  3054. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3055. */
  3056. static readonly OnIntersectionEnterTrigger: number;
  3057. /**
  3058. * On intersection exit
  3059. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3060. */
  3061. static readonly OnIntersectionExitTrigger: number;
  3062. /**
  3063. * On key down
  3064. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3065. */
  3066. static readonly OnKeyDownTrigger: number;
  3067. /**
  3068. * On key up
  3069. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3070. */
  3071. static readonly OnKeyUpTrigger: number;
  3072. /** Gets the list of active triggers */
  3073. static Triggers: {
  3074. [key: string]: number;
  3075. };
  3076. /** Gets the list of actions */
  3077. actions: Action[];
  3078. /** Gets the cursor to use when hovering items */
  3079. hoverCursor: string;
  3080. private _scene;
  3081. /**
  3082. * Creates a new action manager
  3083. * @param scene defines the hosting scene
  3084. */
  3085. constructor(scene: Scene);
  3086. /**
  3087. * Releases all associated resources
  3088. */
  3089. dispose(): void;
  3090. /**
  3091. * Gets hosting scene
  3092. * @returns the hosting scene
  3093. */
  3094. getScene(): Scene;
  3095. /**
  3096. * Does this action manager handles actions of any of the given triggers
  3097. * @param triggers defines the triggers to be tested
  3098. * @return a boolean indicating whether one (or more) of the triggers is handled
  3099. */
  3100. hasSpecificTriggers(triggers: number[]): boolean;
  3101. /**
  3102. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  3103. * speed.
  3104. * @param triggerA defines the trigger to be tested
  3105. * @param triggerB defines the trigger to be tested
  3106. * @return a boolean indicating whether one (or more) of the triggers is handled
  3107. */
  3108. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  3109. /**
  3110. * Does this action manager handles actions of a given trigger
  3111. * @param trigger defines the trigger to be tested
  3112. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  3113. * @return whether the trigger is handled
  3114. */
  3115. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  3116. /**
  3117. * Does this action manager has pointer triggers
  3118. */
  3119. readonly hasPointerTriggers: boolean;
  3120. /**
  3121. * Does this action manager has pick triggers
  3122. */
  3123. readonly hasPickTriggers: boolean;
  3124. /**
  3125. * Does exist one action manager with at least one trigger
  3126. **/
  3127. static readonly HasTriggers: boolean;
  3128. /**
  3129. * Does exist one action manager with at least one pick trigger
  3130. **/
  3131. static readonly HasPickTriggers: boolean;
  3132. /**
  3133. * Does exist one action manager that handles actions of a given trigger
  3134. * @param trigger defines the trigger to be tested
  3135. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  3136. **/
  3137. static HasSpecificTrigger(trigger: number): boolean;
  3138. /**
  3139. * Registers an action to this action manager
  3140. * @param action defines the action to be registered
  3141. * @return the action amended (prepared) after registration
  3142. */
  3143. registerAction(action: Action): Nullable<Action>;
  3144. /**
  3145. * Unregisters an action to this action manager
  3146. * @param action defines the action to be unregistered
  3147. * @return a boolean indicating whether the action has been unregistered
  3148. */
  3149. unregisterAction(action: Action): Boolean;
  3150. /**
  3151. * Process a specific trigger
  3152. * @param trigger defines the trigger to process
  3153. * @param evt defines the event details to be processed
  3154. */
  3155. processTrigger(trigger: number, evt?: ActionEvent): void;
  3156. /** @hidden */
  3157. _getEffectiveTarget(target: any, propertyPath: string): any;
  3158. /** @hidden */
  3159. _getProperty(propertyPath: string): string;
  3160. /**
  3161. * Serialize this manager to a JSON object
  3162. * @param name defines the property name to store this manager
  3163. * @returns a JSON representation of this manager
  3164. */
  3165. serialize(name: string): any;
  3166. /**
  3167. * Creates a new ActionManager from a JSON data
  3168. * @param parsedActions defines the JSON data to read from
  3169. * @param object defines the hosting mesh
  3170. * @param scene defines the hosting scene
  3171. */
  3172. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  3173. /**
  3174. * Get a trigger name by index
  3175. * @param trigger defines the trigger index
  3176. * @returns a trigger name
  3177. */
  3178. static GetTriggerName(trigger: number): string;
  3179. }
  3180. }
  3181. declare module BABYLON {
  3182. /**
  3183. * A Condition applied to an Action
  3184. */
  3185. class Condition {
  3186. /**
  3187. * Internal only - manager for action
  3188. * @hidden
  3189. */
  3190. _actionManager: ActionManager;
  3191. /**
  3192. * Internal only
  3193. * @hidden
  3194. */
  3195. _evaluationId: number;
  3196. /**
  3197. * Internal only
  3198. * @hidden
  3199. */
  3200. _currentResult: boolean;
  3201. /**
  3202. * Creates a new Condition
  3203. * @param actionManager the manager of the action the condition is applied to
  3204. */
  3205. constructor(actionManager: ActionManager);
  3206. /**
  3207. * Check if the current condition is valid
  3208. * @returns a boolean
  3209. */
  3210. isValid(): boolean;
  3211. /**
  3212. * Internal only
  3213. * @hidden
  3214. */
  3215. _getProperty(propertyPath: string): string;
  3216. /**
  3217. * Internal only
  3218. * @hidden
  3219. */
  3220. _getEffectiveTarget(target: any, propertyPath: string): any;
  3221. /**
  3222. * Serialize placeholder for child classes
  3223. * @returns the serialized object
  3224. */
  3225. serialize(): any;
  3226. /**
  3227. * Internal only
  3228. * @hidden
  3229. */
  3230. protected _serialize(serializedCondition: any): any;
  3231. }
  3232. /**
  3233. * Defines specific conditional operators as extensions of Condition
  3234. */
  3235. class ValueCondition extends Condition {
  3236. /** path to specify the property of the target the conditional operator uses */
  3237. propertyPath: string;
  3238. /** the value compared by the conditional operator against the current value of the property */
  3239. value: any;
  3240. /** the conditional operator, default ValueCondition.IsEqual */
  3241. operator: number;
  3242. /**
  3243. * Internal only
  3244. * @hidden
  3245. */
  3246. private static _IsEqual;
  3247. /**
  3248. * Internal only
  3249. * @hidden
  3250. */
  3251. private static _IsDifferent;
  3252. /**
  3253. * Internal only
  3254. * @hidden
  3255. */
  3256. private static _IsGreater;
  3257. /**
  3258. * Internal only
  3259. * @hidden
  3260. */
  3261. private static _IsLesser;
  3262. /**
  3263. * returns the number for IsEqual
  3264. */
  3265. static readonly IsEqual: number;
  3266. /**
  3267. * Returns the number for IsDifferent
  3268. */
  3269. static readonly IsDifferent: number;
  3270. /**
  3271. * Returns the number for IsGreater
  3272. */
  3273. static readonly IsGreater: number;
  3274. /**
  3275. * Returns the number for IsLesser
  3276. */
  3277. static readonly IsLesser: number;
  3278. /**
  3279. * Internal only The action manager for the condition
  3280. * @hidden
  3281. */
  3282. _actionManager: ActionManager;
  3283. /**
  3284. * Internal only
  3285. * @hidden
  3286. */
  3287. private _target;
  3288. /**
  3289. * Internal only
  3290. * @hidden
  3291. */
  3292. private _effectiveTarget;
  3293. /**
  3294. * Internal only
  3295. * @hidden
  3296. */
  3297. private _property;
  3298. /**
  3299. * Creates a new ValueCondition
  3300. * @param actionManager manager for the action the condition applies to
  3301. * @param target for the action
  3302. * @param propertyPath path to specify the property of the target the conditional operator uses
  3303. * @param value the value compared by the conditional operator against the current value of the property
  3304. * @param operator the conditional operator, default ValueCondition.IsEqual
  3305. */
  3306. constructor(actionManager: ActionManager, target: any,
  3307. /** path to specify the property of the target the conditional operator uses */
  3308. propertyPath: string,
  3309. /** the value compared by the conditional operator against the current value of the property */
  3310. value: any,
  3311. /** the conditional operator, default ValueCondition.IsEqual */
  3312. operator?: number);
  3313. /**
  3314. * Compares the given value with the property value for the specified conditional operator
  3315. * @returns the result of the comparison
  3316. */
  3317. isValid(): boolean;
  3318. /**
  3319. * Serialize the ValueCondition into a JSON compatible object
  3320. * @returns serialization object
  3321. */
  3322. serialize(): any;
  3323. /**
  3324. * Gets the name of the conditional operator for the ValueCondition
  3325. * @param operator the conditional operator
  3326. * @returns the name
  3327. */
  3328. static GetOperatorName(operator: number): string;
  3329. }
  3330. /**
  3331. * Defines a predicate condition as an extension of Condition
  3332. */
  3333. class PredicateCondition extends Condition {
  3334. /** defines the predicate function used to validate the condition */
  3335. predicate: () => boolean;
  3336. /**
  3337. * Internal only - manager for action
  3338. * @hidden
  3339. */
  3340. _actionManager: ActionManager;
  3341. /**
  3342. * Creates a new PredicateCondition
  3343. * @param actionManager manager for the action the condition applies to
  3344. * @param predicate defines the predicate function used to validate the condition
  3345. */
  3346. constructor(actionManager: ActionManager,
  3347. /** defines the predicate function used to validate the condition */
  3348. predicate: () => boolean);
  3349. /**
  3350. * @returns the validity of the predicate condition
  3351. */
  3352. isValid(): boolean;
  3353. }
  3354. /**
  3355. * Defines a state condition as an extension of Condition
  3356. */
  3357. class StateCondition extends Condition {
  3358. /** Value to compare with target state */
  3359. value: string;
  3360. /**
  3361. * Internal only - manager for action
  3362. * @hidden
  3363. */
  3364. _actionManager: ActionManager;
  3365. /**
  3366. * Internal only
  3367. * @hidden
  3368. */
  3369. private _target;
  3370. /**
  3371. * Creates a new StateCondition
  3372. * @param actionManager manager for the action the condition applies to
  3373. * @param target of the condition
  3374. * @param value to compare with target state
  3375. */
  3376. constructor(actionManager: ActionManager, target: any,
  3377. /** Value to compare with target state */
  3378. value: string);
  3379. /**
  3380. * Gets a boolean indicating if the current condition is met
  3381. * @returns the validity of the state
  3382. */
  3383. isValid(): boolean;
  3384. /**
  3385. * Serialize the StateCondition into a JSON compatible object
  3386. * @returns serialization object
  3387. */
  3388. serialize(): any;
  3389. }
  3390. }
  3391. declare module BABYLON {
  3392. /**
  3393. * This defines an action responsible to toggle a boolean once triggered.
  3394. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3395. */
  3396. class SwitchBooleanAction extends Action {
  3397. /**
  3398. * The path to the boolean property in the target object
  3399. */
  3400. propertyPath: string;
  3401. private _target;
  3402. private _effectiveTarget;
  3403. private _property;
  3404. /**
  3405. * Instantiate the action
  3406. * @param triggerOptions defines the trigger options
  3407. * @param target defines the object containing the boolean
  3408. * @param propertyPath defines the path to the boolean property in the target object
  3409. * @param condition defines the trigger related conditions
  3410. */
  3411. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  3412. /** @hidden */
  3413. _prepare(): void;
  3414. /**
  3415. * Execute the action toggle the boolean value.
  3416. */
  3417. execute(): void;
  3418. /**
  3419. * Serializes the actions and its related information.
  3420. * @param parent defines the object to serialize in
  3421. * @returns the serialized object
  3422. */
  3423. serialize(parent: any): any;
  3424. }
  3425. /**
  3426. * This defines an action responsible to set a the state field of the target
  3427. * to a desired value once triggered.
  3428. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3429. */
  3430. class SetStateAction extends Action {
  3431. /**
  3432. * The value to store in the state field.
  3433. */
  3434. value: string;
  3435. private _target;
  3436. /**
  3437. * Instantiate the action
  3438. * @param triggerOptions defines the trigger options
  3439. * @param target defines the object containing the state property
  3440. * @param value defines the value to store in the state field
  3441. * @param condition defines the trigger related conditions
  3442. */
  3443. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  3444. /**
  3445. * Execute the action and store the value on the target state property.
  3446. */
  3447. execute(): void;
  3448. /**
  3449. * Serializes the actions and its related information.
  3450. * @param parent defines the object to serialize in
  3451. * @returns the serialized object
  3452. */
  3453. serialize(parent: any): any;
  3454. }
  3455. /**
  3456. * This defines an action responsible to set a property of the target
  3457. * to a desired value once triggered.
  3458. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3459. */
  3460. class SetValueAction extends Action {
  3461. /**
  3462. * The path of the property to set in the target.
  3463. */
  3464. propertyPath: string;
  3465. /**
  3466. * The value to set in the property
  3467. */
  3468. value: any;
  3469. private _target;
  3470. private _effectiveTarget;
  3471. private _property;
  3472. /**
  3473. * Instantiate the action
  3474. * @param triggerOptions defines the trigger options
  3475. * @param target defines the object containing the property
  3476. * @param propertyPath defines the path of the property to set in the target
  3477. * @param value defines the value to set in the property
  3478. * @param condition defines the trigger related conditions
  3479. */
  3480. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3481. /** @hidden */
  3482. _prepare(): void;
  3483. /**
  3484. * Execute the action and set the targetted property to the desired value.
  3485. */
  3486. execute(): void;
  3487. /**
  3488. * Serializes the actions and its related information.
  3489. * @param parent defines the object to serialize in
  3490. * @returns the serialized object
  3491. */
  3492. serialize(parent: any): any;
  3493. }
  3494. /**
  3495. * This defines an action responsible to increment the target value
  3496. * to a desired value once triggered.
  3497. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3498. */
  3499. class IncrementValueAction extends Action {
  3500. /**
  3501. * The path of the property to increment in the target.
  3502. */
  3503. propertyPath: string;
  3504. /**
  3505. * The value we should increment the property by.
  3506. */
  3507. value: any;
  3508. private _target;
  3509. private _effectiveTarget;
  3510. private _property;
  3511. /**
  3512. * Instantiate the action
  3513. * @param triggerOptions defines the trigger options
  3514. * @param target defines the object containing the property
  3515. * @param propertyPath defines the path of the property to increment in the target
  3516. * @param value defines the value value we should increment the property by
  3517. * @param condition defines the trigger related conditions
  3518. */
  3519. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3520. /** @hidden */
  3521. _prepare(): void;
  3522. /**
  3523. * Execute the action and increment the target of the value amount.
  3524. */
  3525. execute(): void;
  3526. /**
  3527. * Serializes the actions and its related information.
  3528. * @param parent defines the object to serialize in
  3529. * @returns the serialized object
  3530. */
  3531. serialize(parent: any): any;
  3532. }
  3533. /**
  3534. * This defines an action responsible to start an animation once triggered.
  3535. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3536. */
  3537. class PlayAnimationAction extends Action {
  3538. /**
  3539. * Where the animation should start (animation frame)
  3540. */
  3541. from: number;
  3542. /**
  3543. * Where the animation should stop (animation frame)
  3544. */
  3545. to: number;
  3546. /**
  3547. * Define if the animation should loop or stop after the first play.
  3548. */
  3549. loop?: boolean;
  3550. private _target;
  3551. /**
  3552. * Instantiate the action
  3553. * @param triggerOptions defines the trigger options
  3554. * @param target defines the target animation or animation name
  3555. * @param from defines from where the animation should start (animation frame)
  3556. * @param end defines where the animation should stop (animation frame)
  3557. * @param loop defines if the animation should loop or stop after the first play
  3558. * @param condition defines the trigger related conditions
  3559. */
  3560. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  3561. /** @hidden */
  3562. _prepare(): void;
  3563. /**
  3564. * Execute the action and play the animation.
  3565. */
  3566. execute(): void;
  3567. /**
  3568. * Serializes the actions and its related information.
  3569. * @param parent defines the object to serialize in
  3570. * @returns the serialized object
  3571. */
  3572. serialize(parent: any): any;
  3573. }
  3574. /**
  3575. * This defines an action responsible to stop an animation once triggered.
  3576. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3577. */
  3578. class StopAnimationAction extends Action {
  3579. private _target;
  3580. /**
  3581. * Instantiate the action
  3582. * @param triggerOptions defines the trigger options
  3583. * @param target defines the target animation or animation name
  3584. * @param condition defines the trigger related conditions
  3585. */
  3586. constructor(triggerOptions: any, target: any, condition?: Condition);
  3587. /** @hidden */
  3588. _prepare(): void;
  3589. /**
  3590. * Execute the action and stop the animation.
  3591. */
  3592. execute(): void;
  3593. /**
  3594. * Serializes the actions and its related information.
  3595. * @param parent defines the object to serialize in
  3596. * @returns the serialized object
  3597. */
  3598. serialize(parent: any): any;
  3599. }
  3600. /**
  3601. * This defines an action responsible that does nothing once triggered.
  3602. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3603. */
  3604. class DoNothingAction extends Action {
  3605. /**
  3606. * Instantiate the action
  3607. * @param triggerOptions defines the trigger options
  3608. * @param condition defines the trigger related conditions
  3609. */
  3610. constructor(triggerOptions?: any, condition?: Condition);
  3611. /**
  3612. * Execute the action and do nothing.
  3613. */
  3614. execute(): void;
  3615. /**
  3616. * Serializes the actions and its related information.
  3617. * @param parent defines the object to serialize in
  3618. * @returns the serialized object
  3619. */
  3620. serialize(parent: any): any;
  3621. }
  3622. /**
  3623. * This defines an action responsible to trigger several actions once triggered.
  3624. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3625. */
  3626. class CombineAction extends Action {
  3627. /**
  3628. * The list of aggregated animations to run.
  3629. */
  3630. children: Action[];
  3631. /**
  3632. * Instantiate the action
  3633. * @param triggerOptions defines the trigger options
  3634. * @param children defines the list of aggregated animations to run
  3635. * @param condition defines the trigger related conditions
  3636. */
  3637. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  3638. /** @hidden */
  3639. _prepare(): void;
  3640. /**
  3641. * Execute the action and executes all the aggregated actions.
  3642. */
  3643. execute(evt: ActionEvent): void;
  3644. /**
  3645. * Serializes the actions and its related information.
  3646. * @param parent defines the object to serialize in
  3647. * @returns the serialized object
  3648. */
  3649. serialize(parent: any): any;
  3650. }
  3651. /**
  3652. * This defines an action responsible to run code (external event) once triggered.
  3653. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3654. */
  3655. class ExecuteCodeAction extends Action {
  3656. /**
  3657. * The callback function to run.
  3658. */
  3659. func: (evt: ActionEvent) => void;
  3660. /**
  3661. * Instantiate the action
  3662. * @param triggerOptions defines the trigger options
  3663. * @param func defines the callback function to run
  3664. * @param condition defines the trigger related conditions
  3665. */
  3666. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  3667. /**
  3668. * Execute the action and run the attached code.
  3669. */
  3670. execute(evt: ActionEvent): void;
  3671. }
  3672. /**
  3673. * This defines an action responsible to set the parent property of the target once triggered.
  3674. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3675. */
  3676. class SetParentAction extends Action {
  3677. private _parent;
  3678. private _target;
  3679. /**
  3680. * Instantiate the action
  3681. * @param triggerOptions defines the trigger options
  3682. * @param target defines the target containing the parent property
  3683. * @param parent defines from where the animation should start (animation frame)
  3684. * @param condition defines the trigger related conditions
  3685. */
  3686. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  3687. /** @hidden */
  3688. _prepare(): void;
  3689. /**
  3690. * Execute the action and set the parent property.
  3691. */
  3692. execute(): void;
  3693. /**
  3694. * Serializes the actions and its related information.
  3695. * @param parent defines the object to serialize in
  3696. * @returns the serialized object
  3697. */
  3698. serialize(parent: any): any;
  3699. }
  3700. }
  3701. declare module BABYLON {
  3702. /**
  3703. * This defines an action helpful to play a defined sound on a triggered action.
  3704. */
  3705. class PlaySoundAction extends Action {
  3706. private _sound;
  3707. /**
  3708. * Instantiate the action
  3709. * @param triggerOptions defines the trigger options
  3710. * @param sound defines the sound to play
  3711. * @param condition defines the trigger related conditions
  3712. */
  3713. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3714. /** @hidden */
  3715. _prepare(): void;
  3716. /**
  3717. * Execute the action and play the sound.
  3718. */
  3719. execute(): void;
  3720. /**
  3721. * Serializes the actions and its related information.
  3722. * @param parent defines the object to serialize in
  3723. * @returns the serialized object
  3724. */
  3725. serialize(parent: any): any;
  3726. }
  3727. /**
  3728. * This defines an action helpful to stop a defined sound on a triggered action.
  3729. */
  3730. class StopSoundAction extends Action {
  3731. private _sound;
  3732. /**
  3733. * Instantiate the action
  3734. * @param triggerOptions defines the trigger options
  3735. * @param sound defines the sound to stop
  3736. * @param condition defines the trigger related conditions
  3737. */
  3738. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3739. /** @hidden */
  3740. _prepare(): void;
  3741. /**
  3742. * Execute the action and stop the sound.
  3743. */
  3744. execute(): void;
  3745. /**
  3746. * Serializes the actions and its related information.
  3747. * @param parent defines the object to serialize in
  3748. * @returns the serialized object
  3749. */
  3750. serialize(parent: any): any;
  3751. }
  3752. }
  3753. declare module BABYLON {
  3754. /**
  3755. * This defines an action responsible to change the value of a property
  3756. * by interpolating between its current value and the newly set one once triggered.
  3757. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3758. */
  3759. class InterpolateValueAction extends Action {
  3760. /**
  3761. * Defines the path of the property where the value should be interpolated
  3762. */
  3763. propertyPath: string;
  3764. /**
  3765. * Defines the target value at the end of the interpolation.
  3766. */
  3767. value: any;
  3768. /**
  3769. * Defines the time it will take for the property to interpolate to the value.
  3770. */
  3771. duration: number;
  3772. /**
  3773. * Defines if the other scene animations should be stopped when the action has been triggered
  3774. */
  3775. stopOtherAnimations?: boolean;
  3776. /**
  3777. * Defines a callback raised once the interpolation animation has been done.
  3778. */
  3779. onInterpolationDone?: () => void;
  3780. /**
  3781. * Observable triggered once the interpolation animation has been done.
  3782. */
  3783. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  3784. private _target;
  3785. private _effectiveTarget;
  3786. private _property;
  3787. /**
  3788. * Instantiate the action
  3789. * @param triggerOptions defines the trigger options
  3790. * @param target defines the object containing the value to interpolate
  3791. * @param propertyPath defines the path to the property in the target object
  3792. * @param value defines the target value at the end of the interpolation
  3793. * @param duration deines the time it will take for the property to interpolate to the value.
  3794. * @param condition defines the trigger related conditions
  3795. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  3796. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  3797. */
  3798. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  3799. /** @hidden */
  3800. _prepare(): void;
  3801. /**
  3802. * Execute the action starts the value interpolation.
  3803. */
  3804. execute(): void;
  3805. /**
  3806. * Serializes the actions and its related information.
  3807. * @param parent defines the object to serialize in
  3808. * @returns the serialized object
  3809. */
  3810. serialize(parent: any): any;
  3811. }
  3812. }
  3813. declare module BABYLON {
  3814. /**
  3815. * Class used to store an actual running animation
  3816. */
  3817. class Animatable {
  3818. /** defines the target object */
  3819. target: any;
  3820. /** defines the starting frame number (default is 0) */
  3821. fromFrame: number;
  3822. /** defines the ending frame number (default is 100) */
  3823. toFrame: number;
  3824. /** defines if the animation must loop (default is false) */
  3825. loopAnimation: boolean;
  3826. /** defines a callback to call when animation ends if it is not looping */
  3827. onAnimationEnd?: (() => void) | null | undefined;
  3828. private _localDelayOffset;
  3829. private _pausedDelay;
  3830. private _runtimeAnimations;
  3831. private _paused;
  3832. private _scene;
  3833. private _speedRatio;
  3834. private _weight;
  3835. private _syncRoot;
  3836. /**
  3837. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  3838. * This will only apply for non looping animation (default is true)
  3839. */
  3840. disposeOnEnd: boolean;
  3841. /**
  3842. * Gets a boolean indicating if the animation has started
  3843. */
  3844. animationStarted: boolean;
  3845. /**
  3846. * Observer raised when the animation ends
  3847. */
  3848. onAnimationEndObservable: Observable<Animatable>;
  3849. /**
  3850. * Gets the root Animatable used to synchronize and normalize animations
  3851. */
  3852. readonly syncRoot: Animatable;
  3853. /**
  3854. * Gets the current frame of the first RuntimeAnimation
  3855. * Used to synchronize Animatables
  3856. */
  3857. readonly masterFrame: number;
  3858. /**
  3859. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  3860. */
  3861. weight: number;
  3862. /**
  3863. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  3864. */
  3865. speedRatio: number;
  3866. /**
  3867. * Creates a new Animatable
  3868. * @param scene defines the hosting scene
  3869. * @param target defines the target object
  3870. * @param fromFrame defines the starting frame number (default is 0)
  3871. * @param toFrame defines the ending frame number (default is 100)
  3872. * @param loopAnimation defines if the animation must loop (default is false)
  3873. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  3874. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  3875. * @param animations defines a group of animation to add to the new Animatable
  3876. */
  3877. constructor(scene: Scene,
  3878. /** defines the target object */
  3879. target: any,
  3880. /** defines the starting frame number (default is 0) */
  3881. fromFrame?: number,
  3882. /** defines the ending frame number (default is 100) */
  3883. toFrame?: number,
  3884. /** defines if the animation must loop (default is false) */
  3885. loopAnimation?: boolean, speedRatio?: number,
  3886. /** defines a callback to call when animation ends if it is not looping */
  3887. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[]);
  3888. /**
  3889. * Synchronize and normalize current Animatable with a source Animatable
  3890. * This is useful when using animation weights and when animations are not of the same length
  3891. * @param root defines the root Animatable to synchronize with
  3892. * @returns the current Animatable
  3893. */
  3894. syncWith(root: Animatable): Animatable;
  3895. /**
  3896. * Gets the list of runtime animations
  3897. * @returns an array of RuntimeAnimation
  3898. */
  3899. getAnimations(): RuntimeAnimation[];
  3900. /**
  3901. * Adds more animations to the current animatable
  3902. * @param target defines the target of the animations
  3903. * @param animations defines the new animations to add
  3904. */
  3905. appendAnimations(target: any, animations: Animation[]): void;
  3906. /**
  3907. * Gets the source animation for a specific property
  3908. * @param property defines the propertyu to look for
  3909. * @returns null or the source animation for the given property
  3910. */
  3911. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  3912. /**
  3913. * Gets the runtime animation for a specific property
  3914. * @param property defines the propertyu to look for
  3915. * @returns null or the runtime animation for the given property
  3916. */
  3917. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  3918. /**
  3919. * Resets the animatable to its original state
  3920. */
  3921. reset(): void;
  3922. /**
  3923. * Allows the animatable to blend with current running animations
  3924. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  3925. * @param blendingSpeed defines the blending speed to use
  3926. */
  3927. enableBlending(blendingSpeed: number): void;
  3928. /**
  3929. * Disable animation blending
  3930. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  3931. */
  3932. disableBlending(): void;
  3933. /**
  3934. * Jump directly to a given frame
  3935. * @param frame defines the frame to jump to
  3936. */
  3937. goToFrame(frame: number): void;
  3938. /**
  3939. * Pause the animation
  3940. */
  3941. pause(): void;
  3942. /**
  3943. * Restart the animation
  3944. */
  3945. restart(): void;
  3946. private _raiseOnAnimationEnd;
  3947. /**
  3948. * Stop and delete the current animation
  3949. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  3950. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  3951. */
  3952. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  3953. /**
  3954. * Wait asynchronously for the animation to end
  3955. * @returns a promise which will be fullfilled when the animation ends
  3956. */
  3957. waitAsync(): Promise<Animatable>;
  3958. /** @hidden */
  3959. _animate(delay: number): boolean;
  3960. }
  3961. }
  3962. declare module BABYLON {
  3963. /**
  3964. * Represents the range of an animation
  3965. */
  3966. class AnimationRange {
  3967. /**The name of the animation range**/
  3968. name: string;
  3969. /**The starting frame of the animation */
  3970. from: number;
  3971. /**The ending frame of the animation*/
  3972. to: number;
  3973. /**
  3974. * Initializes the range of an animation
  3975. * @param name The name of the animation range
  3976. * @param from The starting frame of the animation
  3977. * @param to The ending frame of the animation
  3978. */
  3979. constructor(
  3980. /**The name of the animation range**/
  3981. name: string,
  3982. /**The starting frame of the animation */
  3983. from: number,
  3984. /**The ending frame of the animation*/
  3985. to: number);
  3986. /**
  3987. * Makes a copy of the animation range
  3988. * @returns A copy of the animation range
  3989. */
  3990. clone(): AnimationRange;
  3991. }
  3992. /**
  3993. * Composed of a frame, and an action function
  3994. */
  3995. class AnimationEvent {
  3996. /** The frame for which the event is triggered **/
  3997. frame: number;
  3998. /** The event to perform when triggered **/
  3999. action: (currentFrame: number) => void;
  4000. /** Specifies if the event should be triggered only once**/
  4001. onlyOnce?: boolean | undefined;
  4002. /**
  4003. * Specifies if the animation event is done
  4004. */
  4005. isDone: boolean;
  4006. /**
  4007. * Initializes the animation event
  4008. * @param frame The frame for which the event is triggered
  4009. * @param action The event to perform when triggered
  4010. * @param onlyOnce Specifies if the event should be triggered only once
  4011. */
  4012. constructor(
  4013. /** The frame for which the event is triggered **/
  4014. frame: number,
  4015. /** The event to perform when triggered **/
  4016. action: (currentFrame: number) => void,
  4017. /** Specifies if the event should be triggered only once**/
  4018. onlyOnce?: boolean | undefined);
  4019. /** @hidden */
  4020. _clone(): AnimationEvent;
  4021. }
  4022. /**
  4023. * A cursor which tracks a point on a path
  4024. */
  4025. class PathCursor {
  4026. private path;
  4027. /**
  4028. * Stores path cursor callbacks for when an onchange event is triggered
  4029. */
  4030. private _onchange;
  4031. /**
  4032. * The value of the path cursor
  4033. */
  4034. value: number;
  4035. /**
  4036. * The animation array of the path cursor
  4037. */
  4038. animations: Animation[];
  4039. /**
  4040. * Initializes the path cursor
  4041. * @param path The path to track
  4042. */
  4043. constructor(path: Path2);
  4044. /**
  4045. * Gets the cursor point on the path
  4046. * @returns A point on the path cursor at the cursor location
  4047. */
  4048. getPoint(): Vector3;
  4049. /**
  4050. * Moves the cursor ahead by the step amount
  4051. * @param step The amount to move the cursor forward
  4052. * @returns This path cursor
  4053. */
  4054. moveAhead(step?: number): PathCursor;
  4055. /**
  4056. * Moves the cursor behind by the step amount
  4057. * @param step The amount to move the cursor back
  4058. * @returns This path cursor
  4059. */
  4060. moveBack(step?: number): PathCursor;
  4061. /**
  4062. * Moves the cursor by the step amount
  4063. * If the step amount is greater than one, an exception is thrown
  4064. * @param step The amount to move the cursor
  4065. * @returns This path cursor
  4066. */
  4067. move(step: number): PathCursor;
  4068. /**
  4069. * Ensures that the value is limited between zero and one
  4070. * @returns This path cursor
  4071. */
  4072. private ensureLimits;
  4073. /**
  4074. * Runs onchange callbacks on change (used by the animation engine)
  4075. * @returns This path cursor
  4076. */
  4077. private raiseOnChange;
  4078. /**
  4079. * Executes a function on change
  4080. * @param f A path cursor onchange callback
  4081. * @returns This path cursor
  4082. */
  4083. onchange(f: (cursor: PathCursor) => void): PathCursor;
  4084. }
  4085. /**
  4086. * Defines an interface which represents an animation key frame
  4087. */
  4088. interface IAnimationKey {
  4089. /**
  4090. * Frame of the key frame
  4091. */
  4092. frame: number;
  4093. /**
  4094. * Value at the specifies key frame
  4095. */
  4096. value: any;
  4097. /**
  4098. * The input tangent for the cubic hermite spline
  4099. */
  4100. inTangent?: any;
  4101. /**
  4102. * The output tangent for the cubic hermite spline
  4103. */
  4104. outTangent?: any;
  4105. /**
  4106. * The animation interpolation type
  4107. */
  4108. interpolation?: AnimationKeyInterpolation;
  4109. }
  4110. /**
  4111. * Enum for the animation key frame interpolation type
  4112. */
  4113. enum AnimationKeyInterpolation {
  4114. /**
  4115. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  4116. */
  4117. STEP = 1
  4118. }
  4119. /**
  4120. * Class used to store any kind of animation
  4121. */
  4122. class Animation {
  4123. /**Name of the animation */
  4124. name: string;
  4125. /**Property to animate */
  4126. targetProperty: string;
  4127. /**The frames per second of the animation */
  4128. framePerSecond: number;
  4129. /**The data type of the animation */
  4130. dataType: number;
  4131. /**The loop mode of the animation */
  4132. loopMode?: number | undefined;
  4133. /**Specifies if blending should be enabled */
  4134. enableBlending?: boolean | undefined;
  4135. /**
  4136. * Use matrix interpolation instead of using direct key value when animating matrices
  4137. */
  4138. static AllowMatricesInterpolation: boolean;
  4139. /**
  4140. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  4141. */
  4142. static AllowMatrixDecomposeForInterpolation: boolean;
  4143. /**
  4144. * Stores the key frames of the animation
  4145. */
  4146. private _keys;
  4147. /**
  4148. * Stores the easing function of the animation
  4149. */
  4150. private _easingFunction;
  4151. /**
  4152. * @hidden Internal use only
  4153. */
  4154. _runtimeAnimations: RuntimeAnimation[];
  4155. /**
  4156. * The set of event that will be linked to this animation
  4157. */
  4158. private _events;
  4159. /**
  4160. * Stores an array of target property paths
  4161. */
  4162. targetPropertyPath: string[];
  4163. /**
  4164. * Stores the blending speed of the animation
  4165. */
  4166. blendingSpeed: number;
  4167. /**
  4168. * Stores the animation ranges for the animation
  4169. */
  4170. private _ranges;
  4171. /**
  4172. * @hidden Internal use
  4173. */
  4174. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  4175. /**
  4176. * Sets up an animation
  4177. * @param property The property to animate
  4178. * @param animationType The animation type to apply
  4179. * @param framePerSecond The frames per second of the animation
  4180. * @param easingFunction The easing function used in the animation
  4181. * @returns The created animation
  4182. */
  4183. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  4184. /**
  4185. * Create and start an animation on a node
  4186. * @param name defines the name of the global animation that will be run on all nodes
  4187. * @param node defines the root node where the animation will take place
  4188. * @param targetProperty defines property to animate
  4189. * @param framePerSecond defines the number of frame per second yo use
  4190. * @param totalFrame defines the number of frames in total
  4191. * @param from defines the initial value
  4192. * @param to defines the final value
  4193. * @param loopMode defines which loop mode you want to use (off by default)
  4194. * @param easingFunction defines the easing function to use (linear by default)
  4195. * @param onAnimationEnd defines the callback to call when animation end
  4196. * @returns the animatable created for this animation
  4197. */
  4198. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  4199. /**
  4200. * Create and start an animation on a node and its descendants
  4201. * @param name defines the name of the global animation that will be run on all nodes
  4202. * @param node defines the root node where the animation will take place
  4203. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used
  4204. * @param targetProperty defines property to animate
  4205. * @param framePerSecond defines the number of frame per second to use
  4206. * @param totalFrame defines the number of frames in total
  4207. * @param from defines the initial value
  4208. * @param to defines the final value
  4209. * @param loopMode defines which loop mode you want to use (off by default)
  4210. * @param easingFunction defines the easing function to use (linear by default)
  4211. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  4212. * @returns the list of animatables created for all nodes
  4213. * @example https://www.babylonjs-playground.com/#MH0VLI
  4214. */
  4215. static CreateAndStartHierarchyAnimation(name: string, node: Node, directDescendantsOnly: boolean, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable[]>;
  4216. /**
  4217. * Creates a new animation, merges it with the existing animations and starts it
  4218. * @param name Name of the animation
  4219. * @param node Node which contains the scene that begins the animations
  4220. * @param targetProperty Specifies which property to animate
  4221. * @param framePerSecond The frames per second of the animation
  4222. * @param totalFrame The total number of frames
  4223. * @param from The frame at the beginning of the animation
  4224. * @param to The frame at the end of the animation
  4225. * @param loopMode Specifies the loop mode of the animation
  4226. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  4227. * @param onAnimationEnd Callback to run once the animation is complete
  4228. * @returns Nullable animation
  4229. */
  4230. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  4231. /**
  4232. * Transition property of an host to the target Value
  4233. * @param property The property to transition
  4234. * @param targetValue The target Value of the property
  4235. * @param host The object where the property to animate belongs
  4236. * @param scene Scene used to run the animation
  4237. * @param frameRate Framerate (in frame/s) to use
  4238. * @param transition The transition type we want to use
  4239. * @param duration The duration of the animation, in milliseconds
  4240. * @param onAnimationEnd Callback trigger at the end of the animation
  4241. * @returns Nullable animation
  4242. */
  4243. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  4244. /**
  4245. * Return the array of runtime animations currently using this animation
  4246. */
  4247. readonly runtimeAnimations: RuntimeAnimation[];
  4248. /**
  4249. * Specifies if any of the runtime animations are currently running
  4250. */
  4251. readonly hasRunningRuntimeAnimations: boolean;
  4252. /**
  4253. * Initializes the animation
  4254. * @param name Name of the animation
  4255. * @param targetProperty Property to animate
  4256. * @param framePerSecond The frames per second of the animation
  4257. * @param dataType The data type of the animation
  4258. * @param loopMode The loop mode of the animation
  4259. * @param enableBlendings Specifies if blending should be enabled
  4260. */
  4261. constructor(
  4262. /**Name of the animation */
  4263. name: string,
  4264. /**Property to animate */
  4265. targetProperty: string,
  4266. /**The frames per second of the animation */
  4267. framePerSecond: number,
  4268. /**The data type of the animation */
  4269. dataType: number,
  4270. /**The loop mode of the animation */
  4271. loopMode?: number | undefined,
  4272. /**Specifies if blending should be enabled */
  4273. enableBlending?: boolean | undefined);
  4274. /**
  4275. * Converts the animation to a string
  4276. * @param fullDetails support for multiple levels of logging within scene loading
  4277. * @returns String form of the animation
  4278. */
  4279. toString(fullDetails?: boolean): string;
  4280. /**
  4281. * Add an event to this animation
  4282. * @param event Event to add
  4283. */
  4284. addEvent(event: AnimationEvent): void;
  4285. /**
  4286. * Remove all events found at the given frame
  4287. * @param frame The frame to remove events from
  4288. */
  4289. removeEvents(frame: number): void;
  4290. /**
  4291. * Retrieves all the events from the animation
  4292. * @returns Events from the animation
  4293. */
  4294. getEvents(): AnimationEvent[];
  4295. /**
  4296. * Creates an animation range
  4297. * @param name Name of the animation range
  4298. * @param from Starting frame of the animation range
  4299. * @param to Ending frame of the animation
  4300. */
  4301. createRange(name: string, from: number, to: number): void;
  4302. /**
  4303. * Deletes an animation range by name
  4304. * @param name Name of the animation range to delete
  4305. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  4306. */
  4307. deleteRange(name: string, deleteFrames?: boolean): void;
  4308. /**
  4309. * Gets the animation range by name, or null if not defined
  4310. * @param name Name of the animation range
  4311. * @returns Nullable animation range
  4312. */
  4313. getRange(name: string): Nullable<AnimationRange>;
  4314. /**
  4315. * Gets the key frames from the animation
  4316. * @returns The key frames of the animation
  4317. */
  4318. getKeys(): Array<IAnimationKey>;
  4319. /**
  4320. * Gets the highest frame rate of the animation
  4321. * @returns Highest frame rate of the animation
  4322. */
  4323. getHighestFrame(): number;
  4324. /**
  4325. * Gets the easing function of the animation
  4326. * @returns Easing function of the animation
  4327. */
  4328. getEasingFunction(): IEasingFunction;
  4329. /**
  4330. * Sets the easing function of the animation
  4331. * @param easingFunction A custom mathematical formula for animation
  4332. */
  4333. setEasingFunction(easingFunction: EasingFunction): void;
  4334. /**
  4335. * Interpolates a scalar linearly
  4336. * @param startValue Start value of the animation curve
  4337. * @param endValue End value of the animation curve
  4338. * @param gradient Scalar amount to interpolate
  4339. * @returns Interpolated scalar value
  4340. */
  4341. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  4342. /**
  4343. * Interpolates a scalar cubically
  4344. * @param startValue Start value of the animation curve
  4345. * @param outTangent End tangent of the animation
  4346. * @param endValue End value of the animation curve
  4347. * @param inTangent Start tangent of the animation curve
  4348. * @param gradient Scalar amount to interpolate
  4349. * @returns Interpolated scalar value
  4350. */
  4351. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  4352. /**
  4353. * Interpolates a quaternion using a spherical linear interpolation
  4354. * @param startValue Start value of the animation curve
  4355. * @param endValue End value of the animation curve
  4356. * @param gradient Scalar amount to interpolate
  4357. * @returns Interpolated quaternion value
  4358. */
  4359. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  4360. /**
  4361. * Interpolates a quaternion cubically
  4362. * @param startValue Start value of the animation curve
  4363. * @param outTangent End tangent of the animation curve
  4364. * @param endValue End value of the animation curve
  4365. * @param inTangent Start tangent of the animation curve
  4366. * @param gradient Scalar amount to interpolate
  4367. * @returns Interpolated quaternion value
  4368. */
  4369. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  4370. /**
  4371. * Interpolates a Vector3 linearl
  4372. * @param startValue Start value of the animation curve
  4373. * @param endValue End value of the animation curve
  4374. * @param gradient Scalar amount to interpolate
  4375. * @returns Interpolated scalar value
  4376. */
  4377. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  4378. /**
  4379. * Interpolates a Vector3 cubically
  4380. * @param startValue Start value of the animation curve
  4381. * @param outTangent End tangent of the animation
  4382. * @param endValue End value of the animation curve
  4383. * @param inTangent Start tangent of the animation curve
  4384. * @param gradient Scalar amount to interpolate
  4385. * @returns InterpolatedVector3 value
  4386. */
  4387. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  4388. /**
  4389. * Interpolates a Vector2 linearly
  4390. * @param startValue Start value of the animation curve
  4391. * @param endValue End value of the animation curve
  4392. * @param gradient Scalar amount to interpolate
  4393. * @returns Interpolated Vector2 value
  4394. */
  4395. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  4396. /**
  4397. * Interpolates a Vector2 cubically
  4398. * @param startValue Start value of the animation curve
  4399. * @param outTangent End tangent of the animation
  4400. * @param endValue End value of the animation curve
  4401. * @param inTangent Start tangent of the animation curve
  4402. * @param gradient Scalar amount to interpolate
  4403. * @returns Interpolated Vector2 value
  4404. */
  4405. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  4406. /**
  4407. * Interpolates a size linearly
  4408. * @param startValue Start value of the animation curve
  4409. * @param endValue End value of the animation curve
  4410. * @param gradient Scalar amount to interpolate
  4411. * @returns Interpolated Size value
  4412. */
  4413. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  4414. /**
  4415. * Interpolates a Color3 linearly
  4416. * @param startValue Start value of the animation curve
  4417. * @param endValue End value of the animation curve
  4418. * @param gradient Scalar amount to interpolate
  4419. * @returns Interpolated Color3 value
  4420. */
  4421. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  4422. /**
  4423. * @hidden Internal use only
  4424. */
  4425. _getKeyValue(value: any): any;
  4426. /**
  4427. * @hidden Internal use only
  4428. */
  4429. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  4430. /**
  4431. * Defines the function to use to interpolate matrices
  4432. * @param startValue defines the start matrix
  4433. * @param endValue defines the end matrix
  4434. * @param gradient defines the gradient between both matrices
  4435. * @param result defines an optional target matrix where to store the interpolation
  4436. * @returns the interpolated matrix
  4437. */
  4438. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  4439. /**
  4440. * Makes a copy of the animation
  4441. * @returns Cloned animation
  4442. */
  4443. clone(): Animation;
  4444. /**
  4445. * Sets the key frames of the animation
  4446. * @param values The animation key frames to set
  4447. */
  4448. setKeys(values: Array<IAnimationKey>): void;
  4449. /**
  4450. * Serializes the animation to an object
  4451. * @returns Serialized object
  4452. */
  4453. serialize(): any;
  4454. /**
  4455. * Float animation type
  4456. */
  4457. private static _ANIMATIONTYPE_FLOAT;
  4458. /**
  4459. * Vector3 animation type
  4460. */
  4461. private static _ANIMATIONTYPE_VECTOR3;
  4462. /**
  4463. * Quaternion animation type
  4464. */
  4465. private static _ANIMATIONTYPE_QUATERNION;
  4466. /**
  4467. * Matrix animation type
  4468. */
  4469. private static _ANIMATIONTYPE_MATRIX;
  4470. /**
  4471. * Color3 animation type
  4472. */
  4473. private static _ANIMATIONTYPE_COLOR3;
  4474. /**
  4475. * Vector2 animation type
  4476. */
  4477. private static _ANIMATIONTYPE_VECTOR2;
  4478. /**
  4479. * Size animation type
  4480. */
  4481. private static _ANIMATIONTYPE_SIZE;
  4482. /**
  4483. * Relative Loop Mode
  4484. */
  4485. private static _ANIMATIONLOOPMODE_RELATIVE;
  4486. /**
  4487. * Cycle Loop Mode
  4488. */
  4489. private static _ANIMATIONLOOPMODE_CYCLE;
  4490. /**
  4491. * Constant Loop Mode
  4492. */
  4493. private static _ANIMATIONLOOPMODE_CONSTANT;
  4494. /**
  4495. * Get the float animation type
  4496. */
  4497. static readonly ANIMATIONTYPE_FLOAT: number;
  4498. /**
  4499. * Get the Vector3 animation type
  4500. */
  4501. static readonly ANIMATIONTYPE_VECTOR3: number;
  4502. /**
  4503. * Get the Vector2 animation type
  4504. */
  4505. static readonly ANIMATIONTYPE_VECTOR2: number;
  4506. /**
  4507. * Get the Size animation type
  4508. */
  4509. static readonly ANIMATIONTYPE_SIZE: number;
  4510. /**
  4511. * Get the Quaternion animation type
  4512. */
  4513. static readonly ANIMATIONTYPE_QUATERNION: number;
  4514. /**
  4515. * Get the Matrix animation type
  4516. */
  4517. static readonly ANIMATIONTYPE_MATRIX: number;
  4518. /**
  4519. * Get the Color3 animation type
  4520. */
  4521. static readonly ANIMATIONTYPE_COLOR3: number;
  4522. /**
  4523. * Get the Relative Loop Mode
  4524. */
  4525. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  4526. /**
  4527. * Get the Cycle Loop Mode
  4528. */
  4529. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  4530. /**
  4531. * Get the Constant Loop Mode
  4532. */
  4533. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  4534. /** @hidden */
  4535. static _UniversalLerp(left: any, right: any, amount: number): any;
  4536. /**
  4537. * Parses an animation object and creates an animation
  4538. * @param parsedAnimation Parsed animation object
  4539. * @returns Animation object
  4540. */
  4541. static Parse(parsedAnimation: any): Animation;
  4542. /**
  4543. * Appends the serialized animations from the source animations
  4544. * @param source Source containing the animations
  4545. * @param destination Target to store the animations
  4546. */
  4547. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  4548. }
  4549. }
  4550. declare module BABYLON {
  4551. /**
  4552. * This class defines the direct association between an animation and a target
  4553. */
  4554. class TargetedAnimation {
  4555. /**
  4556. * Animation to perform
  4557. */
  4558. animation: Animation;
  4559. /**
  4560. * Target to animate
  4561. */
  4562. target: any;
  4563. }
  4564. /**
  4565. * Use this class to create coordinated animations on multiple targets
  4566. */
  4567. class AnimationGroup implements IDisposable {
  4568. /** The name of the animation group */
  4569. name: string;
  4570. private _scene;
  4571. private _targetedAnimations;
  4572. private _animatables;
  4573. private _from;
  4574. private _to;
  4575. private _isStarted;
  4576. private _isPaused;
  4577. private _speedRatio;
  4578. /**
  4579. * Gets or sets the unique id of the node
  4580. */
  4581. uniqueId: number;
  4582. /**
  4583. * This observable will notify when one animation have ended.
  4584. */
  4585. onAnimationEndObservable: Observable<TargetedAnimation>;
  4586. /**
  4587. * This observable will notify when all animations have ended.
  4588. */
  4589. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  4590. /**
  4591. * This observable will notify when all animations have paused.
  4592. */
  4593. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  4594. /**
  4595. * This observable will notify when all animations are playing.
  4596. */
  4597. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  4598. /**
  4599. * Gets the first frame
  4600. */
  4601. readonly from: number;
  4602. /**
  4603. * Gets the last frame
  4604. */
  4605. readonly to: number;
  4606. /**
  4607. * Define if the animations are started
  4608. */
  4609. readonly isStarted: boolean;
  4610. /**
  4611. * Gets a value indicating that the current group is playing
  4612. */
  4613. readonly isPlaying: boolean;
  4614. /**
  4615. * Gets or sets the speed ratio to use for all animations
  4616. */
  4617. /**
  4618. * Gets or sets the speed ratio to use for all animations
  4619. */
  4620. speedRatio: number;
  4621. /**
  4622. * Gets the targeted animations for this animation group
  4623. */
  4624. readonly targetedAnimations: Array<TargetedAnimation>;
  4625. /**
  4626. * returning the list of animatables controlled by this animation group.
  4627. */
  4628. readonly animatables: Array<Animatable>;
  4629. /**
  4630. * Instantiates a new Animation Group.
  4631. * This helps managing several animations at once.
  4632. * @see http://doc.babylonjs.com/how_to/group
  4633. * @param name Defines the name of the group
  4634. * @param scene Defines the scene the group belongs to
  4635. */
  4636. constructor(
  4637. /** The name of the animation group */
  4638. name: string, scene?: Nullable<Scene>);
  4639. /**
  4640. * Add an animation (with its target) in the group
  4641. * @param animation defines the animation we want to add
  4642. * @param target defines the target of the animation
  4643. * @returns the TargetedAnimation object
  4644. */
  4645. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  4646. /**
  4647. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  4648. * It can add constant keys at begin or end
  4649. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  4650. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  4651. * @returns the animation group
  4652. */
  4653. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  4654. /**
  4655. * Start all animations on given targets
  4656. * @param loop defines if animations must loop
  4657. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  4658. * @param from defines the from key (optional)
  4659. * @param to defines the to key (optional)
  4660. * @returns the current animation group
  4661. */
  4662. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  4663. /**
  4664. * Pause all animations
  4665. * @returns the animation group
  4666. */
  4667. pause(): AnimationGroup;
  4668. /**
  4669. * Play all animations to initial state
  4670. * This function will start() the animations if they were not started or will restart() them if they were paused
  4671. * @param loop defines if animations must loop
  4672. * @returns the animation group
  4673. */
  4674. play(loop?: boolean): AnimationGroup;
  4675. /**
  4676. * Reset all animations to initial state
  4677. * @returns the animation group
  4678. */
  4679. reset(): AnimationGroup;
  4680. /**
  4681. * Restart animations from key 0
  4682. * @returns the animation group
  4683. */
  4684. restart(): AnimationGroup;
  4685. /**
  4686. * Stop all animations
  4687. * @returns the animation group
  4688. */
  4689. stop(): AnimationGroup;
  4690. /**
  4691. * Set animation weight for all animatables
  4692. * @param weight defines the weight to use
  4693. * @return the animationGroup
  4694. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4695. */
  4696. setWeightForAllAnimatables(weight: number): AnimationGroup;
  4697. /**
  4698. * Synchronize and normalize all animatables with a source animatable
  4699. * @param root defines the root animatable to synchronize with
  4700. * @return the animationGroup
  4701. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4702. */
  4703. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  4704. /**
  4705. * Goes to a specific frame in this animation group
  4706. * @param frame the frame number to go to
  4707. * @return the animationGroup
  4708. */
  4709. goToFrame(frame: number): AnimationGroup;
  4710. /**
  4711. * Dispose all associated resources
  4712. */
  4713. dispose(): void;
  4714. private _checkAnimationGroupEnded;
  4715. /**
  4716. * Returns a new AnimationGroup object parsed from the source provided.
  4717. * @param parsedAnimationGroup defines the source
  4718. * @param scene defines the scene that will receive the animationGroup
  4719. * @returns a new AnimationGroup
  4720. */
  4721. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  4722. /**
  4723. * Returns the string "AnimationGroup"
  4724. * @returns "AnimationGroup"
  4725. */
  4726. getClassName(): string;
  4727. /**
  4728. * Creates a detailled string about the object
  4729. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  4730. * @returns a string representing the object
  4731. */
  4732. toString(fullDetails?: boolean): string;
  4733. }
  4734. }
  4735. declare module BABYLON {
  4736. /**
  4737. * Class used to override all child animations of a given target
  4738. */
  4739. class AnimationPropertiesOverride {
  4740. /**
  4741. * Gets or sets a value indicating if animation blending must be used
  4742. */
  4743. enableBlending: boolean;
  4744. /**
  4745. * Gets or sets the blending speed to use when enableBlending is true
  4746. */
  4747. blendingSpeed: number;
  4748. /**
  4749. * Gets or sets the default loop mode to use
  4750. */
  4751. loopMode: number;
  4752. }
  4753. }
  4754. declare module BABYLON {
  4755. /**
  4756. * This represents the main contract an easing function should follow.
  4757. * Easing functions are used throughout the animation system.
  4758. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4759. */
  4760. interface IEasingFunction {
  4761. /**
  4762. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4763. * of the easing function.
  4764. * The link below provides some of the most common examples of easing functions.
  4765. * @see https://easings.net/
  4766. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4767. * @returns the corresponding value on the curve defined by the easing function
  4768. */
  4769. ease(gradient: number): number;
  4770. }
  4771. /**
  4772. * Base class used for every default easing function.
  4773. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4774. */
  4775. class EasingFunction implements IEasingFunction {
  4776. /**
  4777. * Interpolation follows the mathematical formula associated with the easing function.
  4778. */
  4779. static readonly EASINGMODE_EASEIN: number;
  4780. /**
  4781. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  4782. */
  4783. static readonly EASINGMODE_EASEOUT: number;
  4784. /**
  4785. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  4786. */
  4787. static readonly EASINGMODE_EASEINOUT: number;
  4788. private _easingMode;
  4789. /**
  4790. * Sets the easing mode of the current function.
  4791. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  4792. */
  4793. setEasingMode(easingMode: number): void;
  4794. /**
  4795. * Gets the current easing mode.
  4796. * @returns the easing mode
  4797. */
  4798. getEasingMode(): number;
  4799. /**
  4800. * @hidden
  4801. */
  4802. easeInCore(gradient: number): number;
  4803. /**
  4804. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4805. * of the easing function.
  4806. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4807. * @returns the corresponding value on the curve defined by the easing function
  4808. */
  4809. ease(gradient: number): number;
  4810. }
  4811. /**
  4812. * Easing function with a circle shape (see link below).
  4813. * @see https://easings.net/#easeInCirc
  4814. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4815. */
  4816. class CircleEase extends EasingFunction implements IEasingFunction {
  4817. /** @hidden */
  4818. easeInCore(gradient: number): number;
  4819. }
  4820. /**
  4821. * Easing function with a ease back shape (see link below).
  4822. * @see https://easings.net/#easeInBack
  4823. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4824. */
  4825. class BackEase extends EasingFunction implements IEasingFunction {
  4826. /** Defines the amplitude of the function */
  4827. amplitude: number;
  4828. /**
  4829. * Instantiates a back ease easing
  4830. * @see https://easings.net/#easeInBack
  4831. * @param amplitude Defines the amplitude of the function
  4832. */
  4833. constructor(
  4834. /** Defines the amplitude of the function */
  4835. amplitude?: number);
  4836. /** @hidden */
  4837. easeInCore(gradient: number): number;
  4838. }
  4839. /**
  4840. * Easing function with a bouncing shape (see link below).
  4841. * @see https://easings.net/#easeInBounce
  4842. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4843. */
  4844. class BounceEase extends EasingFunction implements IEasingFunction {
  4845. /** Defines the number of bounces */
  4846. bounces: number;
  4847. /** Defines the amplitude of the bounce */
  4848. bounciness: number;
  4849. /**
  4850. * Instantiates a bounce easing
  4851. * @see https://easings.net/#easeInBounce
  4852. * @param bounces Defines the number of bounces
  4853. * @param bounciness Defines the amplitude of the bounce
  4854. */
  4855. constructor(
  4856. /** Defines the number of bounces */
  4857. bounces?: number,
  4858. /** Defines the amplitude of the bounce */
  4859. bounciness?: number);
  4860. /** @hidden */
  4861. easeInCore(gradient: number): number;
  4862. }
  4863. /**
  4864. * Easing function with a power of 3 shape (see link below).
  4865. * @see https://easings.net/#easeInCubic
  4866. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4867. */
  4868. class CubicEase extends EasingFunction implements IEasingFunction {
  4869. /** @hidden */
  4870. easeInCore(gradient: number): number;
  4871. }
  4872. /**
  4873. * Easing function with an elastic shape (see link below).
  4874. * @see https://easings.net/#easeInElastic
  4875. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4876. */
  4877. class ElasticEase extends EasingFunction implements IEasingFunction {
  4878. /** Defines the number of oscillations*/
  4879. oscillations: number;
  4880. /** Defines the amplitude of the oscillations*/
  4881. springiness: number;
  4882. /**
  4883. * Instantiates an elastic easing function
  4884. * @see https://easings.net/#easeInElastic
  4885. * @param oscillations Defines the number of oscillations
  4886. * @param springiness Defines the amplitude of the oscillations
  4887. */
  4888. constructor(
  4889. /** Defines the number of oscillations*/
  4890. oscillations?: number,
  4891. /** Defines the amplitude of the oscillations*/
  4892. springiness?: number);
  4893. /** @hidden */
  4894. easeInCore(gradient: number): number;
  4895. }
  4896. /**
  4897. * Easing function with an exponential shape (see link below).
  4898. * @see https://easings.net/#easeInExpo
  4899. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4900. */
  4901. class ExponentialEase extends EasingFunction implements IEasingFunction {
  4902. /** Defines the exponent of the function */
  4903. exponent: number;
  4904. /**
  4905. * Instantiates an exponential easing function
  4906. * @see https://easings.net/#easeInExpo
  4907. * @param exponent Defines the exponent of the function
  4908. */
  4909. constructor(
  4910. /** Defines the exponent of the function */
  4911. exponent?: number);
  4912. /** @hidden */
  4913. easeInCore(gradient: number): number;
  4914. }
  4915. /**
  4916. * Easing function with a power shape (see link below).
  4917. * @see https://easings.net/#easeInQuad
  4918. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4919. */
  4920. class PowerEase extends EasingFunction implements IEasingFunction {
  4921. /** Defines the power of the function */
  4922. power: number;
  4923. /**
  4924. * Instantiates an power base easing function
  4925. * @see https://easings.net/#easeInQuad
  4926. * @param power Defines the power of the function
  4927. */
  4928. constructor(
  4929. /** Defines the power of the function */
  4930. power?: number);
  4931. /** @hidden */
  4932. easeInCore(gradient: number): number;
  4933. }
  4934. /**
  4935. * Easing function with a power of 2 shape (see link below).
  4936. * @see https://easings.net/#easeInQuad
  4937. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4938. */
  4939. class QuadraticEase extends EasingFunction implements IEasingFunction {
  4940. /** @hidden */
  4941. easeInCore(gradient: number): number;
  4942. }
  4943. /**
  4944. * Easing function with a power of 4 shape (see link below).
  4945. * @see https://easings.net/#easeInQuart
  4946. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4947. */
  4948. class QuarticEase extends EasingFunction implements IEasingFunction {
  4949. /** @hidden */
  4950. easeInCore(gradient: number): number;
  4951. }
  4952. /**
  4953. * Easing function with a power of 5 shape (see link below).
  4954. * @see https://easings.net/#easeInQuint
  4955. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4956. */
  4957. class QuinticEase extends EasingFunction implements IEasingFunction {
  4958. /** @hidden */
  4959. easeInCore(gradient: number): number;
  4960. }
  4961. /**
  4962. * Easing function with a sin shape (see link below).
  4963. * @see https://easings.net/#easeInSine
  4964. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4965. */
  4966. class SineEase extends EasingFunction implements IEasingFunction {
  4967. /** @hidden */
  4968. easeInCore(gradient: number): number;
  4969. }
  4970. /**
  4971. * Easing function with a bezier shape (see link below).
  4972. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  4973. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4974. */
  4975. class BezierCurveEase extends EasingFunction implements IEasingFunction {
  4976. /** Defines the x component of the start tangent in the bezier curve */
  4977. x1: number;
  4978. /** Defines the y component of the start tangent in the bezier curve */
  4979. y1: number;
  4980. /** Defines the x component of the end tangent in the bezier curve */
  4981. x2: number;
  4982. /** Defines the y component of the end tangent in the bezier curve */
  4983. y2: number;
  4984. /**
  4985. * Instantiates a bezier function
  4986. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  4987. * @param x1 Defines the x component of the start tangent in the bezier curve
  4988. * @param y1 Defines the y component of the start tangent in the bezier curve
  4989. * @param x2 Defines the x component of the end tangent in the bezier curve
  4990. * @param y2 Defines the y component of the end tangent in the bezier curve
  4991. */
  4992. constructor(
  4993. /** Defines the x component of the start tangent in the bezier curve */
  4994. x1?: number,
  4995. /** Defines the y component of the start tangent in the bezier curve */
  4996. y1?: number,
  4997. /** Defines the x component of the end tangent in the bezier curve */
  4998. x2?: number,
  4999. /** Defines the y component of the end tangent in the bezier curve */
  5000. y2?: number);
  5001. /** @hidden */
  5002. easeInCore(gradient: number): number;
  5003. }
  5004. }
  5005. declare module BABYLON {
  5006. /**
  5007. * Defines a runtime animation
  5008. */
  5009. class RuntimeAnimation {
  5010. private _events;
  5011. /**
  5012. * The current frame of the runtime animation
  5013. */
  5014. private _currentFrame;
  5015. /**
  5016. * The animation used by the runtime animation
  5017. */
  5018. private _animation;
  5019. /**
  5020. * The target of the runtime animation
  5021. */
  5022. private _target;
  5023. /**
  5024. * The initiating animatable
  5025. */
  5026. private _host;
  5027. /**
  5028. * The original value of the runtime animation
  5029. */
  5030. private _originalValue;
  5031. /**
  5032. * The original blend value of the runtime animation
  5033. */
  5034. private _originalBlendValue;
  5035. /**
  5036. * The offsets cache of the runtime animation
  5037. */
  5038. private _offsetsCache;
  5039. /**
  5040. * The high limits cache of the runtime animation
  5041. */
  5042. private _highLimitsCache;
  5043. /**
  5044. * Specifies if the runtime animation has been stopped
  5045. */
  5046. private _stopped;
  5047. /**
  5048. * The blending factor of the runtime animation
  5049. */
  5050. private _blendingFactor;
  5051. /**
  5052. * The BabylonJS scene
  5053. */
  5054. private _scene;
  5055. /**
  5056. * The current value of the runtime animation
  5057. */
  5058. private _currentValue;
  5059. /** @hidden */
  5060. _workValue: any;
  5061. /**
  5062. * The active target of the runtime animation
  5063. */
  5064. private _activeTarget;
  5065. /**
  5066. * The target path of the runtime animation
  5067. */
  5068. private _targetPath;
  5069. /**
  5070. * The weight of the runtime animation
  5071. */
  5072. private _weight;
  5073. /**
  5074. * The ratio offset of the runtime animation
  5075. */
  5076. private _ratioOffset;
  5077. /**
  5078. * The previous delay of the runtime animation
  5079. */
  5080. private _previousDelay;
  5081. /**
  5082. * The previous ratio of the runtime animation
  5083. */
  5084. private _previousRatio;
  5085. /**
  5086. * Gets the current frame of the runtime animation
  5087. */
  5088. readonly currentFrame: number;
  5089. /**
  5090. * Gets the weight of the runtime animation
  5091. */
  5092. readonly weight: number;
  5093. /**
  5094. * Gets the current value of the runtime animation
  5095. */
  5096. readonly currentValue: any;
  5097. /**
  5098. * Gets the target path of the runtime animation
  5099. */
  5100. readonly targetPath: string;
  5101. /**
  5102. * Gets the actual target of the runtime animation
  5103. */
  5104. readonly target: any;
  5105. /**
  5106. * Create a new RuntimeAnimation object
  5107. * @param target defines the target of the animation
  5108. * @param animation defines the source animation object
  5109. * @param scene defines the hosting scene
  5110. * @param host defines the initiating Animatable
  5111. */
  5112. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  5113. /**
  5114. * Gets the animation from the runtime animation
  5115. */
  5116. readonly animation: Animation;
  5117. /**
  5118. * Resets the runtime animation to the beginning
  5119. * @param restoreOriginal defines whether to restore the target property to the original value
  5120. */
  5121. reset(restoreOriginal?: boolean): void;
  5122. /**
  5123. * Specifies if the runtime animation is stopped
  5124. * @returns Boolean specifying if the runtime animation is stopped
  5125. */
  5126. isStopped(): boolean;
  5127. /**
  5128. * Disposes of the runtime animation
  5129. */
  5130. dispose(): void;
  5131. /**
  5132. * Interpolates the animation from the current frame
  5133. * @param currentFrame The frame to interpolate the animation to
  5134. * @param repeatCount The number of times that the animation should loop
  5135. * @param loopMode The type of looping mode to use
  5136. * @param offsetValue Animation offset value
  5137. * @param highLimitValue The high limit value
  5138. * @returns The interpolated value
  5139. */
  5140. private _interpolate;
  5141. /**
  5142. * Apply the interpolated value to the target
  5143. * @param currentValue defines the value computed by the animation
  5144. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  5145. */
  5146. setValue(currentValue: any, weight?: number): void;
  5147. private _setValue;
  5148. /**
  5149. * Gets the loop pmode of the runtime animation
  5150. * @returns Loop Mode
  5151. */
  5152. private _getCorrectLoopMode;
  5153. /**
  5154. * Move the current animation to a given frame
  5155. * @param frame defines the frame to move to
  5156. */
  5157. goToFrame(frame: number): void;
  5158. /**
  5159. * @hidden Internal use only
  5160. */
  5161. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  5162. /**
  5163. * Execute the current animation
  5164. * @param delay defines the delay to add to the current frame
  5165. * @param from defines the lower bound of the animation range
  5166. * @param to defines the upper bound of the animation range
  5167. * @param loop defines if the current animation must loop
  5168. * @param speedRatio defines the current speed ratio
  5169. * @param weight defines the weight of the animation (default is -1 so no weight)
  5170. * @returns a boolean indicating if the animation is running
  5171. */
  5172. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  5173. }
  5174. }
  5175. declare module BABYLON {
  5176. /**
  5177. * Class used to work with sound analyzer using fast fourier transform (FFT)
  5178. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5179. */
  5180. class Analyser {
  5181. /**
  5182. * Gets or sets the smoothing
  5183. * @ignorenaming
  5184. */
  5185. SMOOTHING: number;
  5186. /**
  5187. * Gets or sets the FFT table size
  5188. * @ignorenaming
  5189. */
  5190. FFT_SIZE: number;
  5191. /**
  5192. * Gets or sets the bar graph amplitude
  5193. * @ignorenaming
  5194. */
  5195. BARGRAPHAMPLITUDE: number;
  5196. /**
  5197. * Gets or sets the position of the debug canvas
  5198. * @ignorenaming
  5199. */
  5200. DEBUGCANVASPOS: {
  5201. x: number;
  5202. y: number;
  5203. };
  5204. /**
  5205. * Gets or sets the debug canvas size
  5206. * @ignorenaming
  5207. */
  5208. DEBUGCANVASSIZE: {
  5209. width: number;
  5210. height: number;
  5211. };
  5212. private _byteFreqs;
  5213. private _byteTime;
  5214. private _floatFreqs;
  5215. private _webAudioAnalyser;
  5216. private _debugCanvas;
  5217. private _debugCanvasContext;
  5218. private _scene;
  5219. private _registerFunc;
  5220. private _audioEngine;
  5221. /**
  5222. * Creates a new analyser
  5223. * @param scene defines hosting scene
  5224. */
  5225. constructor(scene: Scene);
  5226. /**
  5227. * Get the number of data values you will have to play with for the visualization
  5228. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  5229. * @returns a number
  5230. */
  5231. getFrequencyBinCount(): number;
  5232. /**
  5233. * Gets the current frequency data as a byte array
  5234. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  5235. * @returns a Uint8Array
  5236. */
  5237. getByteFrequencyData(): Uint8Array;
  5238. /**
  5239. * Gets the current waveform as a byte array
  5240. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  5241. * @returns a Uint8Array
  5242. */
  5243. getByteTimeDomainData(): Uint8Array;
  5244. /**
  5245. * Gets the current frequency data as a float array
  5246. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  5247. * @returns a Float32Array
  5248. */
  5249. getFloatFrequencyData(): Float32Array;
  5250. /**
  5251. * Renders the debug canvas
  5252. */
  5253. drawDebugCanvas(): void;
  5254. /**
  5255. * Stops rendering the debug canvas and removes it
  5256. */
  5257. stopDebugCanvas(): void;
  5258. /**
  5259. * Connects two audio nodes
  5260. * @param inputAudioNode defines first node to connect
  5261. * @param outputAudioNode defines second node to connect
  5262. */
  5263. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  5264. /**
  5265. * Releases all associated resources
  5266. */
  5267. dispose(): void;
  5268. }
  5269. }
  5270. declare module BABYLON {
  5271. /**
  5272. * This represents an audio engine and it is responsible
  5273. * to play, synchronize and analyse sounds throughout the application.
  5274. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5275. */
  5276. interface IAudioEngine extends IDisposable {
  5277. /**
  5278. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  5279. */
  5280. readonly canUseWebAudio: boolean;
  5281. /**
  5282. * Gets the current AudioContext if available.
  5283. */
  5284. readonly audioContext: Nullable<AudioContext>;
  5285. /**
  5286. * The master gain node defines the global audio volume of your audio engine.
  5287. */
  5288. readonly masterGain: GainNode;
  5289. /**
  5290. * Gets whether or not mp3 are supported by your browser.
  5291. */
  5292. readonly isMP3supported: boolean;
  5293. /**
  5294. * Gets whether or not ogg are supported by your browser.
  5295. */
  5296. readonly isOGGsupported: boolean;
  5297. /**
  5298. * Defines if Babylon should emit a warning if WebAudio is not supported.
  5299. * @ignoreNaming
  5300. */
  5301. WarnedWebAudioUnsupported: boolean;
  5302. /**
  5303. * Defines if the audio engine relies on a custom unlocked button.
  5304. * In this case, the embedded button will not be displayed.
  5305. */
  5306. useCustomUnlockedButton: boolean;
  5307. /**
  5308. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  5309. */
  5310. readonly unlocked: boolean;
  5311. /**
  5312. * Event raised when audio has been unlocked on the browser.
  5313. */
  5314. onAudioUnlockedObservable: Observable<AudioEngine>;
  5315. /**
  5316. * Event raised when audio has been locked on the browser.
  5317. */
  5318. onAudioLockedObservable: Observable<AudioEngine>;
  5319. /**
  5320. * Flags the audio engine in Locked state.
  5321. * This happens due to new browser policies preventing audio to autoplay.
  5322. */
  5323. lock(): void;
  5324. /**
  5325. * Unlocks the audio engine once a user action has been done on the dom.
  5326. * This is helpful to resume play once browser policies have been satisfied.
  5327. */
  5328. unlock(): void;
  5329. }
  5330. /**
  5331. * This represents the default audio engine used in babylon.
  5332. * It is responsible to play, synchronize and analyse sounds throughout the application.
  5333. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5334. */
  5335. class AudioEngine implements IAudioEngine {
  5336. private _audioContext;
  5337. private _audioContextInitialized;
  5338. private _muteButton;
  5339. private _hostElement;
  5340. /**
  5341. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  5342. */
  5343. canUseWebAudio: boolean;
  5344. /**
  5345. * The master gain node defines the global audio volume of your audio engine.
  5346. */
  5347. masterGain: GainNode;
  5348. /**
  5349. * Defines if Babylon should emit a warning if WebAudio is not supported.
  5350. * @ignoreNaming
  5351. */
  5352. WarnedWebAudioUnsupported: boolean;
  5353. /**
  5354. * Gets whether or not mp3 are supported by your browser.
  5355. */
  5356. isMP3supported: boolean;
  5357. /**
  5358. * Gets whether or not ogg are supported by your browser.
  5359. */
  5360. isOGGsupported: boolean;
  5361. /**
  5362. * Gets whether audio has been unlocked on the device.
  5363. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  5364. * a user interaction has happened.
  5365. */
  5366. unlocked: boolean;
  5367. /**
  5368. * Defines if the audio engine relies on a custom unlocked button.
  5369. * In this case, the embedded button will not be displayed.
  5370. */
  5371. useCustomUnlockedButton: boolean;
  5372. /**
  5373. * Event raised when audio has been unlocked on the browser.
  5374. */
  5375. onAudioUnlockedObservable: Observable<AudioEngine>;
  5376. /**
  5377. * Event raised when audio has been locked on the browser.
  5378. */
  5379. onAudioLockedObservable: Observable<AudioEngine>;
  5380. /**
  5381. * Gets the current AudioContext if available.
  5382. */
  5383. readonly audioContext: Nullable<AudioContext>;
  5384. private _connectedAnalyser;
  5385. /**
  5386. * Instantiates a new audio engine.
  5387. *
  5388. * There should be only one per page as some browsers restrict the number
  5389. * of audio contexts you can create.
  5390. * @param hostElement defines the host element where to display the mute icon if necessary
  5391. */
  5392. constructor(hostElement?: Nullable<HTMLElement>);
  5393. /**
  5394. * Flags the audio engine in Locked state.
  5395. * This happens due to new browser policies preventing audio to autoplay.
  5396. */
  5397. lock(): void;
  5398. /**
  5399. * Unlocks the audio engine once a user action has been done on the dom.
  5400. * This is helpful to resume play once browser policies have been satisfied.
  5401. */
  5402. unlock(): void;
  5403. private _resumeAudioContext;
  5404. private _initializeAudioContext;
  5405. private _tryToRun;
  5406. private _triggerRunningState;
  5407. private _triggerSuspendedState;
  5408. private _displayMuteButton;
  5409. private _moveButtonToTopLeft;
  5410. private _onResize;
  5411. private _hideMuteButton;
  5412. /**
  5413. * Destroy and release the resources associated with the audio ccontext.
  5414. */
  5415. dispose(): void;
  5416. /**
  5417. * Gets the global volume sets on the master gain.
  5418. * @returns the global volume if set or -1 otherwise
  5419. */
  5420. getGlobalVolume(): number;
  5421. /**
  5422. * Sets the global volume of your experience (sets on the master gain).
  5423. * @param newVolume Defines the new global volume of the application
  5424. */
  5425. setGlobalVolume(newVolume: number): void;
  5426. /**
  5427. * Connect the audio engine to an audio analyser allowing some amazing
  5428. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  5429. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  5430. * @param analyser The analyser to connect to the engine
  5431. */
  5432. connectToAnalyser(analyser: Analyser): void;
  5433. }
  5434. }
  5435. declare module BABYLON {
  5436. interface AbstractScene {
  5437. /**
  5438. * The list of sounds used in the scene.
  5439. */
  5440. sounds: Nullable<Array<Sound>>;
  5441. }
  5442. interface Scene {
  5443. /**
  5444. * @hidden
  5445. * Backing field
  5446. */
  5447. _mainSoundTrack: SoundTrack;
  5448. /**
  5449. * The main sound track played by the scene.
  5450. * It cotains your primary collection of sounds.
  5451. */
  5452. mainSoundTrack: SoundTrack;
  5453. /**
  5454. * The list of sound tracks added to the scene
  5455. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5456. */
  5457. soundTracks: Nullable<Array<SoundTrack>>;
  5458. /**
  5459. * Gets a sound using a given name
  5460. * @param name defines the name to search for
  5461. * @return the found sound or null if not found at all.
  5462. */
  5463. getSoundByName(name: string): Nullable<Sound>;
  5464. /**
  5465. * Gets or sets if audio support is enabled
  5466. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5467. */
  5468. audioEnabled: boolean;
  5469. /**
  5470. * Gets or sets if audio will be output to headphones
  5471. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5472. */
  5473. headphone: boolean;
  5474. }
  5475. /**
  5476. * Defines the sound scene component responsible to manage any sounds
  5477. * in a given scene.
  5478. */
  5479. class AudioSceneComponent implements ISceneSerializableComponent {
  5480. /**
  5481. * The component name helpfull to identify the component in the list of scene components.
  5482. */
  5483. readonly name: string;
  5484. /**
  5485. * The scene the component belongs to.
  5486. */
  5487. scene: Scene;
  5488. private _audioEnabled;
  5489. /**
  5490. * Gets whether audio is enabled or not.
  5491. * Please use related enable/disable method to switch state.
  5492. */
  5493. readonly audioEnabled: boolean;
  5494. private _headphone;
  5495. /**
  5496. * Gets whether audio is outputing to headphone or not.
  5497. * Please use the according Switch methods to change output.
  5498. */
  5499. readonly headphone: boolean;
  5500. /**
  5501. * Creates a new instance of the component for the given scene
  5502. * @param scene Defines the scene to register the component in
  5503. */
  5504. constructor(scene: Scene);
  5505. /**
  5506. * Registers the component in a given scene
  5507. */
  5508. register(): void;
  5509. /**
  5510. * Rebuilds the elements related to this component in case of
  5511. * context lost for instance.
  5512. */
  5513. rebuild(): void;
  5514. /**
  5515. * Serializes the component data to the specified json object
  5516. * @param serializationObject The object to serialize to
  5517. */
  5518. serialize(serializationObject: any): void;
  5519. /**
  5520. * Adds all the element from the container to the scene
  5521. * @param container the container holding the elements
  5522. */
  5523. addFromContainer(container: AbstractScene): void;
  5524. /**
  5525. * Removes all the elements in the container from the scene
  5526. * @param container contains the elements to remove
  5527. */
  5528. removeFromContainer(container: AbstractScene): void;
  5529. /**
  5530. * Disposes the component and the associated ressources.
  5531. */
  5532. dispose(): void;
  5533. /**
  5534. * Disables audio in the associated scene.
  5535. */
  5536. disableAudio(): void;
  5537. /**
  5538. * Enables audio in the associated scene.
  5539. */
  5540. enableAudio(): void;
  5541. /**
  5542. * Switch audio to headphone output.
  5543. */
  5544. switchAudioModeForHeadphones(): void;
  5545. /**
  5546. * Switch audio to normal speakers.
  5547. */
  5548. switchAudioModeForNormalSpeakers(): void;
  5549. private _afterRender;
  5550. }
  5551. }
  5552. declare module BABYLON {
  5553. /**
  5554. * Defines a sound that can be played in the application.
  5555. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  5556. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5557. */
  5558. class Sound {
  5559. /**
  5560. * The name of the sound in the scene.
  5561. */
  5562. name: string;
  5563. /**
  5564. * Does the sound autoplay once loaded.
  5565. */
  5566. autoplay: boolean;
  5567. /**
  5568. * Does the sound loop after it finishes playing once.
  5569. */
  5570. loop: boolean;
  5571. /**
  5572. * Does the sound use a custom attenuation curve to simulate the falloff
  5573. * happening when the source gets further away from the camera.
  5574. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  5575. */
  5576. useCustomAttenuation: boolean;
  5577. /**
  5578. * The sound track id this sound belongs to.
  5579. */
  5580. soundTrackId: number;
  5581. /**
  5582. * Is this sound currently played.
  5583. */
  5584. isPlaying: boolean;
  5585. /**
  5586. * Is this sound currently paused.
  5587. */
  5588. isPaused: boolean;
  5589. /**
  5590. * Does this sound enables spatial sound.
  5591. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5592. */
  5593. spatialSound: boolean;
  5594. /**
  5595. * Define the reference distance the sound should be heard perfectly.
  5596. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5597. */
  5598. refDistance: number;
  5599. /**
  5600. * Define the roll off factor of spatial sounds.
  5601. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5602. */
  5603. rolloffFactor: number;
  5604. /**
  5605. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  5606. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5607. */
  5608. maxDistance: number;
  5609. /**
  5610. * Define the distance attenuation model the sound will follow.
  5611. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5612. */
  5613. distanceModel: string;
  5614. /**
  5615. * @hidden
  5616. * Back Compat
  5617. **/
  5618. onended: () => any;
  5619. /**
  5620. * Observable event when the current playing sound finishes.
  5621. */
  5622. onEndedObservable: Observable<Sound>;
  5623. private _panningModel;
  5624. private _playbackRate;
  5625. private _streaming;
  5626. private _startTime;
  5627. private _startOffset;
  5628. private _position;
  5629. /** @hidden */
  5630. _positionInEmitterSpace: boolean;
  5631. private _localDirection;
  5632. private _volume;
  5633. private _isReadyToPlay;
  5634. private _isDirectional;
  5635. private _readyToPlayCallback;
  5636. private _audioBuffer;
  5637. private _soundSource;
  5638. private _streamingSource;
  5639. private _soundPanner;
  5640. private _soundGain;
  5641. private _inputAudioNode;
  5642. private _outputAudioNode;
  5643. private _coneInnerAngle;
  5644. private _coneOuterAngle;
  5645. private _coneOuterGain;
  5646. private _scene;
  5647. private _connectedTransformNode;
  5648. private _customAttenuationFunction;
  5649. private _registerFunc;
  5650. private _isOutputConnected;
  5651. private _htmlAudioElement;
  5652. private _urlType;
  5653. /**
  5654. * Create a sound and attach it to a scene
  5655. * @param name Name of your sound
  5656. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  5657. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  5658. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  5659. */
  5660. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  5661. /**
  5662. * Release the sound and its associated resources
  5663. */
  5664. dispose(): void;
  5665. /**
  5666. * Gets if the sounds is ready to be played or not.
  5667. * @returns true if ready, otherwise false
  5668. */
  5669. isReady(): boolean;
  5670. private _soundLoaded;
  5671. /**
  5672. * Sets the data of the sound from an audiobuffer
  5673. * @param audioBuffer The audioBuffer containing the data
  5674. */
  5675. setAudioBuffer(audioBuffer: AudioBuffer): void;
  5676. /**
  5677. * Updates the current sounds options such as maxdistance, loop...
  5678. * @param options A JSON object containing values named as the object properties
  5679. */
  5680. updateOptions(options: any): void;
  5681. private _createSpatialParameters;
  5682. private _updateSpatialParameters;
  5683. /**
  5684. * Switch the panning model to HRTF:
  5685. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  5686. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5687. */
  5688. switchPanningModelToHRTF(): void;
  5689. /**
  5690. * Switch the panning model to Equal Power:
  5691. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  5692. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5693. */
  5694. switchPanningModelToEqualPower(): void;
  5695. private _switchPanningModel;
  5696. /**
  5697. * Connect this sound to a sound track audio node like gain...
  5698. * @param soundTrackAudioNode the sound track audio node to connect to
  5699. */
  5700. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  5701. /**
  5702. * Transform this sound into a directional source
  5703. * @param coneInnerAngle Size of the inner cone in degree
  5704. * @param coneOuterAngle Size of the outer cone in degree
  5705. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  5706. */
  5707. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  5708. /**
  5709. * Gets or sets the inner angle for the directional cone.
  5710. */
  5711. /**
  5712. * Gets or sets the inner angle for the directional cone.
  5713. */
  5714. directionalConeInnerAngle: number;
  5715. /**
  5716. * Gets or sets the outer angle for the directional cone.
  5717. */
  5718. /**
  5719. * Gets or sets the outer angle for the directional cone.
  5720. */
  5721. directionalConeOuterAngle: number;
  5722. /**
  5723. * Sets the position of the emitter if spatial sound is enabled
  5724. * @param newPosition Defines the new posisiton
  5725. */
  5726. setPosition(newPosition: Vector3): void;
  5727. /**
  5728. * Sets the local direction of the emitter if spatial sound is enabled
  5729. * @param newLocalDirection Defines the new local direction
  5730. */
  5731. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  5732. private _updateDirection;
  5733. /** @hidden */
  5734. updateDistanceFromListener(): void;
  5735. /**
  5736. * Sets a new custom attenuation function for the sound.
  5737. * @param callback Defines the function used for the attenuation
  5738. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  5739. */
  5740. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  5741. /**
  5742. * Play the sound
  5743. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  5744. * @param offset (optional) Start the sound setting it at a specific time
  5745. */
  5746. play(time?: number, offset?: number): void;
  5747. private _onended;
  5748. /**
  5749. * Stop the sound
  5750. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  5751. */
  5752. stop(time?: number): void;
  5753. /**
  5754. * Put the sound in pause
  5755. */
  5756. pause(): void;
  5757. /**
  5758. * Sets a dedicated volume for this sounds
  5759. * @param newVolume Define the new volume of the sound
  5760. * @param time Define in how long the sound should be at this value
  5761. */
  5762. setVolume(newVolume: number, time?: number): void;
  5763. /**
  5764. * Set the sound play back rate
  5765. * @param newPlaybackRate Define the playback rate the sound should be played at
  5766. */
  5767. setPlaybackRate(newPlaybackRate: number): void;
  5768. /**
  5769. * Gets the volume of the sound.
  5770. * @returns the volume of the sound
  5771. */
  5772. getVolume(): number;
  5773. /**
  5774. * Attach the sound to a dedicated mesh
  5775. * @param transformNode The transform node to connect the sound with
  5776. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  5777. */
  5778. attachToMesh(transformNode: TransformNode): void;
  5779. /**
  5780. * Detach the sound from the previously attached mesh
  5781. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  5782. */
  5783. detachFromMesh(): void;
  5784. private _onRegisterAfterWorldMatrixUpdate;
  5785. /**
  5786. * Clone the current sound in the scene.
  5787. * @returns the new sound clone
  5788. */
  5789. clone(): Nullable<Sound>;
  5790. /**
  5791. * Gets the current underlying audio buffer containing the data
  5792. * @returns the audio buffer
  5793. */
  5794. getAudioBuffer(): Nullable<AudioBuffer>;
  5795. /**
  5796. * Serializes the Sound in a JSON representation
  5797. * @returns the JSON representation of the sound
  5798. */
  5799. serialize(): any;
  5800. /**
  5801. * Parse a JSON representation of a sound to innstantiate in a given scene
  5802. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  5803. * @param scene Define the scene the new parsed sound should be created in
  5804. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  5805. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  5806. * @returns the newly parsed sound
  5807. */
  5808. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  5809. }
  5810. }
  5811. declare module BABYLON {
  5812. /**
  5813. * Options allowed during the creation of a sound track.
  5814. */
  5815. interface ISoundTrackOptions {
  5816. /**
  5817. * The volume the sound track should take during creation
  5818. */
  5819. volume?: number;
  5820. /**
  5821. * Define if the sound track is the main sound track of the scene
  5822. */
  5823. mainTrack?: boolean;
  5824. }
  5825. /**
  5826. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  5827. * It will be also used in a future release to apply effects on a specific track.
  5828. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  5829. */
  5830. class SoundTrack {
  5831. /**
  5832. * The unique identifier of the sound track in the scene.
  5833. */
  5834. id: number;
  5835. /**
  5836. * The list of sounds included in the sound track.
  5837. */
  5838. soundCollection: Array<Sound>;
  5839. private _outputAudioNode;
  5840. private _scene;
  5841. private _isMainTrack;
  5842. private _connectedAnalyser;
  5843. private _options;
  5844. private _isInitialized;
  5845. /**
  5846. * Creates a new sound track.
  5847. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  5848. * @param scene Define the scene the sound track belongs to
  5849. * @param options
  5850. */
  5851. constructor(scene: Scene, options?: ISoundTrackOptions);
  5852. private _initializeSoundTrackAudioGraph;
  5853. /**
  5854. * Release the sound track and its associated resources
  5855. */
  5856. dispose(): void;
  5857. /**
  5858. * Adds a sound to this sound track
  5859. * @param sound define the cound to add
  5860. * @ignoreNaming
  5861. */
  5862. AddSound(sound: Sound): void;
  5863. /**
  5864. * Removes a sound to this sound track
  5865. * @param sound define the cound to remove
  5866. * @ignoreNaming
  5867. */
  5868. RemoveSound(sound: Sound): void;
  5869. /**
  5870. * Set a global volume for the full sound track.
  5871. * @param newVolume Define the new volume of the sound track
  5872. */
  5873. setVolume(newVolume: number): void;
  5874. /**
  5875. * Switch the panning model to HRTF:
  5876. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  5877. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5878. */
  5879. switchPanningModelToHRTF(): void;
  5880. /**
  5881. * Switch the panning model to Equal Power:
  5882. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  5883. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5884. */
  5885. switchPanningModelToEqualPower(): void;
  5886. /**
  5887. * Connect the sound track to an audio analyser allowing some amazing
  5888. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  5889. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  5890. * @param analyser The analyser to connect to the engine
  5891. */
  5892. connectToAnalyser(analyser: Analyser): void;
  5893. }
  5894. }
  5895. declare module BABYLON {
  5896. /**
  5897. * Wraps one or more Sound objects and selects one with random weight for playback.
  5898. */
  5899. class WeightedSound {
  5900. /** When true a Sound will be selected and played when the current playing Sound completes. */
  5901. loop: boolean;
  5902. private _coneInnerAngle;
  5903. private _coneOuterAngle;
  5904. private _volume;
  5905. /** A Sound is currently playing. */
  5906. isPlaying: boolean;
  5907. /** A Sound is currently paused. */
  5908. isPaused: boolean;
  5909. private _sounds;
  5910. private _weights;
  5911. private _currentIndex?;
  5912. /**
  5913. * Creates a new WeightedSound from the list of sounds given.
  5914. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  5915. * @param sounds Array of Sounds that will be selected from.
  5916. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  5917. */
  5918. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  5919. /**
  5920. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  5921. */
  5922. /**
  5923. * The size of cone in degress for a directional sound in which there will be no attenuation.
  5924. */
  5925. directionalConeInnerAngle: number;
  5926. /**
  5927. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  5928. * Listener angles between innerAngle and outerAngle will falloff linearly.
  5929. */
  5930. /**
  5931. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  5932. * Listener angles between innerAngle and outerAngle will falloff linearly.
  5933. */
  5934. directionalConeOuterAngle: number;
  5935. /**
  5936. * Playback volume.
  5937. */
  5938. /**
  5939. * Playback volume.
  5940. */
  5941. volume: number;
  5942. private _onended;
  5943. /**
  5944. * Suspend playback
  5945. */
  5946. pause(): void;
  5947. /**
  5948. * Stop playback
  5949. */
  5950. stop(): void;
  5951. /**
  5952. * Start playback.
  5953. * @param startOffset Position the clip head at a specific time in seconds.
  5954. */
  5955. play(startOffset?: number): void;
  5956. }
  5957. }
  5958. declare module BABYLON {
  5959. /**
  5960. * Interface used to define a behavior
  5961. */
  5962. interface Behavior<T> {
  5963. /** gets or sets behavior's name */
  5964. name: string;
  5965. /**
  5966. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5967. */
  5968. init(): void;
  5969. /**
  5970. * Called when the behavior is attached to a target
  5971. * @param target defines the target where the behavior is attached to
  5972. */
  5973. attach(target: T): void;
  5974. /**
  5975. * Called when the behavior is detached from its target
  5976. */
  5977. detach(): void;
  5978. }
  5979. /**
  5980. * Interface implemented by classes supporting behaviors
  5981. */
  5982. interface IBehaviorAware<T> {
  5983. /**
  5984. * Attach a behavior
  5985. * @param behavior defines the behavior to attach
  5986. * @returns the current host
  5987. */
  5988. addBehavior(behavior: Behavior<T>): T;
  5989. /**
  5990. * Remove a behavior from the current object
  5991. * @param behavior defines the behavior to detach
  5992. * @returns the current host
  5993. */
  5994. removeBehavior(behavior: Behavior<T>): T;
  5995. /**
  5996. * Gets a behavior using its name to search
  5997. * @param name defines the name to search
  5998. * @returns the behavior or null if not found
  5999. */
  6000. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6001. }
  6002. }
  6003. declare module BABYLON {
  6004. /**
  6005. * Class used to store bone information
  6006. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  6007. */
  6008. class Bone extends Node {
  6009. /**
  6010. * defines the bone name
  6011. */
  6012. name: string;
  6013. private static _tmpVecs;
  6014. private static _tmpQuat;
  6015. private static _tmpMats;
  6016. /**
  6017. * Gets the list of child bones
  6018. */
  6019. children: Bone[];
  6020. /** Gets the animations associated with this bone */
  6021. animations: Animation[];
  6022. /**
  6023. * Gets or sets bone length
  6024. */
  6025. length: number;
  6026. /**
  6027. * @hidden Internal only
  6028. * Set this value to map this bone to a different index in the transform matrices
  6029. * Set this value to -1 to exclude the bone from the transform matrices
  6030. */
  6031. _index: Nullable<number>;
  6032. private _skeleton;
  6033. private _localMatrix;
  6034. private _restPose;
  6035. private _baseMatrix;
  6036. private _absoluteTransform;
  6037. private _invertedAbsoluteTransform;
  6038. private _parent;
  6039. private _scalingDeterminant;
  6040. private _worldTransform;
  6041. private _localScaling;
  6042. private _localRotation;
  6043. private _localPosition;
  6044. private _needToDecompose;
  6045. private _needToCompose;
  6046. /** @hidden */
  6047. _linkedTransformNode: Nullable<TransformNode>;
  6048. /** @hidden */
  6049. /** @hidden */
  6050. _matrix: Matrix;
  6051. /**
  6052. * Create a new bone
  6053. * @param name defines the bone name
  6054. * @param skeleton defines the parent skeleton
  6055. * @param parentBone defines the parent (can be null if the bone is the root)
  6056. * @param localMatrix defines the local matrix
  6057. * @param restPose defines the rest pose matrix
  6058. * @param baseMatrix defines the base matrix
  6059. * @param index defines index of the bone in the hiearchy
  6060. */
  6061. constructor(
  6062. /**
  6063. * defines the bone name
  6064. */
  6065. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  6066. /**
  6067. * Gets the parent skeleton
  6068. * @returns a skeleton
  6069. */
  6070. getSkeleton(): Skeleton;
  6071. /**
  6072. * Gets parent bone
  6073. * @returns a bone or null if the bone is the root of the bone hierarchy
  6074. */
  6075. getParent(): Nullable<Bone>;
  6076. /**
  6077. * Sets the parent bone
  6078. * @param parent defines the parent (can be null if the bone is the root)
  6079. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  6080. */
  6081. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  6082. /**
  6083. * Gets the local matrix
  6084. * @returns a matrix
  6085. */
  6086. getLocalMatrix(): Matrix;
  6087. /**
  6088. * Gets the base matrix (initial matrix which remains unchanged)
  6089. * @returns a matrix
  6090. */
  6091. getBaseMatrix(): Matrix;
  6092. /**
  6093. * Gets the rest pose matrix
  6094. * @returns a matrix
  6095. */
  6096. getRestPose(): Matrix;
  6097. /**
  6098. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  6099. */
  6100. getWorldMatrix(): Matrix;
  6101. /**
  6102. * Sets the local matrix to rest pose matrix
  6103. */
  6104. returnToRest(): void;
  6105. /**
  6106. * Gets the inverse of the absolute transform matrix.
  6107. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  6108. * @returns a matrix
  6109. */
  6110. getInvertedAbsoluteTransform(): Matrix;
  6111. /**
  6112. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  6113. * @returns a matrix
  6114. */
  6115. getAbsoluteTransform(): Matrix;
  6116. /**
  6117. * Links with the given transform node.
  6118. * The local matrix of this bone is copied from the transform node every frame.
  6119. * @param transformNode defines the transform node to link to
  6120. */
  6121. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  6122. /** Gets or sets current position (in local space) */
  6123. position: Vector3;
  6124. /** Gets or sets current rotation (in local space) */
  6125. rotation: Vector3;
  6126. /** Gets or sets current rotation quaternion (in local space) */
  6127. rotationQuaternion: Quaternion;
  6128. /** Gets or sets current scaling (in local space) */
  6129. scaling: Vector3;
  6130. /**
  6131. * Gets the animation properties override
  6132. */
  6133. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  6134. private _decompose;
  6135. private _compose;
  6136. /**
  6137. * Update the base and local matrices
  6138. * @param matrix defines the new base or local matrix
  6139. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  6140. * @param updateLocalMatrix defines if the local matrix should be updated
  6141. */
  6142. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  6143. /** @hidden */
  6144. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  6145. /**
  6146. * Flag the bone as dirty (Forcing it to update everything)
  6147. */
  6148. markAsDirty(): void;
  6149. private _markAsDirtyAndCompose;
  6150. private _markAsDirtyAndDecompose;
  6151. /**
  6152. * Copy an animation range from another bone
  6153. * @param source defines the source bone
  6154. * @param rangeName defines the range name to copy
  6155. * @param frameOffset defines the frame offset
  6156. * @param rescaleAsRequired defines if rescaling must be applied if required
  6157. * @param skelDimensionsRatio defines the scaling ratio
  6158. * @returns true if operation was successful
  6159. */
  6160. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired?: boolean, skelDimensionsRatio?: Nullable<Vector3>): boolean;
  6161. /**
  6162. * Translate the bone in local or world space
  6163. * @param vec The amount to translate the bone
  6164. * @param space The space that the translation is in
  6165. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6166. */
  6167. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  6168. /**
  6169. * Set the postion of the bone in local or world space
  6170. * @param position The position to set the bone
  6171. * @param space The space that the position is in
  6172. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6173. */
  6174. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  6175. /**
  6176. * Set the absolute position of the bone (world space)
  6177. * @param position The position to set the bone
  6178. * @param mesh The mesh that this bone is attached to
  6179. */
  6180. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  6181. /**
  6182. * Scale the bone on the x, y and z axes (in local space)
  6183. * @param x The amount to scale the bone on the x axis
  6184. * @param y The amount to scale the bone on the y axis
  6185. * @param z The amount to scale the bone on the z axis
  6186. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  6187. */
  6188. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  6189. /**
  6190. * Set the bone scaling in local space
  6191. * @param scale defines the scaling vector
  6192. */
  6193. setScale(scale: Vector3): void;
  6194. /**
  6195. * Gets the current scaling in local space
  6196. * @returns the current scaling vector
  6197. */
  6198. getScale(): Vector3;
  6199. /**
  6200. * Gets the current scaling in local space and stores it in a target vector
  6201. * @param result defines the target vector
  6202. */
  6203. getScaleToRef(result: Vector3): void;
  6204. /**
  6205. * Set the yaw, pitch, and roll of the bone in local or world space
  6206. * @param yaw The rotation of the bone on the y axis
  6207. * @param pitch The rotation of the bone on the x axis
  6208. * @param roll The rotation of the bone on the z axis
  6209. * @param space The space that the axes of rotation are in
  6210. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6211. */
  6212. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  6213. /**
  6214. * Add a rotation to the bone on an axis in local or world space
  6215. * @param axis The axis to rotate the bone on
  6216. * @param amount The amount to rotate the bone
  6217. * @param space The space that the axis is in
  6218. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6219. */
  6220. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  6221. /**
  6222. * Set the rotation of the bone to a particular axis angle in local or world space
  6223. * @param axis The axis to rotate the bone on
  6224. * @param angle The angle that the bone should be rotated to
  6225. * @param space The space that the axis is in
  6226. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6227. */
  6228. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  6229. /**
  6230. * Set the euler rotation of the bone in local of world space
  6231. * @param rotation The euler rotation that the bone should be set to
  6232. * @param space The space that the rotation is in
  6233. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6234. */
  6235. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  6236. /**
  6237. * Set the quaternion rotation of the bone in local of world space
  6238. * @param quat The quaternion rotation that the bone should be set to
  6239. * @param space The space that the rotation is in
  6240. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6241. */
  6242. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  6243. /**
  6244. * Set the rotation matrix of the bone in local of world space
  6245. * @param rotMat The rotation matrix that the bone should be set to
  6246. * @param space The space that the rotation is in
  6247. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6248. */
  6249. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  6250. private _rotateWithMatrix;
  6251. private _getNegativeRotationToRef;
  6252. /**
  6253. * Get the position of the bone in local or world space
  6254. * @param space The space that the returned position is in
  6255. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6256. * @returns The position of the bone
  6257. */
  6258. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  6259. /**
  6260. * Copy the position of the bone to a vector3 in local or world space
  6261. * @param space The space that the returned position is in
  6262. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6263. * @param result The vector3 to copy the position to
  6264. */
  6265. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  6266. /**
  6267. * Get the absolute position of the bone (world space)
  6268. * @param mesh The mesh that this bone is attached to
  6269. * @returns The absolute position of the bone
  6270. */
  6271. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  6272. /**
  6273. * Copy the absolute position of the bone (world space) to the result param
  6274. * @param mesh The mesh that this bone is attached to
  6275. * @param result The vector3 to copy the absolute position to
  6276. */
  6277. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  6278. /**
  6279. * Compute the absolute transforms of this bone and its children
  6280. */
  6281. computeAbsoluteTransforms(): void;
  6282. /**
  6283. * Get the world direction from an axis that is in the local space of the bone
  6284. * @param localAxis The local direction that is used to compute the world direction
  6285. * @param mesh The mesh that this bone is attached to
  6286. * @returns The world direction
  6287. */
  6288. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  6289. /**
  6290. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  6291. * @param localAxis The local direction that is used to compute the world direction
  6292. * @param mesh The mesh that this bone is attached to
  6293. * @param result The vector3 that the world direction will be copied to
  6294. */
  6295. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6296. /**
  6297. * Get the euler rotation of the bone in local or world space
  6298. * @param space The space that the rotation should be in
  6299. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6300. * @returns The euler rotation
  6301. */
  6302. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  6303. /**
  6304. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  6305. * @param space The space that the rotation should be in
  6306. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6307. * @param result The vector3 that the rotation should be copied to
  6308. */
  6309. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6310. /**
  6311. * Get the quaternion rotation of the bone in either local or world space
  6312. * @param space The space that the rotation should be in
  6313. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6314. * @returns The quaternion rotation
  6315. */
  6316. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  6317. /**
  6318. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  6319. * @param space The space that the rotation should be in
  6320. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6321. * @param result The quaternion that the rotation should be copied to
  6322. */
  6323. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  6324. /**
  6325. * Get the rotation matrix of the bone in local or world space
  6326. * @param space The space that the rotation should be in
  6327. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6328. * @returns The rotation matrix
  6329. */
  6330. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  6331. /**
  6332. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  6333. * @param space The space that the rotation should be in
  6334. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6335. * @param result The quaternion that the rotation should be copied to
  6336. */
  6337. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  6338. /**
  6339. * Get the world position of a point that is in the local space of the bone
  6340. * @param position The local position
  6341. * @param mesh The mesh that this bone is attached to
  6342. * @returns The world position
  6343. */
  6344. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  6345. /**
  6346. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  6347. * @param position The local position
  6348. * @param mesh The mesh that this bone is attached to
  6349. * @param result The vector3 that the world position should be copied to
  6350. */
  6351. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6352. /**
  6353. * Get the local position of a point that is in world space
  6354. * @param position The world position
  6355. * @param mesh The mesh that this bone is attached to
  6356. * @returns The local position
  6357. */
  6358. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  6359. /**
  6360. * Get the local position of a point that is in world space and copy it to the result param
  6361. * @param position The world position
  6362. * @param mesh The mesh that this bone is attached to
  6363. * @param result The vector3 that the local position should be copied to
  6364. */
  6365. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6366. }
  6367. }
  6368. declare module BABYLON {
  6369. /**
  6370. * Class used to apply inverse kinematics to bones
  6371. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  6372. */
  6373. class BoneIKController {
  6374. private static _tmpVecs;
  6375. private static _tmpQuat;
  6376. private static _tmpMats;
  6377. /**
  6378. * Gets or sets the target mesh
  6379. */
  6380. targetMesh: AbstractMesh;
  6381. /** Gets or sets the mesh used as pole */
  6382. poleTargetMesh: AbstractMesh;
  6383. /**
  6384. * Gets or sets the bone used as pole
  6385. */
  6386. poleTargetBone: Nullable<Bone>;
  6387. /**
  6388. * Gets or sets the target position
  6389. */
  6390. targetPosition: Vector3;
  6391. /**
  6392. * Gets or sets the pole target position
  6393. */
  6394. poleTargetPosition: Vector3;
  6395. /**
  6396. * Gets or sets the pole target local offset
  6397. */
  6398. poleTargetLocalOffset: Vector3;
  6399. /**
  6400. * Gets or sets the pole angle
  6401. */
  6402. poleAngle: number;
  6403. /**
  6404. * Gets or sets the mesh associated with the controller
  6405. */
  6406. mesh: AbstractMesh;
  6407. /**
  6408. * The amount to slerp (spherical linear interpolation) to the target. Set this to a value between 0 and 1 (a value of 1 disables slerp)
  6409. */
  6410. slerpAmount: number;
  6411. private _bone1Quat;
  6412. private _bone1Mat;
  6413. private _bone2Ang;
  6414. private _bone1;
  6415. private _bone2;
  6416. private _bone1Length;
  6417. private _bone2Length;
  6418. private _maxAngle;
  6419. private _maxReach;
  6420. private _rightHandedSystem;
  6421. private _bendAxis;
  6422. private _slerping;
  6423. private _adjustRoll;
  6424. /**
  6425. * Gets or sets maximum allowed angle
  6426. */
  6427. maxAngle: number;
  6428. /**
  6429. * Creates a new BoneIKController
  6430. * @param mesh defines the mesh to control
  6431. * @param bone defines the bone to control
  6432. * @param options defines options to set up the controller
  6433. */
  6434. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  6435. targetMesh?: AbstractMesh;
  6436. poleTargetMesh?: AbstractMesh;
  6437. poleTargetBone?: Bone;
  6438. poleTargetLocalOffset?: Vector3;
  6439. poleAngle?: number;
  6440. bendAxis?: Vector3;
  6441. maxAngle?: number;
  6442. slerpAmount?: number;
  6443. });
  6444. private _setMaxAngle;
  6445. /**
  6446. * Force the controller to update the bones
  6447. */
  6448. update(): void;
  6449. }
  6450. }
  6451. declare module BABYLON {
  6452. /**
  6453. * Class used to make a bone look toward a point in space
  6454. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  6455. */
  6456. class BoneLookController {
  6457. private static _tmpVecs;
  6458. private static _tmpQuat;
  6459. private static _tmpMats;
  6460. /**
  6461. * The target Vector3 that the bone will look at
  6462. */
  6463. target: Vector3;
  6464. /**
  6465. * The mesh that the bone is attached to
  6466. */
  6467. mesh: AbstractMesh;
  6468. /**
  6469. * The bone that will be looking to the target
  6470. */
  6471. bone: Bone;
  6472. /**
  6473. * The up axis of the coordinate system that is used when the bone is rotated
  6474. */
  6475. upAxis: Vector3;
  6476. /**
  6477. * The space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD
  6478. */
  6479. upAxisSpace: Space;
  6480. /**
  6481. * Used to make an adjustment to the yaw of the bone
  6482. */
  6483. adjustYaw: number;
  6484. /**
  6485. * Used to make an adjustment to the pitch of the bone
  6486. */
  6487. adjustPitch: number;
  6488. /**
  6489. * Used to make an adjustment to the roll of the bone
  6490. */
  6491. adjustRoll: number;
  6492. /**
  6493. * The amount to slerp (spherical linear interpolation) to the target. Set this to a value between 0 and 1 (a value of 1 disables slerp)
  6494. */
  6495. slerpAmount: number;
  6496. private _minYaw;
  6497. private _maxYaw;
  6498. private _minPitch;
  6499. private _maxPitch;
  6500. private _minYawSin;
  6501. private _minYawCos;
  6502. private _maxYawSin;
  6503. private _maxYawCos;
  6504. private _midYawConstraint;
  6505. private _minPitchTan;
  6506. private _maxPitchTan;
  6507. private _boneQuat;
  6508. private _slerping;
  6509. private _transformYawPitch;
  6510. private _transformYawPitchInv;
  6511. private _firstFrameSkipped;
  6512. private _yawRange;
  6513. private _fowardAxis;
  6514. /**
  6515. * Gets or sets the minimum yaw angle that the bone can look to
  6516. */
  6517. minYaw: number;
  6518. /**
  6519. * Gets or sets the maximum yaw angle that the bone can look to
  6520. */
  6521. maxYaw: number;
  6522. /**
  6523. * Gets or sets the minimum pitch angle that the bone can look to
  6524. */
  6525. minPitch: number;
  6526. /**
  6527. * Gets or sets the maximum pitch angle that the bone can look to
  6528. */
  6529. maxPitch: number;
  6530. /**
  6531. * Create a BoneLookController
  6532. * @param mesh the mesh that the bone belongs to
  6533. * @param bone the bone that will be looking to the target
  6534. * @param target the target Vector3 to look at
  6535. * @param settings optional settings:
  6536. * * maxYaw: the maximum angle the bone will yaw to
  6537. * * minYaw: the minimum angle the bone will yaw to
  6538. * * maxPitch: the maximum angle the bone will pitch to
  6539. * * minPitch: the minimum angle the bone will yaw to
  6540. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  6541. * * upAxis: the up axis of the coordinate system
  6542. * * upAxisSpace: the space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD.
  6543. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  6544. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  6545. * * adjustYaw: used to make an adjustment to the yaw of the bone
  6546. * * adjustPitch: used to make an adjustment to the pitch of the bone
  6547. * * adjustRoll: used to make an adjustment to the roll of the bone
  6548. **/
  6549. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  6550. maxYaw?: number;
  6551. minYaw?: number;
  6552. maxPitch?: number;
  6553. minPitch?: number;
  6554. slerpAmount?: number;
  6555. upAxis?: Vector3;
  6556. upAxisSpace?: Space;
  6557. yawAxis?: Vector3;
  6558. pitchAxis?: Vector3;
  6559. adjustYaw?: number;
  6560. adjustPitch?: number;
  6561. adjustRoll?: number;
  6562. });
  6563. /**
  6564. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  6565. */
  6566. update(): void;
  6567. private _getAngleDiff;
  6568. private _getAngleBetween;
  6569. private _isAngleBetween;
  6570. }
  6571. }
  6572. declare module BABYLON {
  6573. /**
  6574. * Class used to handle skinning animations
  6575. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  6576. */
  6577. class Skeleton implements IAnimatable {
  6578. /** defines the skeleton name */
  6579. name: string;
  6580. /** defines the skeleton Id */
  6581. id: string;
  6582. /**
  6583. * Defines the list of child bones
  6584. */
  6585. bones: Bone[];
  6586. /**
  6587. * Defines an estimate of the dimension of the skeleton at rest
  6588. */
  6589. dimensionsAtRest: Vector3;
  6590. /**
  6591. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  6592. */
  6593. needInitialSkinMatrix: boolean;
  6594. /**
  6595. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  6596. */
  6597. overrideMesh: Nullable<AbstractMesh>;
  6598. /**
  6599. * Gets the list of animations attached to this skeleton
  6600. */
  6601. animations: Array<Animation>;
  6602. private _scene;
  6603. private _isDirty;
  6604. private _transformMatrices;
  6605. private _transformMatrixTexture;
  6606. private _meshesWithPoseMatrix;
  6607. private _animatables;
  6608. private _identity;
  6609. private _synchronizedWithMesh;
  6610. private _ranges;
  6611. private _lastAbsoluteTransformsUpdateId;
  6612. private _canUseTextureForBones;
  6613. /** @hidden */
  6614. _numBonesWithLinkedTransformNode: number;
  6615. /**
  6616. * Specifies if the skeleton should be serialized
  6617. */
  6618. doNotSerialize: boolean;
  6619. /**
  6620. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  6621. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  6622. */
  6623. useTextureToStoreBoneMatrices: boolean;
  6624. private _animationPropertiesOverride;
  6625. /**
  6626. * Gets or sets the animation properties override
  6627. */
  6628. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  6629. /**
  6630. * An observable triggered before computing the skeleton's matrices
  6631. */
  6632. onBeforeComputeObservable: Observable<Skeleton>;
  6633. /**
  6634. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  6635. */
  6636. readonly isUsingTextureForMatrices: boolean;
  6637. /**
  6638. * Creates a new skeleton
  6639. * @param name defines the skeleton name
  6640. * @param id defines the skeleton Id
  6641. * @param scene defines the hosting scene
  6642. */
  6643. constructor(
  6644. /** defines the skeleton name */
  6645. name: string,
  6646. /** defines the skeleton Id */
  6647. id: string, scene: Scene);
  6648. /**
  6649. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  6650. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  6651. * @returns a Float32Array containing matrices data
  6652. */
  6653. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  6654. /**
  6655. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  6656. * @returns a raw texture containing the data
  6657. */
  6658. getTransformMatrixTexture(): Nullable<RawTexture>;
  6659. /**
  6660. * Gets the current hosting scene
  6661. * @returns a scene object
  6662. */
  6663. getScene(): Scene;
  6664. /**
  6665. * Gets a string representing the current skeleton data
  6666. * @param fullDetails defines a boolean indicating if we want a verbose version
  6667. * @returns a string representing the current skeleton data
  6668. */
  6669. toString(fullDetails?: boolean): string;
  6670. /**
  6671. * Get bone's index searching by name
  6672. * @param name defines bone's name to search for
  6673. * @return the indice of the bone. Returns -1 if not found
  6674. */
  6675. getBoneIndexByName(name: string): number;
  6676. /**
  6677. * Creater a new animation range
  6678. * @param name defines the name of the range
  6679. * @param from defines the start key
  6680. * @param to defines the end key
  6681. */
  6682. createAnimationRange(name: string, from: number, to: number): void;
  6683. /**
  6684. * Delete a specific animation range
  6685. * @param name defines the name of the range
  6686. * @param deleteFrames defines if frames must be removed as well
  6687. */
  6688. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  6689. /**
  6690. * Gets a specific animation range
  6691. * @param name defines the name of the range to look for
  6692. * @returns the requested animation range or null if not found
  6693. */
  6694. getAnimationRange(name: string): Nullable<AnimationRange>;
  6695. /**
  6696. * Gets the list of all animation ranges defined on this skeleton
  6697. * @returns an array
  6698. */
  6699. getAnimationRanges(): Nullable<AnimationRange>[];
  6700. /**
  6701. * Copy animation range from a source skeleton.
  6702. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  6703. * @param source defines the source skeleton
  6704. * @param name defines the name of the range to copy
  6705. * @param rescaleAsRequired defines if rescaling must be applied if required
  6706. * @returns true if operation was successful
  6707. */
  6708. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  6709. /**
  6710. * Forces the skeleton to go to rest pose
  6711. */
  6712. returnToRest(): void;
  6713. private _getHighestAnimationFrame;
  6714. /**
  6715. * Begin a specific animation range
  6716. * @param name defines the name of the range to start
  6717. * @param loop defines if looping must be turned on (false by default)
  6718. * @param speedRatio defines the speed ratio to apply (1 by default)
  6719. * @param onAnimationEnd defines a callback which will be called when animation will end
  6720. * @returns a new animatable
  6721. */
  6722. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  6723. /** @hidden */
  6724. _markAsDirty(): void;
  6725. /** @hidden */
  6726. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  6727. /** @hidden */
  6728. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  6729. private _computeTransformMatrices;
  6730. /**
  6731. * Build all resources required to render a skeleton
  6732. */
  6733. prepare(): void;
  6734. /**
  6735. * Gets the list of animatables currently running for this skeleton
  6736. * @returns an array of animatables
  6737. */
  6738. getAnimatables(): IAnimatable[];
  6739. /**
  6740. * Clone the current skeleton
  6741. * @param name defines the name of the new skeleton
  6742. * @param id defines the id of the enw skeleton
  6743. * @returns the new skeleton
  6744. */
  6745. clone(name: string, id: string): Skeleton;
  6746. /**
  6747. * Enable animation blending for this skeleton
  6748. * @param blendingSpeed defines the blending speed to apply
  6749. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  6750. */
  6751. enableBlending(blendingSpeed?: number): void;
  6752. /**
  6753. * Releases all resources associated with the current skeleton
  6754. */
  6755. dispose(): void;
  6756. /**
  6757. * Serialize the skeleton in a JSON object
  6758. * @returns a JSON object
  6759. */
  6760. serialize(): any;
  6761. /**
  6762. * Creates a new skeleton from serialized data
  6763. * @param parsedSkeleton defines the serialized data
  6764. * @param scene defines the hosting scene
  6765. * @returns a new skeleton
  6766. */
  6767. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  6768. /**
  6769. * Compute all node absolute transforms
  6770. * @param forceUpdate defines if computation must be done even if cache is up to date
  6771. */
  6772. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  6773. /**
  6774. * Gets the root pose matrix
  6775. * @returns a matrix
  6776. */
  6777. getPoseMatrix(): Nullable<Matrix>;
  6778. /**
  6779. * Sorts bones per internal index
  6780. */
  6781. sortBones(): void;
  6782. private _sortBones;
  6783. }
  6784. }
  6785. declare module BABYLON {
  6786. /**
  6787. * This represents an orbital type of camera.
  6788. *
  6789. * 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.
  6790. * 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.
  6791. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  6792. */
  6793. class ArcRotateCamera extends TargetCamera {
  6794. /**
  6795. * Defines the rotation angle of the camera along the longitudinal axis.
  6796. */
  6797. alpha: number;
  6798. /**
  6799. * Defines the rotation angle of the camera along the latitudinal axis.
  6800. */
  6801. beta: number;
  6802. /**
  6803. * Defines the radius of the camera from it s target point.
  6804. */
  6805. radius: number;
  6806. protected _target: Vector3;
  6807. protected _targetHost: Nullable<AbstractMesh>;
  6808. /**
  6809. * Defines the target point of the camera.
  6810. * The camera looks towards it form the radius distance.
  6811. */
  6812. target: Vector3;
  6813. /**
  6814. * Current inertia value on the longitudinal axis.
  6815. * The bigger this number the longer it will take for the camera to stop.
  6816. */
  6817. inertialAlphaOffset: number;
  6818. /**
  6819. * Current inertia value on the latitudinal axis.
  6820. * The bigger this number the longer it will take for the camera to stop.
  6821. */
  6822. inertialBetaOffset: number;
  6823. /**
  6824. * Current inertia value on the radius axis.
  6825. * The bigger this number the longer it will take for the camera to stop.
  6826. */
  6827. inertialRadiusOffset: number;
  6828. /**
  6829. * Minimum allowed angle on the longitudinal axis.
  6830. * This can help limiting how the Camera is able to move in the scene.
  6831. */
  6832. lowerAlphaLimit: Nullable<number>;
  6833. /**
  6834. * Maximum allowed angle on the longitudinal axis.
  6835. * This can help limiting how the Camera is able to move in the scene.
  6836. */
  6837. upperAlphaLimit: Nullable<number>;
  6838. /**
  6839. * Minimum allowed angle on the latitudinal axis.
  6840. * This can help limiting how the Camera is able to move in the scene.
  6841. */
  6842. lowerBetaLimit: number;
  6843. /**
  6844. * Maximum allowed angle on the latitudinal axis.
  6845. * This can help limiting how the Camera is able to move in the scene.
  6846. */
  6847. upperBetaLimit: number;
  6848. /**
  6849. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  6850. * This can help limiting how the Camera is able to move in the scene.
  6851. */
  6852. lowerRadiusLimit: Nullable<number>;
  6853. /**
  6854. * Maximum allowed distance of the camera to the target (The camera can not get further).
  6855. * This can help limiting how the Camera is able to move in the scene.
  6856. */
  6857. upperRadiusLimit: Nullable<number>;
  6858. /**
  6859. * Defines the current inertia value used during panning of the camera along the X axis.
  6860. */
  6861. inertialPanningX: number;
  6862. /**
  6863. * Defines the current inertia value used during panning of the camera along the Y axis.
  6864. */
  6865. inertialPanningY: number;
  6866. /**
  6867. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  6868. * Basically if your fingers moves away from more than this distance you will be considered
  6869. * in pinch mode.
  6870. */
  6871. pinchToPanMaxDistance: number;
  6872. /**
  6873. * Defines the maximum distance the camera can pan.
  6874. * This could help keeping the cammera always in your scene.
  6875. */
  6876. panningDistanceLimit: Nullable<number>;
  6877. /**
  6878. * Defines the target of the camera before paning.
  6879. */
  6880. panningOriginTarget: Vector3;
  6881. /**
  6882. * Defines the value of the inertia used during panning.
  6883. * 0 would mean stop inertia and one would mean no decelleration at all.
  6884. */
  6885. panningInertia: number;
  6886. /**
  6887. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  6888. */
  6889. angularSensibilityX: number;
  6890. /**
  6891. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  6892. */
  6893. angularSensibilityY: number;
  6894. /**
  6895. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  6896. */
  6897. pinchPrecision: number;
  6898. /**
  6899. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  6900. * It will be used instead of pinchDeltaPrecision if different from 0.
  6901. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  6902. */
  6903. pinchDeltaPercentage: number;
  6904. /**
  6905. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  6906. */
  6907. panningSensibility: number;
  6908. /**
  6909. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  6910. */
  6911. keysUp: number[];
  6912. /**
  6913. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  6914. */
  6915. keysDown: number[];
  6916. /**
  6917. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  6918. */
  6919. keysLeft: number[];
  6920. /**
  6921. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  6922. */
  6923. keysRight: number[];
  6924. /**
  6925. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  6926. */
  6927. wheelPrecision: number;
  6928. /**
  6929. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  6930. * It will be used instead of pinchDeltaPrecision if different from 0.
  6931. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  6932. */
  6933. wheelDeltaPercentage: number;
  6934. /**
  6935. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  6936. */
  6937. zoomOnFactor: number;
  6938. /**
  6939. * Defines a screen offset for the camera position.
  6940. */
  6941. targetScreenOffset: Vector2;
  6942. /**
  6943. * Allows the camera to be completely reversed.
  6944. * If false the camera can not arrive upside down.
  6945. */
  6946. allowUpsideDown: boolean;
  6947. /**
  6948. * Define if double tap/click is used to restore the previously saved state of the camera.
  6949. */
  6950. useInputToRestoreState: boolean;
  6951. /** @hidden */
  6952. _viewMatrix: Matrix;
  6953. /** @hidden */
  6954. _useCtrlForPanning: boolean;
  6955. /** @hidden */
  6956. _panningMouseButton: number;
  6957. /**
  6958. * Defines the inpute associated to the camera.
  6959. */
  6960. inputs: ArcRotateCameraInputsManager;
  6961. /** @hidden */
  6962. _reset: () => void;
  6963. /**
  6964. * Defines the allowed panning axis.
  6965. */
  6966. panningAxis: Vector3;
  6967. protected _localDirection: Vector3;
  6968. protected _transformedDirection: Vector3;
  6969. private _bouncingBehavior;
  6970. /**
  6971. * Gets the bouncing behavior of the camera if it has been enabled.
  6972. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  6973. */
  6974. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  6975. /**
  6976. * Defines if the bouncing behavior of the camera is enabled on the camera.
  6977. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  6978. */
  6979. useBouncingBehavior: boolean;
  6980. private _framingBehavior;
  6981. /**
  6982. * Gets the framing behavior of the camera if it has been enabled.
  6983. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  6984. */
  6985. readonly framingBehavior: Nullable<FramingBehavior>;
  6986. /**
  6987. * Defines if the framing behavior of the camera is enabled on the camera.
  6988. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  6989. */
  6990. useFramingBehavior: boolean;
  6991. private _autoRotationBehavior;
  6992. /**
  6993. * Gets the auto rotation behavior of the camera if it has been enabled.
  6994. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  6995. */
  6996. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  6997. /**
  6998. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  6999. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  7000. */
  7001. useAutoRotationBehavior: boolean;
  7002. /**
  7003. * Observable triggered when the mesh target has been changed on the camera.
  7004. */
  7005. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  7006. /**
  7007. * Event raised when the camera is colliding with a mesh.
  7008. */
  7009. onCollide: (collidedMesh: AbstractMesh) => void;
  7010. /**
  7011. * Defines whether the camera should check collision with the objects oh the scene.
  7012. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  7013. */
  7014. checkCollisions: boolean;
  7015. /**
  7016. * Defines the collision radius of the camera.
  7017. * This simulates a sphere around the camera.
  7018. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  7019. */
  7020. collisionRadius: Vector3;
  7021. protected _collider: Collider;
  7022. protected _previousPosition: Vector3;
  7023. protected _collisionVelocity: Vector3;
  7024. protected _newPosition: Vector3;
  7025. protected _previousAlpha: number;
  7026. protected _previousBeta: number;
  7027. protected _previousRadius: number;
  7028. protected _collisionTriggered: boolean;
  7029. protected _targetBoundingCenter: Nullable<Vector3>;
  7030. private _computationVector;
  7031. private _tempAxisVector;
  7032. private _tempAxisRotationMatrix;
  7033. /**
  7034. * Instantiates a new ArcRotateCamera in a given scene
  7035. * @param name Defines the name of the camera
  7036. * @param alpha Defines the camera rotation along the logitudinal axis
  7037. * @param beta Defines the camera rotation along the latitudinal axis
  7038. * @param radius Defines the camera distance from its target
  7039. * @param target Defines the camera target
  7040. * @param scene Defines the scene the camera belongs to
  7041. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  7042. */
  7043. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  7044. /** @hidden */
  7045. _initCache(): void;
  7046. /** @hidden */
  7047. _updateCache(ignoreParentClass?: boolean): void;
  7048. protected _getTargetPosition(): Vector3;
  7049. private _storedAlpha;
  7050. private _storedBeta;
  7051. private _storedRadius;
  7052. private _storedTarget;
  7053. /**
  7054. * Stores the current state of the camera (alpha, beta, radius and target)
  7055. * @returns the camera itself
  7056. */
  7057. storeState(): Camera;
  7058. /**
  7059. * @hidden
  7060. * Restored camera state. You must call storeState() first
  7061. */
  7062. _restoreStateValues(): boolean;
  7063. /** @hidden */
  7064. _isSynchronizedViewMatrix(): boolean;
  7065. /**
  7066. * Attached controls to the current camera.
  7067. * @param element Defines the element the controls should be listened from
  7068. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7069. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  7070. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  7071. */
  7072. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  7073. /**
  7074. * Detach the current controls from the camera.
  7075. * The camera will stop reacting to inputs.
  7076. * @param element Defines the element to stop listening the inputs from
  7077. */
  7078. detachControl(element: HTMLElement): void;
  7079. /** @hidden */
  7080. _checkInputs(): void;
  7081. protected _checkLimits(): void;
  7082. /**
  7083. * Rebuilds angles (alpha, beta) and radius from the give position and target.
  7084. */
  7085. rebuildAnglesAndRadius(): void;
  7086. /**
  7087. * Use a position to define the current camera related information like aplha, beta and radius
  7088. * @param position Defines the position to set the camera at
  7089. */
  7090. setPosition(position: Vector3): void;
  7091. /**
  7092. * Defines the target the camera should look at.
  7093. * This will automatically adapt alpha beta and radius to fit within the new target.
  7094. * @param target Defines the new target as a Vector or a mesh
  7095. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  7096. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  7097. */
  7098. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  7099. /** @hidden */
  7100. _getViewMatrix(): Matrix;
  7101. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  7102. /**
  7103. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  7104. * @param meshes Defines the mesh to zoom on
  7105. * @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)
  7106. */
  7107. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  7108. /**
  7109. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  7110. * The target will be changed but the radius
  7111. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  7112. * @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)
  7113. */
  7114. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  7115. min: Vector3;
  7116. max: Vector3;
  7117. distance: number;
  7118. }, doNotUpdateMaxZ?: boolean): void;
  7119. /**
  7120. * @override
  7121. * Override Camera.createRigCamera
  7122. */
  7123. createRigCamera(name: string, cameraIndex: number): Camera;
  7124. /**
  7125. * @hidden
  7126. * @override
  7127. * Override Camera._updateRigCameras
  7128. */
  7129. _updateRigCameras(): void;
  7130. /**
  7131. * Destroy the camera and release the current resources hold by it.
  7132. */
  7133. dispose(): void;
  7134. /**
  7135. * Gets the current object class name.
  7136. * @return the class name
  7137. */
  7138. getClassName(): string;
  7139. }
  7140. }
  7141. declare module BABYLON {
  7142. /**
  7143. * Default Inputs manager for the ArcRotateCamera.
  7144. * It groups all the default supported inputs for ease of use.
  7145. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  7146. */
  7147. class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  7148. /**
  7149. * Instantiates a new ArcRotateCameraInputsManager.
  7150. * @param camera Defines the camera the inputs belong to
  7151. */
  7152. constructor(camera: ArcRotateCamera);
  7153. /**
  7154. * Add mouse wheel input support to the input manager.
  7155. * @returns the current input manager
  7156. */
  7157. addMouseWheel(): ArcRotateCameraInputsManager;
  7158. /**
  7159. * Add pointers input support to the input manager.
  7160. * @returns the current input manager
  7161. */
  7162. addPointers(): ArcRotateCameraInputsManager;
  7163. /**
  7164. * Add keyboard input support to the input manager.
  7165. * @returns the current input manager
  7166. */
  7167. addKeyboard(): ArcRotateCameraInputsManager;
  7168. /**
  7169. * Add orientation input support to the input manager.
  7170. * @returns the current input manager
  7171. */
  7172. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  7173. }
  7174. }
  7175. declare module BABYLON {
  7176. /**
  7177. * This is the base class of all the camera used in the application.
  7178. * @see http://doc.babylonjs.com/features/cameras
  7179. */
  7180. class Camera extends Node {
  7181. /**
  7182. * This is the default projection mode used by the cameras.
  7183. * It helps recreating a feeling of perspective and better appreciate depth.
  7184. * This is the best way to simulate real life cameras.
  7185. */
  7186. static readonly PERSPECTIVE_CAMERA: number;
  7187. /**
  7188. * This helps creating camera with an orthographic mode.
  7189. * 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.
  7190. */
  7191. static readonly ORTHOGRAPHIC_CAMERA: number;
  7192. /**
  7193. * This is the default FOV mode for perspective cameras.
  7194. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  7195. */
  7196. static readonly FOVMODE_VERTICAL_FIXED: number;
  7197. /**
  7198. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  7199. */
  7200. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  7201. /**
  7202. * This specifies ther is no need for a camera rig.
  7203. * Basically only one eye is rendered corresponding to the camera.
  7204. */
  7205. static readonly RIG_MODE_NONE: number;
  7206. /**
  7207. * Simulates a camera Rig with one blue eye and one red eye.
  7208. * This can be use with 3d blue and red glasses.
  7209. */
  7210. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  7211. /**
  7212. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  7213. */
  7214. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  7215. /**
  7216. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  7217. */
  7218. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  7219. /**
  7220. * Defines that both eyes of the camera will be rendered over under each other.
  7221. */
  7222. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  7223. /**
  7224. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  7225. */
  7226. static readonly RIG_MODE_VR: number;
  7227. /**
  7228. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  7229. */
  7230. static readonly RIG_MODE_WEBVR: number;
  7231. /**
  7232. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  7233. */
  7234. static readonly RIG_MODE_CUSTOM: number;
  7235. /**
  7236. * Defines if by default attaching controls should prevent the default javascript event to continue.
  7237. */
  7238. static ForceAttachControlToAlwaysPreventDefault: boolean;
  7239. /**
  7240. * @hidden
  7241. * Might be removed once multiview will be a thing
  7242. */
  7243. static UseAlternateWebVRRendering: boolean;
  7244. /**
  7245. * Define the input manager associated with the camera.
  7246. */
  7247. inputs: CameraInputsManager<Camera>;
  7248. /**
  7249. * Define the current local position of the camera in the scene
  7250. */
  7251. position: Vector3;
  7252. /**
  7253. * The vector the camera should consider as up.
  7254. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  7255. */
  7256. upVector: Vector3;
  7257. /**
  7258. * Define the current limit on the left side for an orthographic camera
  7259. * In scene unit
  7260. */
  7261. orthoLeft: Nullable<number>;
  7262. /**
  7263. * Define the current limit on the right side for an orthographic camera
  7264. * In scene unit
  7265. */
  7266. orthoRight: Nullable<number>;
  7267. /**
  7268. * Define the current limit on the bottom side for an orthographic camera
  7269. * In scene unit
  7270. */
  7271. orthoBottom: Nullable<number>;
  7272. /**
  7273. * Define the current limit on the top side for an orthographic camera
  7274. * In scene unit
  7275. */
  7276. orthoTop: Nullable<number>;
  7277. /**
  7278. * Field Of View is set in Radians. (default is 0.8)
  7279. */
  7280. fov: number;
  7281. /**
  7282. * Define the minimum distance the camera can see from.
  7283. * This is important to note that the depth buffer are not infinite and the closer it starts
  7284. * the more your scene might encounter depth fighting issue.
  7285. */
  7286. minZ: number;
  7287. /**
  7288. * Define the maximum distance the camera can see to.
  7289. * This is important to note that the depth buffer are not infinite and the further it end
  7290. * the more your scene might encounter depth fighting issue.
  7291. */
  7292. maxZ: number;
  7293. /**
  7294. * Define the default inertia of the camera.
  7295. * This helps giving a smooth feeling to the camera movement.
  7296. */
  7297. inertia: number;
  7298. /**
  7299. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  7300. */
  7301. mode: number;
  7302. /**
  7303. * Define wether the camera is intermediate.
  7304. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  7305. */
  7306. isIntermediate: boolean;
  7307. /**
  7308. * Define the viewport of the camera.
  7309. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  7310. */
  7311. viewport: Viewport;
  7312. /**
  7313. * Restricts the camera to viewing objects with the same layerMask.
  7314. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  7315. */
  7316. layerMask: number;
  7317. /**
  7318. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  7319. */
  7320. fovMode: number;
  7321. /**
  7322. * Rig mode of the camera.
  7323. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  7324. * This is normally controlled byt the camera themselves as internal use.
  7325. */
  7326. cameraRigMode: number;
  7327. /**
  7328. * Defines the distance between both "eyes" in case of a RIG
  7329. */
  7330. interaxialDistance: number;
  7331. /**
  7332. * Defines if stereoscopic rendering is done side by side or over under.
  7333. */
  7334. isStereoscopicSideBySide: boolean;
  7335. /**
  7336. * 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
  7337. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  7338. * else in the scene.
  7339. */
  7340. customRenderTargets: RenderTargetTexture[];
  7341. /**
  7342. * When set, the camera will render to this render target instead of the default canvas
  7343. */
  7344. outputRenderTarget: Nullable<RenderTargetTexture>;
  7345. /**
  7346. * Observable triggered when the camera view matrix has changed.
  7347. */
  7348. onViewMatrixChangedObservable: Observable<Camera>;
  7349. /**
  7350. * Observable triggered when the camera Projection matrix has changed.
  7351. */
  7352. onProjectionMatrixChangedObservable: Observable<Camera>;
  7353. /**
  7354. * Observable triggered when the inputs have been processed.
  7355. */
  7356. onAfterCheckInputsObservable: Observable<Camera>;
  7357. /**
  7358. * Observable triggered when reset has been called and applied to the camera.
  7359. */
  7360. onRestoreStateObservable: Observable<Camera>;
  7361. /** @hidden */
  7362. _cameraRigParams: any;
  7363. /** @hidden */
  7364. _rigCameras: Camera[];
  7365. /** @hidden */
  7366. _rigPostProcess: Nullable<PostProcess>;
  7367. protected _webvrViewMatrix: Matrix;
  7368. /** @hidden */
  7369. _skipRendering: boolean;
  7370. /** @hidden */
  7371. _alternateCamera: Camera;
  7372. /** @hidden */
  7373. _projectionMatrix: Matrix;
  7374. /** @hidden */
  7375. _postProcesses: Nullable<PostProcess>[];
  7376. /** @hidden */
  7377. _activeMeshes: SmartArray<AbstractMesh>;
  7378. protected _globalPosition: Vector3;
  7379. /** hidden */
  7380. _computedViewMatrix: Matrix;
  7381. private _doNotComputeProjectionMatrix;
  7382. private _transformMatrix;
  7383. private _frustumPlanes;
  7384. private _refreshFrustumPlanes;
  7385. private _storedFov;
  7386. private _stateStored;
  7387. /**
  7388. * Instantiates a new camera object.
  7389. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  7390. * @see http://doc.babylonjs.com/features/cameras
  7391. * @param name Defines the name of the camera in the scene
  7392. * @param position Defines the position of the camera
  7393. * @param scene Defines the scene the camera belongs too
  7394. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  7395. */
  7396. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  7397. /**
  7398. * Store current camera state (fov, position, etc..)
  7399. * @returns the camera
  7400. */
  7401. storeState(): Camera;
  7402. /**
  7403. * Restores the camera state values if it has been stored. You must call storeState() first
  7404. */
  7405. protected _restoreStateValues(): boolean;
  7406. /**
  7407. * Restored camera state. You must call storeState() first.
  7408. * @returns true if restored and false otherwise
  7409. */
  7410. restoreState(): boolean;
  7411. /**
  7412. * Gets the class name of the camera.
  7413. * @returns the class name
  7414. */
  7415. getClassName(): string;
  7416. /**
  7417. * Gets a string representation of the camera useful for debug purpose.
  7418. * @param fullDetails Defines that a more verboe level of logging is required
  7419. * @returns the string representation
  7420. */
  7421. toString(fullDetails?: boolean): string;
  7422. /**
  7423. * Gets the current world space position of the camera.
  7424. */
  7425. readonly globalPosition: Vector3;
  7426. /**
  7427. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  7428. * @returns the active meshe list
  7429. */
  7430. getActiveMeshes(): SmartArray<AbstractMesh>;
  7431. /**
  7432. * Check wether a mesh is part of the current active mesh list of the camera
  7433. * @param mesh Defines the mesh to check
  7434. * @returns true if active, false otherwise
  7435. */
  7436. isActiveMesh(mesh: Mesh): boolean;
  7437. /**
  7438. * Is this camera ready to be used/rendered
  7439. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  7440. * @return true if the camera is ready
  7441. */
  7442. isReady(completeCheck?: boolean): boolean;
  7443. /** @hidden */
  7444. _initCache(): void;
  7445. /** @hidden */
  7446. _updateCache(ignoreParentClass?: boolean): void;
  7447. /** @hidden */
  7448. _isSynchronized(): boolean;
  7449. /** @hidden */
  7450. _isSynchronizedViewMatrix(): boolean;
  7451. /** @hidden */
  7452. _isSynchronizedProjectionMatrix(): boolean;
  7453. /**
  7454. * Attach the input controls to a specific dom element to get the input from.
  7455. * @param element Defines the element the controls should be listened from
  7456. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7457. */
  7458. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  7459. /**
  7460. * Detach the current controls from the specified dom element.
  7461. * @param element Defines the element to stop listening the inputs from
  7462. */
  7463. detachControl(element: HTMLElement): void;
  7464. /**
  7465. * Update the camera state according to the different inputs gathered during the frame.
  7466. */
  7467. update(): void;
  7468. /** @hidden */
  7469. _checkInputs(): void;
  7470. /** @hidden */
  7471. readonly rigCameras: Camera[];
  7472. /**
  7473. * Gets the post process used by the rig cameras
  7474. */
  7475. readonly rigPostProcess: Nullable<PostProcess>;
  7476. /**
  7477. * Internal, gets the first post proces.
  7478. * @returns the first post process to be run on this camera.
  7479. */
  7480. _getFirstPostProcess(): Nullable<PostProcess>;
  7481. private _cascadePostProcessesToRigCams;
  7482. /**
  7483. * Attach a post process to the camera.
  7484. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  7485. * @param postProcess The post process to attach to the camera
  7486. * @param insertAt The position of the post process in case several of them are in use in the scene
  7487. * @returns the position the post process has been inserted at
  7488. */
  7489. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  7490. /**
  7491. * Detach a post process to the camera.
  7492. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  7493. * @param postProcess The post process to detach from the camera
  7494. */
  7495. detachPostProcess(postProcess: PostProcess): void;
  7496. /**
  7497. * Gets the current world matrix of the camera
  7498. */
  7499. getWorldMatrix(): Matrix;
  7500. /** @hidden */
  7501. protected _getViewMatrix(): Matrix;
  7502. /**
  7503. * Gets the current view matrix of the camera.
  7504. * @param force forces the camera to recompute the matrix without looking at the cached state
  7505. * @returns the view matrix
  7506. */
  7507. getViewMatrix(force?: boolean): Matrix;
  7508. /**
  7509. * Freeze the projection matrix.
  7510. * It will prevent the cache check of the camera projection compute and can speed up perf
  7511. * if no parameter of the camera are meant to change
  7512. * @param projection Defines manually a projection if necessary
  7513. */
  7514. freezeProjectionMatrix(projection?: Matrix): void;
  7515. /**
  7516. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  7517. */
  7518. unfreezeProjectionMatrix(): void;
  7519. /**
  7520. * Gets the current projection matrix of the camera.
  7521. * @param force forces the camera to recompute the matrix without looking at the cached state
  7522. * @returns the projection matrix
  7523. */
  7524. getProjectionMatrix(force?: boolean): Matrix;
  7525. /**
  7526. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  7527. * @returns a Matrix
  7528. */
  7529. getTransformationMatrix(): Matrix;
  7530. private _updateFrustumPlanes;
  7531. /**
  7532. * Checks if a cullable object (mesh...) is in the camera frustum
  7533. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  7534. * @param target The object to check
  7535. * @returns true if the object is in frustum otherwise false
  7536. */
  7537. isInFrustum(target: ICullable): boolean;
  7538. /**
  7539. * Checks if a cullable object (mesh...) is in the camera frustum
  7540. * Unlike isInFrustum this cheks the full bounding box
  7541. * @param target The object to check
  7542. * @returns true if the object is in frustum otherwise false
  7543. */
  7544. isCompletelyInFrustum(target: ICullable): boolean;
  7545. /**
  7546. * Gets a ray in the forward direction from the camera.
  7547. * @param length Defines the length of the ray to create
  7548. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  7549. * @param origin Defines the start point of the ray which defaults to the camera position
  7550. * @returns the forward ray
  7551. */
  7552. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  7553. /**
  7554. * Releases resources associated with this node.
  7555. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  7556. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  7557. */
  7558. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7559. /**
  7560. * Gets the left camera of a rig setup in case of Rigged Camera
  7561. */
  7562. readonly leftCamera: Nullable<FreeCamera>;
  7563. /**
  7564. * Gets the right camera of a rig setup in case of Rigged Camera
  7565. */
  7566. readonly rightCamera: Nullable<FreeCamera>;
  7567. /**
  7568. * Gets the left camera target of a rig setup in case of Rigged Camera
  7569. * @returns the target position
  7570. */
  7571. getLeftTarget(): Nullable<Vector3>;
  7572. /**
  7573. * Gets the right camera target of a rig setup in case of Rigged Camera
  7574. * @returns the target position
  7575. */
  7576. getRightTarget(): Nullable<Vector3>;
  7577. /**
  7578. * @hidden
  7579. */
  7580. setCameraRigMode(mode: number, rigParams: any): void;
  7581. private _getVRProjectionMatrix;
  7582. protected _updateCameraRotationMatrix(): void;
  7583. protected _updateWebVRCameraRotationMatrix(): void;
  7584. /**
  7585. * This function MUST be overwritten by the different WebVR cameras available.
  7586. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  7587. */
  7588. protected _getWebVRProjectionMatrix(): Matrix;
  7589. /**
  7590. * This function MUST be overwritten by the different WebVR cameras available.
  7591. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  7592. */
  7593. protected _getWebVRViewMatrix(): Matrix;
  7594. /** @hidden */
  7595. setCameraRigParameter(name: string, value: any): void;
  7596. /**
  7597. * needs to be overridden by children so sub has required properties to be copied
  7598. * @hidden
  7599. */
  7600. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  7601. /**
  7602. * May need to be overridden by children
  7603. * @hidden
  7604. */
  7605. _updateRigCameras(): void;
  7606. /** @hidden */
  7607. _setupInputs(): void;
  7608. /**
  7609. * Serialiaze the camera setup to a json represention
  7610. * @returns the JSON representation
  7611. */
  7612. serialize(): any;
  7613. /**
  7614. * Clones the current camera.
  7615. * @param name The cloned camera name
  7616. * @returns the cloned camera
  7617. */
  7618. clone(name: string): Camera;
  7619. /**
  7620. * Gets the direction of the camera relative to a given local axis.
  7621. * @param localAxis Defines the reference axis to provide a relative direction.
  7622. * @return the direction
  7623. */
  7624. getDirection(localAxis: Vector3): Vector3;
  7625. /**
  7626. * Gets the direction of the camera relative to a given local axis into a passed vector.
  7627. * @param localAxis Defines the reference axis to provide a relative direction.
  7628. * @param result Defines the vector to store the result in
  7629. */
  7630. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  7631. /**
  7632. * Gets a camera constructor for a given camera type
  7633. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  7634. * @param name The name of the camera the result will be able to instantiate
  7635. * @param scene The scene the result will construct the camera in
  7636. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  7637. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  7638. * @returns a factory method to construc the camera
  7639. */
  7640. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  7641. /**
  7642. * Compute the world matrix of the camera.
  7643. * @returns the camera workd matrix
  7644. */
  7645. computeWorldMatrix(): Matrix;
  7646. /**
  7647. * Parse a JSON and creates the camera from the parsed information
  7648. * @param parsedCamera The JSON to parse
  7649. * @param scene The scene to instantiate the camera in
  7650. * @returns the newly constructed camera
  7651. */
  7652. static Parse(parsedCamera: any, scene: Scene): Camera;
  7653. }
  7654. }
  7655. declare module BABYLON {
  7656. /**
  7657. * @ignore
  7658. * This is a list of all the different input types that are available in the application.
  7659. * Fo instance: ArcRotateCameraGamepadInput...
  7660. */
  7661. var CameraInputTypes: {};
  7662. /**
  7663. * This is the contract to implement in order to create a new input class.
  7664. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  7665. */
  7666. interface ICameraInput<TCamera extends Camera> {
  7667. /**
  7668. * Defines the camera the input is attached to.
  7669. */
  7670. camera: Nullable<TCamera>;
  7671. /**
  7672. * Gets the class name of the current intput.
  7673. * @returns the class name
  7674. */
  7675. getClassName(): string;
  7676. /**
  7677. * Get the friendly name associated with the input class.
  7678. * @returns the input friendly name
  7679. */
  7680. getSimpleName(): string;
  7681. /**
  7682. * Attach the input controls to a specific dom element to get the input from.
  7683. * @param element Defines the element the controls should be listened from
  7684. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7685. */
  7686. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  7687. /**
  7688. * Detach the current controls from the specified dom element.
  7689. * @param element Defines the element to stop listening the inputs from
  7690. */
  7691. detachControl(element: Nullable<HTMLElement>): void;
  7692. /**
  7693. * Update the current camera state depending on the inputs that have been used this frame.
  7694. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  7695. */
  7696. checkInputs?: () => void;
  7697. }
  7698. /**
  7699. * Represents a map of input types to input instance or input index to input instance.
  7700. */
  7701. interface CameraInputsMap<TCamera extends Camera> {
  7702. /**
  7703. * Accessor to the input by input type.
  7704. */
  7705. [name: string]: ICameraInput<TCamera>;
  7706. /**
  7707. * Accessor to the input by input index.
  7708. */
  7709. [idx: number]: ICameraInput<TCamera>;
  7710. }
  7711. /**
  7712. * This represents the input manager used within a camera.
  7713. * It helps dealing with all the different kind of input attached to a camera.
  7714. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  7715. */
  7716. class CameraInputsManager<TCamera extends Camera> {
  7717. /**
  7718. * Defines the list of inputs attahed to the camera.
  7719. */
  7720. attached: CameraInputsMap<TCamera>;
  7721. /**
  7722. * Defines the dom element the camera is collecting inputs from.
  7723. * This is null if the controls have not been attached.
  7724. */
  7725. attachedElement: Nullable<HTMLElement>;
  7726. /**
  7727. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7728. */
  7729. noPreventDefault: boolean;
  7730. /**
  7731. * Defined the camera the input manager belongs to.
  7732. */
  7733. camera: TCamera;
  7734. /**
  7735. * Update the current camera state depending on the inputs that have been used this frame.
  7736. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  7737. */
  7738. checkInputs: () => void;
  7739. /**
  7740. * Instantiate a new Camera Input Manager.
  7741. * @param camera Defines the camera the input manager blongs to
  7742. */
  7743. constructor(camera: TCamera);
  7744. /**
  7745. * Add an input method to a camera
  7746. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  7747. * @param input camera input method
  7748. */
  7749. add(input: ICameraInput<TCamera>): void;
  7750. /**
  7751. * Remove a specific input method from a camera
  7752. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  7753. * @param inputToRemove camera input method
  7754. */
  7755. remove(inputToRemove: ICameraInput<TCamera>): void;
  7756. /**
  7757. * Remove a specific input type from a camera
  7758. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  7759. * @param inputType the type of the input to remove
  7760. */
  7761. removeByType(inputType: string): void;
  7762. private _addCheckInputs;
  7763. /**
  7764. * Attach the input controls to the currently attached dom element to listen the events from.
  7765. * @param input Defines the input to attach
  7766. */
  7767. attachInput(input: ICameraInput<TCamera>): void;
  7768. /**
  7769. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  7770. * @param element Defines the dom element to collect the events from
  7771. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7772. */
  7773. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  7774. /**
  7775. * Detach the current manager inputs controls from a specific dom element.
  7776. * @param element Defines the dom element to collect the events from
  7777. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  7778. */
  7779. detachElement(element: HTMLElement, disconnect?: boolean): void;
  7780. /**
  7781. * Rebuild the dynamic inputCheck function from the current list of
  7782. * defined inputs in the manager.
  7783. */
  7784. rebuildInputCheck(): void;
  7785. /**
  7786. * Remove all attached input methods from a camera
  7787. */
  7788. clear(): void;
  7789. /**
  7790. * Serialize the current input manager attached to a camera.
  7791. * This ensures than once parsed,
  7792. * the input associated to the camera will be identical to the current ones
  7793. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  7794. */
  7795. serialize(serializedCamera: any): void;
  7796. /**
  7797. * Parses an input manager serialized JSON to restore the previous list of inputs
  7798. * and states associated to a camera.
  7799. * @param parsedCamera Defines the JSON to parse
  7800. */
  7801. parse(parsedCamera: any): void;
  7802. }
  7803. }
  7804. declare module BABYLON {
  7805. /**
  7806. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  7807. * being tilted forward or back and left or right.
  7808. */
  7809. class DeviceOrientationCamera extends FreeCamera {
  7810. private _initialQuaternion;
  7811. private _quaternionCache;
  7812. /**
  7813. * Creates a new device orientation camera
  7814. * @param name The name of the camera
  7815. * @param position The start position camera
  7816. * @param scene The scene the camera belongs to
  7817. */
  7818. constructor(name: string, position: Vector3, scene: Scene);
  7819. /**
  7820. * Gets the current instance class name ("DeviceOrientationCamera").
  7821. * This helps avoiding instanceof at run time.
  7822. * @returns the class name
  7823. */
  7824. getClassName(): string;
  7825. /**
  7826. * @hidden
  7827. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  7828. */
  7829. _checkInputs(): void;
  7830. /**
  7831. * Reset the camera to its default orientation on the specified axis only.
  7832. * @param axis The axis to reset
  7833. */
  7834. resetToCurrentRotation(axis?: Axis): void;
  7835. }
  7836. }
  7837. declare module BABYLON {
  7838. /**
  7839. * This is a flying camera, designed for 3D movement and rotation in all directions,
  7840. * such as in a 3D Space Shooter or a Flight Simulator.
  7841. */
  7842. class FlyCamera extends TargetCamera {
  7843. /**
  7844. * Define the collision ellipsoid of the camera.
  7845. * This is helpful for simulating a camera body, like a player's body.
  7846. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  7847. */
  7848. ellipsoid: Vector3;
  7849. /**
  7850. * Define an offset for the position of the ellipsoid around the camera.
  7851. * This can be helpful if the camera is attached away from the player's body center,
  7852. * such as at its head.
  7853. */
  7854. ellipsoidOffset: Vector3;
  7855. /**
  7856. * Enable or disable collisions of the camera with the rest of the scene objects.
  7857. */
  7858. checkCollisions: boolean;
  7859. /**
  7860. * Enable or disable gravity on the camera.
  7861. */
  7862. applyGravity: boolean;
  7863. /**
  7864. * Define the current direction the camera is moving to.
  7865. */
  7866. cameraDirection: Vector3;
  7867. /**
  7868. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  7869. * This overrides and empties cameraRotation.
  7870. */
  7871. rotationQuaternion: BABYLON.Quaternion;
  7872. /**
  7873. * Track Roll to maintain the wanted Rolling when looking around.
  7874. */
  7875. _trackRoll: number;
  7876. /**
  7877. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  7878. */
  7879. rollCorrect: number;
  7880. /**
  7881. * Mimic a banked turn, Rolling the camera when Yawing.
  7882. * It's recommended to use rollCorrect = 10 for faster banking correction.
  7883. */
  7884. bankedTurn: boolean;
  7885. /**
  7886. * Limit in radians for how much Roll banking will add. (Default: 90°)
  7887. */
  7888. bankedTurnLimit: number;
  7889. /**
  7890. * Value of 0 disables the banked Roll.
  7891. * Value of 1 is equal to the Yaw angle in radians.
  7892. */
  7893. bankedTurnMultiplier: number;
  7894. /**
  7895. * The inputs manager loads all the input sources, such as keyboard and mouse.
  7896. */
  7897. inputs: FlyCameraInputsManager;
  7898. /**
  7899. * Gets the input sensibility for mouse input.
  7900. * Higher values reduce sensitivity.
  7901. */
  7902. /**
  7903. * Sets the input sensibility for a mouse input.
  7904. * Higher values reduce sensitivity.
  7905. */
  7906. angularSensibility: number;
  7907. /**
  7908. * Get the keys for camera movement forward.
  7909. */
  7910. /**
  7911. * Set the keys for camera movement forward.
  7912. */
  7913. keysForward: number[];
  7914. /**
  7915. * Get the keys for camera movement backward.
  7916. */
  7917. keysBackward: number[];
  7918. /**
  7919. * Get the keys for camera movement up.
  7920. */
  7921. /**
  7922. * Set the keys for camera movement up.
  7923. */
  7924. keysUp: number[];
  7925. /**
  7926. * Get the keys for camera movement down.
  7927. */
  7928. /**
  7929. * Set the keys for camera movement down.
  7930. */
  7931. keysDown: number[];
  7932. /**
  7933. * Get the keys for camera movement left.
  7934. */
  7935. /**
  7936. * Set the keys for camera movement left.
  7937. */
  7938. keysLeft: number[];
  7939. /**
  7940. * Set the keys for camera movement right.
  7941. */
  7942. /**
  7943. * Set the keys for camera movement right.
  7944. */
  7945. keysRight: number[];
  7946. /**
  7947. * Event raised when the camera collides with a mesh in the scene.
  7948. */
  7949. onCollide: (collidedMesh: AbstractMesh) => void;
  7950. private _collider;
  7951. private _needMoveForGravity;
  7952. private _oldPosition;
  7953. private _diffPosition;
  7954. private _newPosition;
  7955. /** @hidden */
  7956. _localDirection: Vector3;
  7957. /** @hidden */
  7958. _transformedDirection: Vector3;
  7959. /**
  7960. * Instantiates a FlyCamera.
  7961. * This is a flying camera, designed for 3D movement and rotation in all directions,
  7962. * such as in a 3D Space Shooter or a Flight Simulator.
  7963. * @param name Define the name of the camera in the scene.
  7964. * @param position Define the starting position of the camera in the scene.
  7965. * @param scene Define the scene the camera belongs to.
  7966. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  7967. */
  7968. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  7969. /**
  7970. * Attach a control to the HTML DOM element.
  7971. * @param element Defines the element that listens to the input events.
  7972. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  7973. */
  7974. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  7975. /**
  7976. * Detach a control from the HTML DOM element.
  7977. * The camera will stop reacting to that input.
  7978. * @param element Defines the element that listens to the input events.
  7979. */
  7980. detachControl(element: HTMLElement): void;
  7981. private _collisionMask;
  7982. /**
  7983. * Get the mask that the camera ignores in collision events.
  7984. */
  7985. /**
  7986. * Set the mask that the camera ignores in collision events.
  7987. */
  7988. collisionMask: number;
  7989. /** @hidden */
  7990. _collideWithWorld(displacement: Vector3): void;
  7991. /** @hidden */
  7992. private _onCollisionPositionChange;
  7993. /** @hidden */
  7994. _checkInputs(): void;
  7995. /** @hidden */
  7996. _decideIfNeedsToMove(): boolean;
  7997. /** @hidden */
  7998. _updatePosition(): void;
  7999. /**
  8000. * Restore the Roll to its target value at the rate specified.
  8001. * @param rate - Higher means slower restoring.
  8002. * @hidden
  8003. */
  8004. restoreRoll(rate: number): void;
  8005. /**
  8006. * Destroy the camera and release the current resources held by it.
  8007. */
  8008. dispose(): void;
  8009. /**
  8010. * Get the current object class name.
  8011. * @returns the class name.
  8012. */
  8013. getClassName(): string;
  8014. }
  8015. }
  8016. declare module BABYLON {
  8017. /**
  8018. * Default Inputs manager for the FlyCamera.
  8019. * It groups all the default supported inputs for ease of use.
  8020. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8021. */
  8022. class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  8023. /**
  8024. * Instantiates a new FlyCameraInputsManager.
  8025. * @param camera Defines the camera the inputs belong to.
  8026. */
  8027. constructor(camera: FlyCamera);
  8028. /**
  8029. * Add keyboard input support to the input manager.
  8030. * @returns the new FlyCameraKeyboardMoveInput().
  8031. */
  8032. addKeyboard(): FlyCameraInputsManager;
  8033. /**
  8034. * Add mouse input support to the input manager.
  8035. * @param touchEnabled Enable touch screen support.
  8036. * @returns the new FlyCameraMouseInput().
  8037. */
  8038. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  8039. }
  8040. }
  8041. declare module BABYLON {
  8042. /**
  8043. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  8044. * an arc rotate version arcFollowCamera are available.
  8045. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  8046. */
  8047. class FollowCamera extends TargetCamera {
  8048. /**
  8049. * Distance the follow camera should follow an object at
  8050. */
  8051. radius: number;
  8052. /**
  8053. * Define a rotation offset between the camera and the object it follows
  8054. */
  8055. rotationOffset: number;
  8056. /**
  8057. * Define a height offset between the camera and the object it follows.
  8058. * It can help following an object from the top (like a car chaing a plane)
  8059. */
  8060. heightOffset: number;
  8061. /**
  8062. * Define how fast the camera can accelerate to follow it s target.
  8063. */
  8064. cameraAcceleration: number;
  8065. /**
  8066. * Define the speed limit of the camera following an object.
  8067. */
  8068. maxCameraSpeed: number;
  8069. /**
  8070. * Define the target of the camera.
  8071. */
  8072. lockedTarget: Nullable<AbstractMesh>;
  8073. /**
  8074. * Instantiates the follow camera.
  8075. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  8076. * @param name Define the name of the camera in the scene
  8077. * @param position Define the position of the camera
  8078. * @param scene Define the scene the camera belong to
  8079. * @param lockedTarget Define the target of the camera
  8080. */
  8081. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  8082. private _follow;
  8083. /** @hidden */
  8084. _checkInputs(): void;
  8085. /**
  8086. * Gets the camera class name.
  8087. * @returns the class name
  8088. */
  8089. getClassName(): string;
  8090. }
  8091. /**
  8092. * Arc Rotate version of the follow camera.
  8093. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  8094. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  8095. */
  8096. class ArcFollowCamera extends TargetCamera {
  8097. /** The longitudinal angle of the camera */
  8098. alpha: number;
  8099. /** The latitudinal angle of the camera */
  8100. beta: number;
  8101. /** The radius of the camera from its target */
  8102. radius: number;
  8103. /** Define the camera target (the messh it should follow) */
  8104. target: Nullable<AbstractMesh>;
  8105. private _cartesianCoordinates;
  8106. /**
  8107. * Instantiates a new ArcFollowCamera
  8108. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  8109. * @param name Define the name of the camera
  8110. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  8111. * @param beta Define the rotation angle of the camera around the elevation axis
  8112. * @param radius Define the radius of the camera from its target point
  8113. * @param target Define the target of the camera
  8114. * @param scene Define the scene the camera belongs to
  8115. */
  8116. constructor(name: string,
  8117. /** The longitudinal angle of the camera */
  8118. alpha: number,
  8119. /** The latitudinal angle of the camera */
  8120. beta: number,
  8121. /** The radius of the camera from its target */
  8122. radius: number,
  8123. /** Define the camera target (the messh it should follow) */
  8124. target: Nullable<AbstractMesh>, scene: Scene);
  8125. private _follow;
  8126. /** @hidden */
  8127. _checkInputs(): void;
  8128. /**
  8129. * Returns the class name of the object.
  8130. * It is mostly used internally for serialization purposes.
  8131. */
  8132. getClassName(): string;
  8133. }
  8134. }
  8135. declare module BABYLON {
  8136. /**
  8137. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  8138. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  8139. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8140. */
  8141. class FreeCamera extends TargetCamera {
  8142. /**
  8143. * Define the collision ellipsoid of the camera.
  8144. * This is helpful to simulate a camera body like the player body around the camera
  8145. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  8146. */
  8147. ellipsoid: Vector3;
  8148. /**
  8149. * Define an offset for the position of the ellipsoid around the camera.
  8150. * This can be helpful to determine the center of the body near the gravity center of the body
  8151. * instead of its head.
  8152. */
  8153. ellipsoidOffset: Vector3;
  8154. /**
  8155. * Enable or disable collisions of the camera with the rest of the scene objects.
  8156. */
  8157. checkCollisions: boolean;
  8158. /**
  8159. * Enable or disable gravity on the camera.
  8160. */
  8161. applyGravity: boolean;
  8162. /**
  8163. * Define the input manager associated to the camera.
  8164. */
  8165. inputs: FreeCameraInputsManager;
  8166. /**
  8167. * Gets the input sensibility for a mouse input. (default is 2000.0)
  8168. * Higher values reduce sensitivity.
  8169. */
  8170. /**
  8171. * Sets the input sensibility for a mouse input. (default is 2000.0)
  8172. * Higher values reduce sensitivity.
  8173. */
  8174. angularSensibility: number;
  8175. /**
  8176. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8177. */
  8178. keysUp: number[];
  8179. /**
  8180. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8181. */
  8182. keysDown: number[];
  8183. /**
  8184. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8185. */
  8186. keysLeft: number[];
  8187. /**
  8188. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8189. */
  8190. keysRight: number[];
  8191. /**
  8192. * Event raised when the camera collide with a mesh in the scene.
  8193. */
  8194. onCollide: (collidedMesh: AbstractMesh) => void;
  8195. private _collider;
  8196. private _needMoveForGravity;
  8197. private _oldPosition;
  8198. private _diffPosition;
  8199. private _newPosition;
  8200. /** @hidden */
  8201. _localDirection: Vector3;
  8202. /** @hidden */
  8203. _transformedDirection: Vector3;
  8204. /**
  8205. * Instantiates a Free Camera.
  8206. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  8207. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  8208. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8209. * @param name Define the name of the camera in the scene
  8210. * @param position Define the start position of the camera in the scene
  8211. * @param scene Define the scene the camera belongs to
  8212. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8213. */
  8214. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8215. /**
  8216. * Attached controls to the current camera.
  8217. * @param element Defines the element the controls should be listened from
  8218. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8219. */
  8220. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8221. /**
  8222. * Detach the current controls from the camera.
  8223. * The camera will stop reacting to inputs.
  8224. * @param element Defines the element to stop listening the inputs from
  8225. */
  8226. detachControl(element: HTMLElement): void;
  8227. private _collisionMask;
  8228. /**
  8229. * Define a collision mask to limit the list of object the camera can collide with
  8230. */
  8231. collisionMask: number;
  8232. /** @hidden */
  8233. _collideWithWorld(displacement: Vector3): void;
  8234. private _onCollisionPositionChange;
  8235. /** @hidden */
  8236. _checkInputs(): void;
  8237. /** @hidden */
  8238. _decideIfNeedsToMove(): boolean;
  8239. /** @hidden */
  8240. _updatePosition(): void;
  8241. /**
  8242. * Destroy the camera and release the current resources hold by it.
  8243. */
  8244. dispose(): void;
  8245. /**
  8246. * Gets the current object class name.
  8247. * @return the class name
  8248. */
  8249. getClassName(): string;
  8250. }
  8251. }
  8252. declare module BABYLON {
  8253. /**
  8254. * Default Inputs manager for the FreeCamera.
  8255. * It groups all the default supported inputs for ease of use.
  8256. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8257. */
  8258. class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  8259. /**
  8260. * Instantiates a new FreeCameraInputsManager.
  8261. * @param camera Defines the camera the inputs belong to
  8262. */
  8263. constructor(camera: FreeCamera);
  8264. /**
  8265. * Add keyboard input support to the input manager.
  8266. * @returns the current input manager
  8267. */
  8268. addKeyboard(): FreeCameraInputsManager;
  8269. /**
  8270. * Add mouse input support to the input manager.
  8271. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  8272. * @returns the current input manager
  8273. */
  8274. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  8275. /**
  8276. * Add orientation input support to the input manager.
  8277. * @returns the current input manager
  8278. */
  8279. addDeviceOrientation(): FreeCameraInputsManager;
  8280. /**
  8281. * Add touch input support to the input manager.
  8282. * @returns the current input manager
  8283. */
  8284. addTouch(): FreeCameraInputsManager;
  8285. /**
  8286. * Add virtual joystick input support to the input manager.
  8287. * @returns the current input manager
  8288. */
  8289. addVirtualJoystick(): FreeCameraInputsManager;
  8290. }
  8291. }
  8292. declare module BABYLON {
  8293. /**
  8294. * This represents a FPS type of camera. This is only here for back compat purpose.
  8295. * Please use the UniversalCamera instead as both are identical.
  8296. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8297. */
  8298. class GamepadCamera extends UniversalCamera {
  8299. /**
  8300. * Instantiates a new Gamepad Camera
  8301. * This represents a FPS type of camera. This is only here for back compat purpose.
  8302. * Please use the UniversalCamera instead as both are identical.
  8303. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8304. * @param name Define the name of the camera in the scene
  8305. * @param position Define the start position of the camera in the scene
  8306. * @param scene Define the scene the camera belongs to
  8307. */
  8308. constructor(name: string, position: Vector3, scene: Scene);
  8309. /**
  8310. * Gets the current object class name.
  8311. * @return the class name
  8312. */
  8313. getClassName(): string;
  8314. }
  8315. }
  8316. declare module BABYLON {
  8317. /**
  8318. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8319. * This is the base of the follow, arc rotate cameras and Free camera
  8320. * @see http://doc.babylonjs.com/features/cameras
  8321. */
  8322. class TargetCamera extends Camera {
  8323. private static _RigCamTransformMatrix;
  8324. private static _TargetTransformMatrix;
  8325. private static _TargetFocalPoint;
  8326. /**
  8327. * Define the current direction the camera is moving to
  8328. */
  8329. cameraDirection: Vector3;
  8330. /**
  8331. * Define the current rotation the camera is rotating to
  8332. */
  8333. cameraRotation: Vector2;
  8334. /**
  8335. * When set, the up vector of the camera will be updated by the rotation of the camera
  8336. */
  8337. updateUpVectorFromRotation: boolean;
  8338. private _tmpQuaternion;
  8339. /**
  8340. * Define the current rotation of the camera
  8341. */
  8342. rotation: Vector3;
  8343. /**
  8344. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8345. */
  8346. rotationQuaternion: Quaternion;
  8347. /**
  8348. * Define the current speed of the camera
  8349. */
  8350. speed: number;
  8351. /**
  8352. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8353. * around all axis.
  8354. */
  8355. noRotationConstraint: boolean;
  8356. /**
  8357. * Define the current target of the camera as an object or a position.
  8358. */
  8359. lockedTarget: any;
  8360. /** @hidden */
  8361. _currentTarget: Vector3;
  8362. /** @hidden */
  8363. _initialFocalDistance: number;
  8364. /** @hidden */
  8365. _viewMatrix: Matrix;
  8366. /** @hidden */
  8367. _camMatrix: Matrix;
  8368. /** @hidden */
  8369. _cameraTransformMatrix: Matrix;
  8370. /** @hidden */
  8371. _cameraRotationMatrix: Matrix;
  8372. /** @hidden */
  8373. _referencePoint: Vector3;
  8374. /** @hidden */
  8375. _transformedReferencePoint: Vector3;
  8376. protected _globalCurrentTarget: Vector3;
  8377. protected _globalCurrentUpVector: Vector3;
  8378. /** @hidden */
  8379. _reset: () => void;
  8380. private _defaultUp;
  8381. /**
  8382. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8383. * This is the base of the follow, arc rotate cameras and Free camera
  8384. * @see http://doc.babylonjs.com/features/cameras
  8385. * @param name Defines the name of the camera in the scene
  8386. * @param position Defines the start position of the camera in the scene
  8387. * @param scene Defines the scene the camera belongs to
  8388. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8389. */
  8390. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8391. /**
  8392. * Gets the position in front of the camera at a given distance.
  8393. * @param distance The distance from the camera we want the position to be
  8394. * @returns the position
  8395. */
  8396. getFrontPosition(distance: number): Vector3;
  8397. /** @hidden */
  8398. _getLockedTargetPosition(): Nullable<Vector3>;
  8399. private _storedPosition;
  8400. private _storedRotation;
  8401. private _storedRotationQuaternion;
  8402. /**
  8403. * Store current camera state of the camera (fov, position, rotation, etc..)
  8404. * @returns the camera
  8405. */
  8406. storeState(): Camera;
  8407. /**
  8408. * Restored camera state. You must call storeState() first
  8409. * @returns whether it was successful or not
  8410. * @hidden
  8411. */
  8412. _restoreStateValues(): boolean;
  8413. /** @hidden */
  8414. _initCache(): void;
  8415. /** @hidden */
  8416. _updateCache(ignoreParentClass?: boolean): void;
  8417. /** @hidden */
  8418. _isSynchronizedViewMatrix(): boolean;
  8419. /** @hidden */
  8420. _computeLocalCameraSpeed(): number;
  8421. /** @hidden */
  8422. setTarget(target: Vector3): void;
  8423. /**
  8424. * Return the current target position of the camera. This value is expressed in local space.
  8425. * @returns the target position
  8426. */
  8427. getTarget(): Vector3;
  8428. /** @hidden */
  8429. _decideIfNeedsToMove(): boolean;
  8430. /** @hidden */
  8431. _updatePosition(): void;
  8432. /** @hidden */
  8433. _checkInputs(): void;
  8434. protected _updateCameraRotationMatrix(): void;
  8435. /**
  8436. * 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)
  8437. * @returns the current camera
  8438. */
  8439. private _rotateUpVectorWithCameraRotationMatrix;
  8440. private _cachedRotationZ;
  8441. private _cachedQuaternionRotationZ;
  8442. /** @hidden */
  8443. _getViewMatrix(): Matrix;
  8444. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8445. /**
  8446. * @hidden
  8447. */
  8448. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8449. /**
  8450. * @hidden
  8451. */
  8452. _updateRigCameras(): void;
  8453. private _getRigCamPositionAndTarget;
  8454. /**
  8455. * Gets the current object class name.
  8456. * @return the class name
  8457. */
  8458. getClassName(): string;
  8459. }
  8460. }
  8461. declare module BABYLON {
  8462. /**
  8463. * This represents a FPS type of camera controlled by touch.
  8464. * This is like a universal camera minus the Gamepad controls.
  8465. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8466. */
  8467. class TouchCamera extends FreeCamera {
  8468. /**
  8469. * Defines the touch sensibility for rotation.
  8470. * The higher the faster.
  8471. */
  8472. touchAngularSensibility: number;
  8473. /**
  8474. * Defines the touch sensibility for move.
  8475. * The higher the faster.
  8476. */
  8477. touchMoveSensibility: number;
  8478. /**
  8479. * Instantiates a new touch camera.
  8480. * This represents a FPS type of camera controlled by touch.
  8481. * This is like a universal camera minus the Gamepad controls.
  8482. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8483. * @param name Define the name of the camera in the scene
  8484. * @param position Define the start position of the camera in the scene
  8485. * @param scene Define the scene the camera belongs to
  8486. */
  8487. constructor(name: string, position: Vector3, scene: Scene);
  8488. /**
  8489. * Gets the current object class name.
  8490. * @return the class name
  8491. */
  8492. getClassName(): string;
  8493. /** @hidden */
  8494. _setupInputs(): void;
  8495. }
  8496. }
  8497. declare module BABYLON {
  8498. /**
  8499. * 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,
  8500. * which still works and will still be found in many Playgrounds.
  8501. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8502. */
  8503. class UniversalCamera extends TouchCamera {
  8504. /**
  8505. * Defines the gamepad rotation sensiblity.
  8506. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  8507. */
  8508. gamepadAngularSensibility: number;
  8509. /**
  8510. * Defines the gamepad move sensiblity.
  8511. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  8512. */
  8513. gamepadMoveSensibility: number;
  8514. /**
  8515. * 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,
  8516. * which still works and will still be found in many Playgrounds.
  8517. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8518. * @param name Define the name of the camera in the scene
  8519. * @param position Define the start position of the camera in the scene
  8520. * @param scene Define the scene the camera belongs to
  8521. */
  8522. constructor(name: string, position: Vector3, scene: Scene);
  8523. /**
  8524. * Gets the current object class name.
  8525. * @return the class name
  8526. */
  8527. getClassName(): string;
  8528. }
  8529. }
  8530. declare module BABYLON {
  8531. /**
  8532. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  8533. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  8534. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  8535. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  8536. */
  8537. class VirtualJoysticksCamera extends FreeCamera {
  8538. /**
  8539. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  8540. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  8541. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  8542. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  8543. * @param name Define the name of the camera in the scene
  8544. * @param position Define the start position of the camera in the scene
  8545. * @param scene Define the scene the camera belongs to
  8546. */
  8547. constructor(name: string, position: Vector3, scene: Scene);
  8548. /**
  8549. * Gets the current object class name.
  8550. * @return the class name
  8551. */
  8552. getClassName(): string;
  8553. }
  8554. }
  8555. interface VRDisplay extends EventTarget {
  8556. /**
  8557. * Dictionary of capabilities describing the VRDisplay.
  8558. */
  8559. readonly capabilities: VRDisplayCapabilities;
  8560. /**
  8561. * z-depth defining the far plane of the eye view frustum
  8562. * enables mapping of values in the render target depth
  8563. * attachment to scene coordinates. Initially set to 10000.0.
  8564. */
  8565. depthFar: number;
  8566. /**
  8567. * z-depth defining the near plane of the eye view frustum
  8568. * enables mapping of values in the render target depth
  8569. * attachment to scene coordinates. Initially set to 0.01.
  8570. */
  8571. depthNear: number;
  8572. /**
  8573. * An identifier for this distinct VRDisplay. Used as an
  8574. * association point in the Gamepad API.
  8575. */
  8576. readonly displayId: number;
  8577. /**
  8578. * A display name, a user-readable name identifying it.
  8579. */
  8580. readonly displayName: string;
  8581. readonly isConnected: boolean;
  8582. readonly isPresenting: boolean;
  8583. /**
  8584. * If this VRDisplay supports room-scale experiences, the optional
  8585. * stage attribute contains details on the room-scale parameters.
  8586. */
  8587. readonly stageParameters: VRStageParameters | null;
  8588. /**
  8589. * Passing the value returned by `requestAnimationFrame` to
  8590. * `cancelAnimationFrame` will unregister the callback.
  8591. * @param handle Define the hanle of the request to cancel
  8592. */
  8593. cancelAnimationFrame(handle: number): void;
  8594. /**
  8595. * Stops presenting to the VRDisplay.
  8596. * @returns a promise to know when it stopped
  8597. */
  8598. exitPresent(): Promise<void>;
  8599. /**
  8600. * Return the current VREyeParameters for the given eye.
  8601. * @param whichEye Define the eye we want the parameter for
  8602. * @returns the eye parameters
  8603. */
  8604. getEyeParameters(whichEye: string): VREyeParameters;
  8605. /**
  8606. * Populates the passed VRFrameData with the information required to render
  8607. * the current frame.
  8608. * @param frameData Define the data structure to populate
  8609. * @returns true if ok otherwise false
  8610. */
  8611. getFrameData(frameData: VRFrameData): boolean;
  8612. /**
  8613. * Get the layers currently being presented.
  8614. * @returns the list of VR layers
  8615. */
  8616. getLayers(): VRLayer[];
  8617. /**
  8618. * Return a VRPose containing the future predicted pose of the VRDisplay
  8619. * when the current frame will be presented. The value returned will not
  8620. * change until JavaScript has returned control to the browser.
  8621. *
  8622. * The VRPose will contain the position, orientation, velocity,
  8623. * and acceleration of each of these properties.
  8624. * @returns the pose object
  8625. */
  8626. getPose(): VRPose;
  8627. /**
  8628. * Return the current instantaneous pose of the VRDisplay, with no
  8629. * prediction applied.
  8630. * @returns the current instantaneous pose
  8631. */
  8632. getImmediatePose(): VRPose;
  8633. /**
  8634. * The callback passed to `requestAnimationFrame` will be called
  8635. * any time a new frame should be rendered. When the VRDisplay is
  8636. * presenting the callback will be called at the native refresh
  8637. * rate of the HMD. When not presenting this function acts
  8638. * identically to how window.requestAnimationFrame acts. Content should
  8639. * make no assumptions of frame rate or vsync behavior as the HMD runs
  8640. * asynchronously from other displays and at differing refresh rates.
  8641. * @param callback Define the eaction to run next frame
  8642. * @returns the request handle it
  8643. */
  8644. requestAnimationFrame(callback: FrameRequestCallback): number;
  8645. /**
  8646. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  8647. * Repeat calls while already presenting will update the VRLayers being displayed.
  8648. * @param layers Define the list of layer to present
  8649. * @returns a promise to know when the request has been fulfilled
  8650. */
  8651. requestPresent(layers: VRLayer[]): Promise<void>;
  8652. /**
  8653. * Reset the pose for this display, treating its current position and
  8654. * orientation as the "origin/zero" values. VRPose.position,
  8655. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  8656. * updated when calling resetPose(). This should be called in only
  8657. * sitting-space experiences.
  8658. */
  8659. resetPose(): void;
  8660. /**
  8661. * The VRLayer provided to the VRDisplay will be captured and presented
  8662. * in the HMD. Calling this function has the same effect on the source
  8663. * canvas as any other operation that uses its source image, and canvases
  8664. * created without preserveDrawingBuffer set to true will be cleared.
  8665. * @param pose Define the pose to submit
  8666. */
  8667. submitFrame(pose?: VRPose): void;
  8668. }
  8669. declare var VRDisplay: {
  8670. prototype: VRDisplay;
  8671. new (): VRDisplay;
  8672. };
  8673. interface VRLayer {
  8674. leftBounds?: number[] | Float32Array | null;
  8675. rightBounds?: number[] | Float32Array | null;
  8676. source?: HTMLCanvasElement | null;
  8677. }
  8678. interface VRDisplayCapabilities {
  8679. readonly canPresent: boolean;
  8680. readonly hasExternalDisplay: boolean;
  8681. readonly hasOrientation: boolean;
  8682. readonly hasPosition: boolean;
  8683. readonly maxLayers: number;
  8684. }
  8685. interface VREyeParameters {
  8686. /** @deprecated */
  8687. readonly fieldOfView: VRFieldOfView;
  8688. readonly offset: Float32Array;
  8689. readonly renderHeight: number;
  8690. readonly renderWidth: number;
  8691. }
  8692. interface VRFieldOfView {
  8693. readonly downDegrees: number;
  8694. readonly leftDegrees: number;
  8695. readonly rightDegrees: number;
  8696. readonly upDegrees: number;
  8697. }
  8698. interface VRFrameData {
  8699. readonly leftProjectionMatrix: Float32Array;
  8700. readonly leftViewMatrix: Float32Array;
  8701. readonly pose: VRPose;
  8702. readonly rightProjectionMatrix: Float32Array;
  8703. readonly rightViewMatrix: Float32Array;
  8704. readonly timestamp: number;
  8705. }
  8706. interface VRPose {
  8707. readonly angularAcceleration: Float32Array | null;
  8708. readonly angularVelocity: Float32Array | null;
  8709. readonly linearAcceleration: Float32Array | null;
  8710. readonly linearVelocity: Float32Array | null;
  8711. readonly orientation: Float32Array | null;
  8712. readonly position: Float32Array | null;
  8713. readonly timestamp: number;
  8714. }
  8715. interface VRStageParameters {
  8716. sittingToStandingTransform?: Float32Array;
  8717. sizeX?: number;
  8718. sizeY?: number;
  8719. }
  8720. interface Navigator {
  8721. getVRDisplays(): Promise<VRDisplay[]>;
  8722. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  8723. }
  8724. interface Window {
  8725. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  8726. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  8727. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  8728. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  8729. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  8730. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  8731. }
  8732. interface Gamepad {
  8733. readonly displayId: number;
  8734. }
  8735. declare module BABYLON {
  8736. /** @hidden */
  8737. class Collider {
  8738. /** Define if a collision was found */
  8739. collisionFound: boolean;
  8740. /**
  8741. * Define last intersection point in local space
  8742. */
  8743. intersectionPoint: Vector3;
  8744. /**
  8745. * Define last collided mesh
  8746. */
  8747. collidedMesh: Nullable<AbstractMesh>;
  8748. private _collisionPoint;
  8749. private _planeIntersectionPoint;
  8750. private _tempVector;
  8751. private _tempVector2;
  8752. private _tempVector3;
  8753. private _tempVector4;
  8754. private _edge;
  8755. private _baseToVertex;
  8756. private _destinationPoint;
  8757. private _slidePlaneNormal;
  8758. private _displacementVector;
  8759. /** @hidden */
  8760. _radius: Vector3;
  8761. /** @hidden */
  8762. _retry: number;
  8763. private _velocity;
  8764. private _basePoint;
  8765. private _epsilon;
  8766. /** @hidden */
  8767. _velocityWorldLength: number;
  8768. /** @hidden */
  8769. _basePointWorld: Vector3;
  8770. private _velocityWorld;
  8771. private _normalizedVelocity;
  8772. /** @hidden */
  8773. _initialVelocity: Vector3;
  8774. /** @hidden */
  8775. _initialPosition: Vector3;
  8776. private _nearestDistance;
  8777. private _collisionMask;
  8778. collisionMask: number;
  8779. /**
  8780. * Gets the plane normal used to compute the sliding response (in local space)
  8781. */
  8782. readonly slidePlaneNormal: Vector3;
  8783. /** @hidden */
  8784. _initialize(source: Vector3, dir: Vector3, e: number): void;
  8785. /** @hidden */
  8786. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  8787. /** @hidden */
  8788. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  8789. /** @hidden */
  8790. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  8791. /** @hidden */
  8792. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  8793. /** @hidden */
  8794. _getResponse(pos: Vector3, vel: Vector3): void;
  8795. }
  8796. }
  8797. declare module BABYLON {
  8798. /** @hidden */
  8799. var CollisionWorker: string;
  8800. /** @hidden */
  8801. interface ICollisionCoordinator {
  8802. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  8803. init(scene: Scene): void;
  8804. destroy(): void;
  8805. onMeshAdded(mesh: AbstractMesh): void;
  8806. onMeshUpdated(mesh: AbstractMesh): void;
  8807. onMeshRemoved(mesh: AbstractMesh): void;
  8808. onGeometryAdded(geometry: Geometry): void;
  8809. onGeometryUpdated(geometry: Geometry): void;
  8810. onGeometryDeleted(geometry: Geometry): void;
  8811. }
  8812. /** @hidden */
  8813. interface SerializedMesh {
  8814. id: string;
  8815. name: string;
  8816. uniqueId: number;
  8817. geometryId: Nullable<string>;
  8818. sphereCenter: Array<number>;
  8819. sphereRadius: number;
  8820. boxMinimum: Array<number>;
  8821. boxMaximum: Array<number>;
  8822. worldMatrixFromCache: any;
  8823. subMeshes: Array<SerializedSubMesh>;
  8824. checkCollisions: boolean;
  8825. }
  8826. /** @hidden */
  8827. interface SerializedSubMesh {
  8828. position: number;
  8829. verticesStart: number;
  8830. verticesCount: number;
  8831. indexStart: number;
  8832. indexCount: number;
  8833. hasMaterial: boolean;
  8834. sphereCenter: Array<number>;
  8835. sphereRadius: number;
  8836. boxMinimum: Array<number>;
  8837. boxMaximum: Array<number>;
  8838. }
  8839. /**
  8840. * Interface describing the value associated with a geometry.
  8841. * @hidden
  8842. */
  8843. interface SerializedGeometry {
  8844. /**
  8845. * Defines the unique ID of the geometry
  8846. */
  8847. id: string;
  8848. /**
  8849. * Defines the array containing the positions
  8850. */
  8851. positions: Float32Array;
  8852. /**
  8853. * Defines the array containing the indices
  8854. */
  8855. indices: Uint32Array;
  8856. /**
  8857. * Defines the array containing the normals
  8858. */
  8859. normals: Float32Array;
  8860. }
  8861. /** @hidden */
  8862. interface BabylonMessage {
  8863. taskType: WorkerTaskType;
  8864. payload: InitPayload | CollidePayload | UpdatePayload;
  8865. }
  8866. /** @hidden */
  8867. interface SerializedColliderToWorker {
  8868. position: Array<number>;
  8869. velocity: Array<number>;
  8870. radius: Array<number>;
  8871. }
  8872. /** Defines supported task for worker process */
  8873. enum WorkerTaskType {
  8874. /** Initialization */
  8875. INIT = 0,
  8876. /** Update of geometry */
  8877. UPDATE = 1,
  8878. /** Evaluate collision */
  8879. COLLIDE = 2
  8880. }
  8881. /** @hidden */
  8882. interface WorkerReply {
  8883. error: WorkerReplyType;
  8884. taskType: WorkerTaskType;
  8885. payload?: any;
  8886. }
  8887. /** @hidden */
  8888. interface CollisionReplyPayload {
  8889. newPosition: Array<number>;
  8890. collisionId: number;
  8891. collidedMeshUniqueId: number;
  8892. }
  8893. /** @hidden */
  8894. interface InitPayload {
  8895. }
  8896. /** @hidden */
  8897. interface CollidePayload {
  8898. collisionId: number;
  8899. collider: SerializedColliderToWorker;
  8900. maximumRetry: number;
  8901. excludedMeshUniqueId: Nullable<number>;
  8902. }
  8903. /** @hidden */
  8904. interface UpdatePayload {
  8905. updatedMeshes: {
  8906. [n: number]: SerializedMesh;
  8907. };
  8908. updatedGeometries: {
  8909. [s: string]: SerializedGeometry;
  8910. };
  8911. removedMeshes: Array<number>;
  8912. removedGeometries: Array<string>;
  8913. }
  8914. /** Defines kind of replies returned by worker */
  8915. enum WorkerReplyType {
  8916. /** Success */
  8917. SUCCESS = 0,
  8918. /** Unkown error */
  8919. UNKNOWN_ERROR = 1
  8920. }
  8921. /** @hidden */
  8922. class CollisionCoordinatorWorker implements ICollisionCoordinator {
  8923. private _scene;
  8924. private _scaledPosition;
  8925. private _scaledVelocity;
  8926. private _collisionsCallbackArray;
  8927. private _init;
  8928. private _runningUpdated;
  8929. private _worker;
  8930. private _addUpdateMeshesList;
  8931. private _addUpdateGeometriesList;
  8932. private _toRemoveMeshesArray;
  8933. private _toRemoveGeometryArray;
  8934. constructor();
  8935. static SerializeMesh: (mesh: AbstractMesh) => SerializedMesh;
  8936. static SerializeGeometry: (geometry: Geometry) => SerializedGeometry;
  8937. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  8938. init(scene: Scene): void;
  8939. destroy(): void;
  8940. onMeshAdded(mesh: AbstractMesh): void;
  8941. onMeshUpdated: (transformNode: TransformNode) => void;
  8942. onMeshRemoved(mesh: AbstractMesh): void;
  8943. onGeometryAdded(geometry: Geometry): void;
  8944. onGeometryUpdated: (geometry: Geometry) => void;
  8945. onGeometryDeleted(geometry: Geometry): void;
  8946. private _afterRender;
  8947. private _onMessageFromWorker;
  8948. }
  8949. /** @hidden */
  8950. class CollisionCoordinatorLegacy implements ICollisionCoordinator {
  8951. private _scene;
  8952. private _scaledPosition;
  8953. private _scaledVelocity;
  8954. private _finalPosition;
  8955. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  8956. init(scene: Scene): void;
  8957. destroy(): void;
  8958. onMeshAdded(mesh: AbstractMesh): void;
  8959. onMeshUpdated(mesh: AbstractMesh): void;
  8960. onMeshRemoved(mesh: AbstractMesh): void;
  8961. onGeometryAdded(geometry: Geometry): void;
  8962. onGeometryUpdated(geometry: Geometry): void;
  8963. onGeometryDeleted(geometry: Geometry): void;
  8964. private _collideWithWorld;
  8965. }
  8966. }
  8967. declare function importScripts(...urls: string[]): void;
  8968. declare const safePostMessage: any;
  8969. declare module BABYLON {
  8970. /** @hidden */
  8971. var WorkerIncluded: boolean;
  8972. /** @hidden */
  8973. class CollisionCache {
  8974. private _meshes;
  8975. private _geometries;
  8976. getMeshes(): {
  8977. [n: number]: SerializedMesh;
  8978. };
  8979. getGeometries(): {
  8980. [s: number]: SerializedGeometry;
  8981. };
  8982. getMesh(id: any): SerializedMesh;
  8983. addMesh(mesh: SerializedMesh): void;
  8984. removeMesh(uniqueId: number): void;
  8985. getGeometry(id: string): SerializedGeometry;
  8986. addGeometry(geometry: SerializedGeometry): void;
  8987. removeGeometry(id: string): void;
  8988. }
  8989. /** @hidden */
  8990. class CollideWorker {
  8991. collider: Collider;
  8992. private _collisionCache;
  8993. private finalPosition;
  8994. private collisionsScalingMatrix;
  8995. private collisionTranformationMatrix;
  8996. constructor(collider: Collider, _collisionCache: CollisionCache, finalPosition: Vector3);
  8997. collideWithWorld(position: Vector3, velocity: Vector3, maximumRetry: number, excludedMeshUniqueId: Nullable<number>): void;
  8998. private checkCollision;
  8999. private processCollisionsForSubMeshes;
  9000. private collideForSubMesh;
  9001. private checkSubmeshCollision;
  9002. }
  9003. /** @hidden */
  9004. interface ICollisionDetector {
  9005. onInit(payload: InitPayload): void;
  9006. onUpdate(payload: UpdatePayload): void;
  9007. onCollision(payload: CollidePayload): void;
  9008. }
  9009. /** @hidden */
  9010. class CollisionDetectorTransferable implements ICollisionDetector {
  9011. private _collisionCache;
  9012. onInit(payload: InitPayload): void;
  9013. onUpdate(payload: UpdatePayload): void;
  9014. onCollision(payload: CollidePayload): void;
  9015. }
  9016. }
  9017. declare module BABYLON {
  9018. /**
  9019. * @hidden
  9020. */
  9021. class IntersectionInfo {
  9022. bu: Nullable<number>;
  9023. bv: Nullable<number>;
  9024. distance: number;
  9025. faceId: number;
  9026. subMeshId: number;
  9027. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  9028. }
  9029. /**
  9030. * Information about the result of picking within a scene
  9031. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  9032. */
  9033. class PickingInfo {
  9034. /**
  9035. * If the pick collided with an object
  9036. */
  9037. hit: boolean;
  9038. /**
  9039. * Distance away where the pick collided
  9040. */
  9041. distance: number;
  9042. /**
  9043. * The location of pick collision
  9044. */
  9045. pickedPoint: Nullable<Vector3>;
  9046. /**
  9047. * The mesh corresponding the the pick collision
  9048. */
  9049. pickedMesh: Nullable<AbstractMesh>;
  9050. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  9051. bu: number;
  9052. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  9053. bv: number;
  9054. /** The id of the face on the mesh that was picked */
  9055. faceId: number;
  9056. /** Id of the the submesh that was picked */
  9057. subMeshId: number;
  9058. /** If a sprite was picked, this will be the sprite the pick collided with */
  9059. pickedSprite: Nullable<Sprite>;
  9060. /**
  9061. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  9062. */
  9063. originMesh: Nullable<AbstractMesh>;
  9064. /**
  9065. * The ray that was used to perform the picking.
  9066. */
  9067. ray: Nullable<Ray>;
  9068. /**
  9069. * Gets the normal correspodning to the face the pick collided with
  9070. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  9071. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  9072. * @returns The normal correspodning to the face the pick collided with
  9073. */
  9074. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  9075. /**
  9076. * Gets the texture coordinates of where the pick occured
  9077. * @returns the vector containing the coordnates of the texture
  9078. */
  9079. getTextureCoordinates(): Nullable<Vector2>;
  9080. }
  9081. }
  9082. declare module BABYLON {
  9083. /**
  9084. * Class used to store bounding box information
  9085. */
  9086. class BoundingBox implements ICullable {
  9087. /**
  9088. * Gets the 8 vectors representing the bounding box in local space
  9089. */
  9090. readonly vectors: Vector3[];
  9091. /**
  9092. * Gets the center of the bounding box in local space
  9093. */
  9094. readonly center: Vector3;
  9095. /**
  9096. * Gets the center of the bounding box in world space
  9097. */
  9098. readonly centerWorld: Vector3;
  9099. /**
  9100. * Gets the extend size in local space
  9101. */
  9102. readonly extendSize: Vector3;
  9103. /**
  9104. * Gets the extend size in world space
  9105. */
  9106. readonly extendSizeWorld: Vector3;
  9107. /**
  9108. * Gets the OBB (object bounding box) directions
  9109. */
  9110. readonly directions: Vector3[];
  9111. /**
  9112. * Gets the 8 vectors representing the bounding box in world space
  9113. */
  9114. readonly vectorsWorld: Vector3[];
  9115. /**
  9116. * Gets the minimum vector in world space
  9117. */
  9118. readonly minimumWorld: Vector3;
  9119. /**
  9120. * Gets the maximum vector in world space
  9121. */
  9122. readonly maximumWorld: Vector3;
  9123. /**
  9124. * Gets the minimum vector in local space
  9125. */
  9126. readonly minimum: Vector3;
  9127. /**
  9128. * Gets the maximum vector in local space
  9129. */
  9130. readonly maximum: Vector3;
  9131. private _worldMatrix;
  9132. private static readonly TmpVector3;
  9133. /**
  9134. * @hidden
  9135. */
  9136. _tag: number;
  9137. /**
  9138. * Creates a new bounding box
  9139. * @param min defines the minimum vector (in local space)
  9140. * @param max defines the maximum vector (in local space)
  9141. * @param worldMatrix defines the new world matrix
  9142. */
  9143. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  9144. /**
  9145. * Recreates the entire bounding box from scratch as if we call the constructor in place
  9146. * @param min defines the new minimum vector (in local space)
  9147. * @param max defines the new maximum vector (in local space)
  9148. * @param worldMatrix defines the new world matrix
  9149. */
  9150. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  9151. /**
  9152. * Scale the current bounding box by applying a scale factor
  9153. * @param factor defines the scale factor to apply
  9154. * @returns the current bounding box
  9155. */
  9156. scale(factor: number): BoundingBox;
  9157. /**
  9158. * Gets the world matrix of the bounding box
  9159. * @returns a matrix
  9160. */
  9161. getWorldMatrix(): DeepImmutable<Matrix>;
  9162. /** @hidden */
  9163. _update(world: DeepImmutable<Matrix>): void;
  9164. /**
  9165. * Tests if the bounding box is intersecting the frustum planes
  9166. * @param frustumPlanes defines the frustum planes to test
  9167. * @returns true if there is an intersection
  9168. */
  9169. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  9170. /**
  9171. * Tests if the bounding box is entirely inside the frustum planes
  9172. * @param frustumPlanes defines the frustum planes to test
  9173. * @returns true if there is an inclusion
  9174. */
  9175. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  9176. /**
  9177. * Tests if a point is inside the bounding box
  9178. * @param point defines the point to test
  9179. * @returns true if the point is inside the bounding box
  9180. */
  9181. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  9182. /**
  9183. * Tests if the bounding box intersects with a bounding sphere
  9184. * @param sphere defines the sphere to test
  9185. * @returns true if there is an intersection
  9186. */
  9187. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  9188. /**
  9189. * Tests if the bounding box intersects with a box defined by a min and max vectors
  9190. * @param min defines the min vector to use
  9191. * @param max defines the max vector to use
  9192. * @returns true if there is an intersection
  9193. */
  9194. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  9195. /**
  9196. * Tests if two bounding boxes are intersections
  9197. * @param box0 defines the first box to test
  9198. * @param box1 defines the second box to test
  9199. * @returns true if there is an intersection
  9200. */
  9201. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  9202. /**
  9203. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  9204. * @param minPoint defines the minimum vector of the bounding box
  9205. * @param maxPoint defines the maximum vector of the bounding box
  9206. * @param sphereCenter defines the sphere center
  9207. * @param sphereRadius defines the sphere radius
  9208. * @returns true if there is an intersection
  9209. */
  9210. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  9211. /**
  9212. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  9213. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  9214. * @param frustumPlanes defines the frustum planes to test
  9215. * @return true if there is an inclusion
  9216. */
  9217. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  9218. /**
  9219. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  9220. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  9221. * @param frustumPlanes defines the frustum planes to test
  9222. * @return true if there is an intersection
  9223. */
  9224. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  9225. }
  9226. }
  9227. declare module BABYLON {
  9228. /**
  9229. * Interface for cullable objects
  9230. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  9231. */
  9232. interface ICullable {
  9233. /**
  9234. * Checks if the object or part of the object is in the frustum
  9235. * @param frustumPlanes Camera near/planes
  9236. * @returns true if the object is in frustum otherwise false
  9237. */
  9238. isInFrustum(frustumPlanes: Plane[]): boolean;
  9239. /**
  9240. * Checks if a cullable object (mesh...) is in the camera frustum
  9241. * Unlike isInFrustum this cheks the full bounding box
  9242. * @param frustumPlanes Camera near/planes
  9243. * @returns true if the object is in frustum otherwise false
  9244. */
  9245. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  9246. }
  9247. /**
  9248. * Info for a bounding data of a mesh
  9249. */
  9250. class BoundingInfo implements ICullable {
  9251. /**
  9252. * Bounding box for the mesh
  9253. */
  9254. readonly boundingBox: BoundingBox;
  9255. /**
  9256. * Bounding sphere for the mesh
  9257. */
  9258. readonly boundingSphere: BoundingSphere;
  9259. private _isLocked;
  9260. private static readonly TmpVector3;
  9261. /**
  9262. * Constructs bounding info
  9263. * @param minimum min vector of the bounding box/sphere
  9264. * @param maximum max vector of the bounding box/sphere
  9265. * @param worldMatrix defines the new world matrix
  9266. */
  9267. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  9268. /**
  9269. * Recreates the entire bounding info from scratch as if we call the constructor in place
  9270. * @param min defines the new minimum vector (in local space)
  9271. * @param max defines the new maximum vector (in local space)
  9272. * @param worldMatrix defines the new world matrix
  9273. */
  9274. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  9275. /**
  9276. * min vector of the bounding box/sphere
  9277. */
  9278. readonly minimum: Vector3;
  9279. /**
  9280. * max vector of the bounding box/sphere
  9281. */
  9282. readonly maximum: Vector3;
  9283. /**
  9284. * If the info is locked and won't be updated to avoid perf overhead
  9285. */
  9286. isLocked: boolean;
  9287. /**
  9288. * Updates the bounding sphere and box
  9289. * @param world world matrix to be used to update
  9290. */
  9291. update(world: DeepImmutable<Matrix>): void;
  9292. /**
  9293. * Recreate the bounding info to be centered around a specific point given a specific extend.
  9294. * @param center New center of the bounding info
  9295. * @param extend New extend of the bounding info
  9296. * @returns the current bounding info
  9297. */
  9298. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  9299. /**
  9300. * Scale the current bounding info by applying a scale factor
  9301. * @param factor defines the scale factor to apply
  9302. * @returns the current bounding info
  9303. */
  9304. scale(factor: number): BoundingInfo;
  9305. /**
  9306. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  9307. * @param frustumPlanes defines the frustum to test
  9308. * @param strategy defines the strategy to use for the culling (default is BABYLON.Scene.CULLINGSTRATEGY_STANDARD)
  9309. * @returns true if the bounding info is in the frustum planes
  9310. */
  9311. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  9312. /**
  9313. * Gets the world distance between the min and max points of the bounding box
  9314. */
  9315. readonly diagonalLength: number;
  9316. /**
  9317. * Checks if a cullable object (mesh...) is in the camera frustum
  9318. * Unlike isInFrustum this cheks the full bounding box
  9319. * @param frustumPlanes Camera near/planes
  9320. * @returns true if the object is in frustum otherwise false
  9321. */
  9322. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  9323. /** @hidden */
  9324. _checkCollision(collider: Collider): boolean;
  9325. /**
  9326. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  9327. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  9328. * @param point the point to check intersection with
  9329. * @returns if the point intersects
  9330. */
  9331. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  9332. /**
  9333. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  9334. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  9335. * @param boundingInfo the bounding info to check intersection with
  9336. * @param precise if the intersection should be done using OBB
  9337. * @returns if the bounding info intersects
  9338. */
  9339. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  9340. }
  9341. }
  9342. declare module BABYLON {
  9343. /**
  9344. * Class used to store bounding sphere information
  9345. */
  9346. class BoundingSphere {
  9347. /**
  9348. * Gets the center of the bounding sphere in local space
  9349. */
  9350. readonly center: Vector3;
  9351. /**
  9352. * Radius of the bounding sphere in local space
  9353. */
  9354. radius: number;
  9355. /**
  9356. * Gets the center of the bounding sphere in world space
  9357. */
  9358. readonly centerWorld: Vector3;
  9359. /**
  9360. * Radius of the bounding sphere in world space
  9361. */
  9362. radiusWorld: number;
  9363. /**
  9364. * Gets the minimum vector in local space
  9365. */
  9366. readonly minimum: Vector3;
  9367. /**
  9368. * Gets the maximum vector in local space
  9369. */
  9370. readonly maximum: Vector3;
  9371. private _worldMatrix;
  9372. private static readonly TmpVector3;
  9373. /**
  9374. * Creates a new bounding sphere
  9375. * @param min defines the minimum vector (in local space)
  9376. * @param max defines the maximum vector (in local space)
  9377. * @param worldMatrix defines the new world matrix
  9378. */
  9379. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  9380. /**
  9381. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  9382. * @param min defines the new minimum vector (in local space)
  9383. * @param max defines the new maximum vector (in local space)
  9384. * @param worldMatrix defines the new world matrix
  9385. */
  9386. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  9387. /**
  9388. * Scale the current bounding sphere by applying a scale factor
  9389. * @param factor defines the scale factor to apply
  9390. * @returns the current bounding box
  9391. */
  9392. scale(factor: number): BoundingSphere;
  9393. /**
  9394. * Gets the world matrix of the bounding box
  9395. * @returns a matrix
  9396. */
  9397. getWorldMatrix(): DeepImmutable<Matrix>;
  9398. /** @hidden */
  9399. _update(worldMatrix: DeepImmutable<Matrix>): void;
  9400. /**
  9401. * Tests if the bounding sphere is intersecting the frustum planes
  9402. * @param frustumPlanes defines the frustum planes to test
  9403. * @returns true if there is an intersection
  9404. */
  9405. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  9406. /**
  9407. * Tests if a point is inside the bounding sphere
  9408. * @param point defines the point to test
  9409. * @returns true if the point is inside the bounding sphere
  9410. */
  9411. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  9412. /**
  9413. * Checks if two sphere intersct
  9414. * @param sphere0 sphere 0
  9415. * @param sphere1 sphere 1
  9416. * @returns true if the speres intersect
  9417. */
  9418. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  9419. }
  9420. }
  9421. declare module BABYLON {
  9422. /**
  9423. * Class representing a ray with position and direction
  9424. */
  9425. class Ray {
  9426. /** origin point */
  9427. origin: Vector3;
  9428. /** direction */
  9429. direction: Vector3;
  9430. /** length of the ray */
  9431. length: number;
  9432. private static readonly TmpVector3;
  9433. private _tmpRay;
  9434. /**
  9435. * Creates a new ray
  9436. * @param origin origin point
  9437. * @param direction direction
  9438. * @param length length of the ray
  9439. */
  9440. constructor(
  9441. /** origin point */
  9442. origin: Vector3,
  9443. /** direction */
  9444. direction: Vector3,
  9445. /** length of the ray */
  9446. length?: number);
  9447. /**
  9448. * Checks if the ray intersects a box
  9449. * @param minimum bound of the box
  9450. * @param maximum bound of the box
  9451. * @param intersectionTreshold extra extend to be added to the box in all direction
  9452. * @returns if the box was hit
  9453. */
  9454. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  9455. /**
  9456. * Checks if the ray intersects a box
  9457. * @param box the bounding box to check
  9458. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  9459. * @returns if the box was hit
  9460. */
  9461. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  9462. /**
  9463. * If the ray hits a sphere
  9464. * @param sphere the bounding sphere to check
  9465. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  9466. * @returns true if it hits the sphere
  9467. */
  9468. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  9469. /**
  9470. * If the ray hits a triange
  9471. * @param vertex0 triangle vertex
  9472. * @param vertex1 triangle vertex
  9473. * @param vertex2 triangle vertex
  9474. * @returns intersection information if hit
  9475. */
  9476. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  9477. /**
  9478. * Checks if ray intersects a plane
  9479. * @param plane the plane to check
  9480. * @returns the distance away it was hit
  9481. */
  9482. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  9483. /**
  9484. * Checks if ray intersects a mesh
  9485. * @param mesh the mesh to check
  9486. * @param fastCheck if only the bounding box should checked
  9487. * @returns picking info of the intersecton
  9488. */
  9489. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  9490. /**
  9491. * Checks if ray intersects a mesh
  9492. * @param meshes the meshes to check
  9493. * @param fastCheck if only the bounding box should checked
  9494. * @param results array to store result in
  9495. * @returns Array of picking infos
  9496. */
  9497. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  9498. private _comparePickingInfo;
  9499. private static smallnum;
  9500. private static rayl;
  9501. /**
  9502. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  9503. * @param sega the first point of the segment to test the intersection against
  9504. * @param segb the second point of the segment to test the intersection against
  9505. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  9506. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  9507. */
  9508. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  9509. /**
  9510. * Update the ray from viewport position
  9511. * @param x position
  9512. * @param y y position
  9513. * @param viewportWidth viewport width
  9514. * @param viewportHeight viewport height
  9515. * @param world world matrix
  9516. * @param view view matrix
  9517. * @param projection projection matrix
  9518. * @returns this ray updated
  9519. */
  9520. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9521. /**
  9522. * Creates a ray with origin and direction of 0,0,0
  9523. * @returns the new ray
  9524. */
  9525. static Zero(): Ray;
  9526. /**
  9527. * Creates a new ray from screen space and viewport
  9528. * @param x position
  9529. * @param y y position
  9530. * @param viewportWidth viewport width
  9531. * @param viewportHeight viewport height
  9532. * @param world world matrix
  9533. * @param view view matrix
  9534. * @param projection projection matrix
  9535. * @returns new ray
  9536. */
  9537. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9538. /**
  9539. * 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
  9540. * transformed to the given world matrix.
  9541. * @param origin The origin point
  9542. * @param end The end point
  9543. * @param world a matrix to transform the ray to. Default is the identity matrix.
  9544. * @returns the new ray
  9545. */
  9546. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  9547. /**
  9548. * Transforms a ray by a matrix
  9549. * @param ray ray to transform
  9550. * @param matrix matrix to apply
  9551. * @returns the resulting new ray
  9552. */
  9553. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  9554. /**
  9555. * Transforms a ray by a matrix
  9556. * @param ray ray to transform
  9557. * @param matrix matrix to apply
  9558. * @param result ray to store result in
  9559. */
  9560. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  9561. }
  9562. }
  9563. /**
  9564. * Module Debug contains the (visual) components to debug a scene correctly
  9565. */
  9566. declare module BABYLON.Debug {
  9567. /**
  9568. * The Axes viewer will show 3 axes in a specific point in space
  9569. */
  9570. class AxesViewer {
  9571. private _xAxis;
  9572. private _yAxis;
  9573. private _zAxis;
  9574. private _scaleLinesFactor;
  9575. private _instanced;
  9576. /**
  9577. * Gets the hosting scene
  9578. */
  9579. scene: Scene;
  9580. /**
  9581. * Gets or sets a number used to scale line length
  9582. */
  9583. scaleLines: number;
  9584. /** Gets the node hierarchy used to render x-axis */
  9585. readonly xAxis: TransformNode;
  9586. /** Gets the node hierarchy used to render y-axis */
  9587. readonly yAxis: TransformNode;
  9588. /** Gets the node hierarchy used to render z-axis */
  9589. readonly zAxis: TransformNode;
  9590. /**
  9591. * Creates a new AxesViewer
  9592. * @param scene defines the hosting scene
  9593. * @param scaleLines defines a number used to scale line length (1 by default)
  9594. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  9595. * @param xAxis defines the node hierarchy used to render the x-axis
  9596. * @param yAxis defines the node hierarchy used to render the y-axis
  9597. * @param zAxis defines the node hierarchy used to render the z-axis
  9598. */
  9599. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  9600. /**
  9601. * Force the viewer to update
  9602. * @param position defines the position of the viewer
  9603. * @param xaxis defines the x axis of the viewer
  9604. * @param yaxis defines the y axis of the viewer
  9605. * @param zaxis defines the z axis of the viewer
  9606. */
  9607. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  9608. /**
  9609. * Creates an instance of this axes viewer.
  9610. * @returns a new axes viewer with instanced meshes
  9611. */
  9612. createInstance(): AxesViewer;
  9613. /** Releases resources */
  9614. dispose(): void;
  9615. private static _SetRenderingGroupId;
  9616. }
  9617. }
  9618. declare module BABYLON.Debug {
  9619. /**
  9620. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  9621. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  9622. */
  9623. class BoneAxesViewer extends AxesViewer {
  9624. /**
  9625. * Gets or sets the target mesh where to display the axes viewer
  9626. */
  9627. mesh: Nullable<Mesh>;
  9628. /**
  9629. * Gets or sets the target bone where to display the axes viewer
  9630. */
  9631. bone: Nullable<Bone>;
  9632. /** Gets current position */
  9633. pos: Vector3;
  9634. /** Gets direction of X axis */
  9635. xaxis: Vector3;
  9636. /** Gets direction of Y axis */
  9637. yaxis: Vector3;
  9638. /** Gets direction of Z axis */
  9639. zaxis: Vector3;
  9640. /**
  9641. * Creates a new BoneAxesViewer
  9642. * @param scene defines the hosting scene
  9643. * @param bone defines the target bone
  9644. * @param mesh defines the target mesh
  9645. * @param scaleLines defines a scaling factor for line length (1 by default)
  9646. */
  9647. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  9648. /**
  9649. * Force the viewer to update
  9650. */
  9651. update(): void;
  9652. /** Releases resources */
  9653. dispose(): void;
  9654. }
  9655. }
  9656. declare module BABYLON {
  9657. /**
  9658. * Interface used to define scene explorer extensibility option
  9659. */
  9660. interface IExplorerExtensibilityOption {
  9661. /**
  9662. * Define the option label
  9663. */
  9664. label: string;
  9665. /**
  9666. * Defines the action to execute on click
  9667. */
  9668. action: (entity: any) => void;
  9669. }
  9670. /**
  9671. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  9672. */
  9673. interface IExplorerExtensibilityGroup {
  9674. /**
  9675. * Defines a predicate to test if a given type mut be extended
  9676. */
  9677. predicate: (entity: any) => boolean;
  9678. /**
  9679. * Gets the list of options added to a type
  9680. */
  9681. entries: IExplorerExtensibilityOption[];
  9682. }
  9683. /**
  9684. * Interface used to define the options to use to create the Inspector
  9685. */
  9686. interface IInspectorOptions {
  9687. /**
  9688. * Display in overlay mode (default: false)
  9689. */
  9690. overlay?: boolean;
  9691. /**
  9692. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  9693. */
  9694. globalRoot?: HTMLElement;
  9695. /**
  9696. * Display the Scene explorer
  9697. */
  9698. showExplorer?: boolean;
  9699. /**
  9700. * Display the property inspector
  9701. */
  9702. showInspector?: boolean;
  9703. /**
  9704. * Display in embed mode (both panes on the right)
  9705. */
  9706. embedMode?: boolean;
  9707. /**
  9708. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  9709. */
  9710. handleResize?: boolean;
  9711. /**
  9712. * Allow the panes to popup (default: true)
  9713. */
  9714. enablePopup?: boolean;
  9715. /**
  9716. * Allow the panes to be closed by users (default: true)
  9717. */
  9718. enableClose?: boolean;
  9719. /**
  9720. * Optional list of extensibility entries
  9721. */
  9722. explorerExtensibility?: IExplorerExtensibilityGroup[];
  9723. }
  9724. interface Scene {
  9725. /**
  9726. * @hidden
  9727. * Backing field
  9728. */
  9729. _debugLayer: DebugLayer;
  9730. /**
  9731. * Gets the debug layer (aka Inspector) associated with the scene
  9732. * @see http://doc.babylonjs.com/features/playground_debuglayer
  9733. */
  9734. debugLayer: DebugLayer;
  9735. }
  9736. /**
  9737. * The debug layer (aka Inspector) is the go to tool in order to better understand
  9738. * what is happening in your scene
  9739. * @see http://doc.babylonjs.com/features/playground_debuglayer
  9740. */
  9741. class DebugLayer {
  9742. /**
  9743. * Define the url to get the inspector script from.
  9744. * By default it uses the babylonjs CDN.
  9745. * @ignoreNaming
  9746. */
  9747. static InspectorURL: string;
  9748. private _scene;
  9749. private BJSINSPECTOR;
  9750. /**
  9751. * Observable triggered when a property is changed through the inspector.
  9752. */
  9753. onPropertyChangedObservable: Observable<{
  9754. object: any;
  9755. property: string;
  9756. value: any;
  9757. initialValue: any;
  9758. }>;
  9759. /**
  9760. * Instantiates a new debug layer.
  9761. * The debug layer (aka Inspector) is the go to tool in order to better understand
  9762. * what is happening in your scene
  9763. * @see http://doc.babylonjs.com/features/playground_debuglayer
  9764. * @param scene Defines the scene to inspect
  9765. */
  9766. constructor(scene: Scene);
  9767. /** Creates the inspector window. */
  9768. private _createInspector;
  9769. /**
  9770. * Get if the inspector is visible or not.
  9771. * @returns true if visible otherwise, false
  9772. */
  9773. isVisible(): boolean;
  9774. /**
  9775. * Hide the inspector and close its window.
  9776. */
  9777. hide(): void;
  9778. /**
  9779. * Launch the debugLayer.
  9780. * @param config Define the configuration of the inspector
  9781. */
  9782. show(config?: IInspectorOptions): void;
  9783. }
  9784. }
  9785. declare module BABYLON.Debug {
  9786. /**
  9787. * Used to show the physics impostor around the specific mesh
  9788. */
  9789. class PhysicsViewer {
  9790. /** @hidden */
  9791. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  9792. /** @hidden */
  9793. protected _meshes: Array<Nullable<AbstractMesh>>;
  9794. /** @hidden */
  9795. protected _scene: Nullable<Scene>;
  9796. /** @hidden */
  9797. protected _numMeshes: number;
  9798. /** @hidden */
  9799. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  9800. private _renderFunction;
  9801. private _utilityLayer;
  9802. private _debugBoxMesh;
  9803. private _debugSphereMesh;
  9804. private _debugMaterial;
  9805. /**
  9806. * Creates a new PhysicsViewer
  9807. * @param scene defines the hosting scene
  9808. */
  9809. constructor(scene: Scene);
  9810. /** @hidden */
  9811. protected _updateDebugMeshes(): void;
  9812. /**
  9813. * Renders a specified physic impostor
  9814. * @param impostor defines the impostor to render
  9815. * @returns the new debug mesh used to render the impostor
  9816. */
  9817. showImpostor(impostor: PhysicsImpostor): Nullable<AbstractMesh>;
  9818. /**
  9819. * Hides a specified physic impostor
  9820. * @param impostor defines the impostor to hide
  9821. */
  9822. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  9823. private _getDebugMaterial;
  9824. private _getDebugBoxMesh;
  9825. private _getDebugSphereMesh;
  9826. private _getDebugMesh;
  9827. /** Releases all resources */
  9828. dispose(): void;
  9829. }
  9830. }
  9831. declare module BABYLON {
  9832. /**
  9833. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  9834. * in order to better appreciate the issue one might have.
  9835. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  9836. */
  9837. class RayHelper {
  9838. /**
  9839. * Defines the ray we are currently tryin to visualize.
  9840. */
  9841. ray: Nullable<Ray>;
  9842. private _renderPoints;
  9843. private _renderLine;
  9844. private _renderFunction;
  9845. private _scene;
  9846. private _updateToMeshFunction;
  9847. private _attachedToMesh;
  9848. private _meshSpaceDirection;
  9849. private _meshSpaceOrigin;
  9850. /**
  9851. * Helper function to create a colored helper in a scene in one line.
  9852. * @param ray Defines the ray we are currently tryin to visualize
  9853. * @param scene Defines the scene the ray is used in
  9854. * @param color Defines the color we want to see the ray in
  9855. * @returns The newly created ray helper.
  9856. */
  9857. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  9858. /**
  9859. * Instantiate a new ray helper.
  9860. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  9861. * in order to better appreciate the issue one might have.
  9862. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  9863. * @param ray Defines the ray we are currently tryin to visualize
  9864. */
  9865. constructor(ray: Ray);
  9866. /**
  9867. * Shows the ray we are willing to debug.
  9868. * @param scene Defines the scene the ray needs to be rendered in
  9869. * @param color Defines the color the ray needs to be rendered in
  9870. */
  9871. show(scene: Scene, color?: Color3): void;
  9872. /**
  9873. * Hides the ray we are debugging.
  9874. */
  9875. hide(): void;
  9876. private _render;
  9877. /**
  9878. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  9879. * @param mesh Defines the mesh we want the helper attached to
  9880. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  9881. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  9882. * @param length Defines the length of the ray
  9883. */
  9884. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  9885. /**
  9886. * Detach the ray helper from the mesh it has previously been attached to.
  9887. */
  9888. detachFromMesh(): void;
  9889. private _updateToMesh;
  9890. /**
  9891. * Dispose the helper and release its associated resources.
  9892. */
  9893. dispose(): void;
  9894. }
  9895. }
  9896. declare module BABYLON.Debug {
  9897. /**
  9898. * Class used to render a debug view of a given skeleton
  9899. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  9900. */
  9901. class SkeletonViewer {
  9902. /** defines the skeleton to render */
  9903. skeleton: Skeleton;
  9904. /** defines the mesh attached to the skeleton */
  9905. mesh: AbstractMesh;
  9906. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  9907. autoUpdateBonesMatrices: boolean;
  9908. /** defines the rendering group id to use with the viewer */
  9909. renderingGroupId: number;
  9910. /** Gets or sets the color used to render the skeleton */
  9911. color: Color3;
  9912. private _scene;
  9913. private _debugLines;
  9914. private _debugMesh;
  9915. private _isEnabled;
  9916. private _renderFunction;
  9917. private _utilityLayer;
  9918. /**
  9919. * Returns the mesh used to render the bones
  9920. */
  9921. readonly debugMesh: Nullable<LinesMesh>;
  9922. /**
  9923. * Creates a new SkeletonViewer
  9924. * @param skeleton defines the skeleton to render
  9925. * @param mesh defines the mesh attached to the skeleton
  9926. * @param scene defines the hosting scene
  9927. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  9928. * @param renderingGroupId defines the rendering group id to use with the viewer
  9929. */
  9930. constructor(
  9931. /** defines the skeleton to render */
  9932. skeleton: Skeleton,
  9933. /** defines the mesh attached to the skeleton */
  9934. mesh: AbstractMesh, scene: Scene,
  9935. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  9936. autoUpdateBonesMatrices?: boolean,
  9937. /** defines the rendering group id to use with the viewer */
  9938. renderingGroupId?: number);
  9939. /** Gets or sets a boolean indicating if the viewer is enabled */
  9940. isEnabled: boolean;
  9941. private _getBonePosition;
  9942. private _getLinesForBonesWithLength;
  9943. private _getLinesForBonesNoLength;
  9944. /** Update the viewer to sync with current skeleton state */
  9945. update(): void;
  9946. /** Release associated resources */
  9947. dispose(): void;
  9948. }
  9949. }
  9950. declare module BABYLON {
  9951. /**
  9952. * Interface for attribute information associated with buffer instanciation
  9953. */
  9954. class InstancingAttributeInfo {
  9955. /**
  9956. * Index/offset of the attribute in the vertex shader
  9957. */
  9958. index: number;
  9959. /**
  9960. * size of the attribute, 1, 2, 3 or 4
  9961. */
  9962. attributeSize: number;
  9963. /**
  9964. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  9965. * default is FLOAT
  9966. */
  9967. attribyteType: number;
  9968. /**
  9969. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  9970. */
  9971. normalized: boolean;
  9972. /**
  9973. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  9974. */
  9975. offset: number;
  9976. /**
  9977. * Name of the GLSL attribute, for debugging purpose only
  9978. */
  9979. attributeName: string;
  9980. }
  9981. /**
  9982. * Define options used to create a render target texture
  9983. */
  9984. class RenderTargetCreationOptions {
  9985. /**
  9986. * Specifies is mipmaps must be generated
  9987. */
  9988. generateMipMaps?: boolean;
  9989. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  9990. generateDepthBuffer?: boolean;
  9991. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  9992. generateStencilBuffer?: boolean;
  9993. /** Defines texture type (int by default) */
  9994. type?: number;
  9995. /** Defines sampling mode (trilinear by default) */
  9996. samplingMode?: number;
  9997. /** Defines format (RGBA by default) */
  9998. format?: number;
  9999. }
  10000. /**
  10001. * Define options used to create a depth texture
  10002. */
  10003. class DepthTextureCreationOptions {
  10004. /** Specifies whether or not a stencil should be allocated in the texture */
  10005. generateStencil?: boolean;
  10006. /** Specifies whether or not bilinear filtering is enable on the texture */
  10007. bilinearFiltering?: boolean;
  10008. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  10009. comparisonFunction?: number;
  10010. /** Specifies if the created texture is a cube texture */
  10011. isCube?: boolean;
  10012. }
  10013. /**
  10014. * Class used to describe the capabilities of the engine relatively to the current browser
  10015. */
  10016. class EngineCapabilities {
  10017. /** Maximum textures units per fragment shader */
  10018. maxTexturesImageUnits: number;
  10019. /** Maximum texture units per vertex shader */
  10020. maxVertexTextureImageUnits: number;
  10021. /** Maximum textures units in the entire pipeline */
  10022. maxCombinedTexturesImageUnits: number;
  10023. /** Maximum texture size */
  10024. maxTextureSize: number;
  10025. /** Maximum cube texture size */
  10026. maxCubemapTextureSize: number;
  10027. /** Maximum render texture size */
  10028. maxRenderTextureSize: number;
  10029. /** Maximum number of vertex attributes */
  10030. maxVertexAttribs: number;
  10031. /** Maximum number of varyings */
  10032. maxVaryingVectors: number;
  10033. /** Maximum number of uniforms per vertex shader */
  10034. maxVertexUniformVectors: number;
  10035. /** Maximum number of uniforms per fragment shader */
  10036. maxFragmentUniformVectors: number;
  10037. /** Defines if standard derivates (dx/dy) are supported */
  10038. standardDerivatives: boolean;
  10039. /** Defines if s3tc texture compression is supported */
  10040. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  10041. /** Defines if pvrtc texture compression is supported */
  10042. pvrtc: any;
  10043. /** Defines if etc1 texture compression is supported */
  10044. etc1: any;
  10045. /** Defines if etc2 texture compression is supported */
  10046. etc2: any;
  10047. /** Defines if astc texture compression is supported */
  10048. astc: any;
  10049. /** Defines if float textures are supported */
  10050. textureFloat: boolean;
  10051. /** Defines if vertex array objects are supported */
  10052. vertexArrayObject: boolean;
  10053. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  10054. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  10055. /** Gets the maximum level of anisotropy supported */
  10056. maxAnisotropy: number;
  10057. /** Defines if instancing is supported */
  10058. instancedArrays: boolean;
  10059. /** Defines if 32 bits indices are supported */
  10060. uintIndices: boolean;
  10061. /** Defines if high precision shaders are supported */
  10062. highPrecisionShaderSupported: boolean;
  10063. /** Defines if depth reading in the fragment shader is supported */
  10064. fragmentDepthSupported: boolean;
  10065. /** Defines if float texture linear filtering is supported*/
  10066. textureFloatLinearFiltering: boolean;
  10067. /** Defines if rendering to float textures is supported */
  10068. textureFloatRender: boolean;
  10069. /** Defines if half float textures are supported*/
  10070. textureHalfFloat: boolean;
  10071. /** Defines if half float texture linear filtering is supported*/
  10072. textureHalfFloatLinearFiltering: boolean;
  10073. /** Defines if rendering to half float textures is supported */
  10074. textureHalfFloatRender: boolean;
  10075. /** Defines if textureLOD shader command is supported */
  10076. textureLOD: boolean;
  10077. /** Defines if draw buffers extension is supported */
  10078. drawBuffersExtension: boolean;
  10079. /** Defines if depth textures are supported */
  10080. depthTextureExtension: boolean;
  10081. /** Defines if float color buffer are supported */
  10082. colorBufferFloat: boolean;
  10083. /** Gets disjoint timer query extension (null if not supported) */
  10084. timerQuery: EXT_disjoint_timer_query;
  10085. /** Defines if timestamp can be used with timer query */
  10086. canUseTimestampForTimerQuery: boolean;
  10087. /** Function used to let the system compiles shaders in background */
  10088. parallelShaderCompile: {
  10089. MAX_SHADER_COMPILER_THREADS_KHR: number;
  10090. maxShaderCompilerThreadsKHR: (thread: number) => void;
  10091. COMPLETION_STATUS_KHR: number;
  10092. };
  10093. }
  10094. /** Interface defining initialization parameters for Engine class */
  10095. interface EngineOptions extends WebGLContextAttributes {
  10096. /**
  10097. * Defines if the engine should no exceed a specified device ratio
  10098. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  10099. */
  10100. limitDeviceRatio?: number;
  10101. /**
  10102. * Defines if webvr should be enabled automatically
  10103. * @see http://doc.babylonjs.com/how_to/webvr_camera
  10104. */
  10105. autoEnableWebVR?: boolean;
  10106. /**
  10107. * Defines if webgl2 should be turned off even if supported
  10108. * @see http://doc.babylonjs.com/features/webgl2
  10109. */
  10110. disableWebGL2Support?: boolean;
  10111. /**
  10112. * Defines if webaudio should be initialized as well
  10113. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  10114. */
  10115. audioEngine?: boolean;
  10116. /**
  10117. * Defines if animations should run using a deterministic lock step
  10118. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  10119. */
  10120. deterministicLockstep?: boolean;
  10121. /** Defines the maximum steps to use with deterministic lock step mode */
  10122. lockstepMaxSteps?: number;
  10123. /**
  10124. * Defines that engine should ignore context lost events
  10125. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  10126. */
  10127. doNotHandleContextLost?: boolean;
  10128. }
  10129. /**
  10130. * Defines the interface used by display changed events
  10131. */
  10132. interface IDisplayChangedEventArgs {
  10133. /** Gets the vrDisplay object (if any) */
  10134. vrDisplay: Nullable<any>;
  10135. /** Gets a boolean indicating if webVR is supported */
  10136. vrSupported: boolean;
  10137. }
  10138. /**
  10139. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  10140. */
  10141. class Engine {
  10142. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  10143. static ExceptionList: ({
  10144. key: string;
  10145. capture: string;
  10146. captureConstraint: number;
  10147. targets: string[];
  10148. } | {
  10149. key: string;
  10150. capture: null;
  10151. captureConstraint: null;
  10152. targets: string[];
  10153. })[];
  10154. /** Gets the list of created engines */
  10155. static Instances: Engine[];
  10156. /**
  10157. * Gets the latest created engine
  10158. */
  10159. static readonly LastCreatedEngine: Nullable<Engine>;
  10160. /**
  10161. * Gets the latest created scene
  10162. */
  10163. static readonly LastCreatedScene: Nullable<Scene>;
  10164. /**
  10165. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  10166. * @param flag defines which part of the materials must be marked as dirty
  10167. * @param predicate defines a predicate used to filter which materials should be affected
  10168. */
  10169. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  10170. /**
  10171. * Hidden
  10172. */
  10173. static _TextureLoaders: IInternalTextureLoader[];
  10174. /** Defines that alpha blending is disabled */
  10175. static readonly ALPHA_DISABLE: number;
  10176. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  10177. static readonly ALPHA_ADD: number;
  10178. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  10179. static readonly ALPHA_COMBINE: number;
  10180. /** Defines that alpha blending to DEST - SRC * DEST */
  10181. static readonly ALPHA_SUBTRACT: number;
  10182. /** Defines that alpha blending to SRC * DEST */
  10183. static readonly ALPHA_MULTIPLY: number;
  10184. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  10185. static readonly ALPHA_MAXIMIZED: number;
  10186. /** Defines that alpha blending to SRC + DEST */
  10187. static readonly ALPHA_ONEONE: number;
  10188. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  10189. static readonly ALPHA_PREMULTIPLIED: number;
  10190. /**
  10191. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  10192. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  10193. */
  10194. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  10195. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  10196. static readonly ALPHA_INTERPOLATE: number;
  10197. /**
  10198. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  10199. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  10200. */
  10201. static readonly ALPHA_SCREENMODE: number;
  10202. /** Defines that the ressource is not delayed*/
  10203. static readonly DELAYLOADSTATE_NONE: number;
  10204. /** Defines that the ressource was successfully delay loaded */
  10205. static readonly DELAYLOADSTATE_LOADED: number;
  10206. /** Defines that the ressource is currently delay loading */
  10207. static readonly DELAYLOADSTATE_LOADING: number;
  10208. /** Defines that the ressource is delayed and has not started loading */
  10209. static readonly DELAYLOADSTATE_NOTLOADED: number;
  10210. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  10211. static readonly NEVER: number;
  10212. /** 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 */
  10213. static readonly ALWAYS: number;
  10214. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  10215. static readonly LESS: number;
  10216. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  10217. static readonly EQUAL: number;
  10218. /** 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 */
  10219. static readonly LEQUAL: number;
  10220. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  10221. static readonly GREATER: number;
  10222. /** 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 */
  10223. static readonly GEQUAL: number;
  10224. /** 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 */
  10225. static readonly NOTEQUAL: number;
  10226. /** Passed to stencilOperation to specify that stencil value must be kept */
  10227. static readonly KEEP: number;
  10228. /** Passed to stencilOperation to specify that stencil value must be replaced */
  10229. static readonly REPLACE: number;
  10230. /** Passed to stencilOperation to specify that stencil value must be incremented */
  10231. static readonly INCR: number;
  10232. /** Passed to stencilOperation to specify that stencil value must be decremented */
  10233. static readonly DECR: number;
  10234. /** Passed to stencilOperation to specify that stencil value must be inverted */
  10235. static readonly INVERT: number;
  10236. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  10237. static readonly INCR_WRAP: number;
  10238. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  10239. static readonly DECR_WRAP: number;
  10240. /** Texture is not repeating outside of 0..1 UVs */
  10241. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  10242. /** Texture is repeating outside of 0..1 UVs */
  10243. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  10244. /** Texture is repeating and mirrored */
  10245. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  10246. /** ALPHA */
  10247. static readonly TEXTUREFORMAT_ALPHA: number;
  10248. /** LUMINANCE */
  10249. static readonly TEXTUREFORMAT_LUMINANCE: number;
  10250. /** LUMINANCE_ALPHA */
  10251. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  10252. /** RGB */
  10253. static readonly TEXTUREFORMAT_RGB: number;
  10254. /** RGBA */
  10255. static readonly TEXTUREFORMAT_RGBA: number;
  10256. /** RED */
  10257. static readonly TEXTUREFORMAT_RED: number;
  10258. /** RED (2nd reference) */
  10259. static readonly TEXTUREFORMAT_R: number;
  10260. /** RG */
  10261. static readonly TEXTUREFORMAT_RG: number;
  10262. /** RED_INTEGER */
  10263. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  10264. /** RED_INTEGER (2nd reference) */
  10265. static readonly TEXTUREFORMAT_R_INTEGER: number;
  10266. /** RG_INTEGER */
  10267. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  10268. /** RGB_INTEGER */
  10269. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  10270. /** RGBA_INTEGER */
  10271. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  10272. /** UNSIGNED_BYTE */
  10273. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  10274. /** UNSIGNED_BYTE (2nd reference) */
  10275. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  10276. /** FLOAT */
  10277. static readonly TEXTURETYPE_FLOAT: number;
  10278. /** HALF_FLOAT */
  10279. static readonly TEXTURETYPE_HALF_FLOAT: number;
  10280. /** BYTE */
  10281. static readonly TEXTURETYPE_BYTE: number;
  10282. /** SHORT */
  10283. static readonly TEXTURETYPE_SHORT: number;
  10284. /** UNSIGNED_SHORT */
  10285. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  10286. /** INT */
  10287. static readonly TEXTURETYPE_INT: number;
  10288. /** UNSIGNED_INT */
  10289. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  10290. /** UNSIGNED_SHORT_4_4_4_4 */
  10291. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  10292. /** UNSIGNED_SHORT_5_5_5_1 */
  10293. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  10294. /** UNSIGNED_SHORT_5_6_5 */
  10295. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  10296. /** UNSIGNED_INT_2_10_10_10_REV */
  10297. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  10298. /** UNSIGNED_INT_24_8 */
  10299. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  10300. /** UNSIGNED_INT_10F_11F_11F_REV */
  10301. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  10302. /** UNSIGNED_INT_5_9_9_9_REV */
  10303. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  10304. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  10305. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  10306. /** nearest is mag = nearest and min = nearest and mip = linear */
  10307. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  10308. /** Bilinear is mag = linear and min = linear and mip = nearest */
  10309. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  10310. /** Trilinear is mag = linear and min = linear and mip = linear */
  10311. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  10312. /** nearest is mag = nearest and min = nearest and mip = linear */
  10313. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  10314. /** Bilinear is mag = linear and min = linear and mip = nearest */
  10315. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  10316. /** Trilinear is mag = linear and min = linear and mip = linear */
  10317. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  10318. /** mag = nearest and min = nearest and mip = nearest */
  10319. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  10320. /** mag = nearest and min = linear and mip = nearest */
  10321. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  10322. /** mag = nearest and min = linear and mip = linear */
  10323. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  10324. /** mag = nearest and min = linear and mip = none */
  10325. static readonly TEXTURE_NEAREST_LINEAR: number;
  10326. /** mag = nearest and min = nearest and mip = none */
  10327. static readonly TEXTURE_NEAREST_NEAREST: number;
  10328. /** mag = linear and min = nearest and mip = nearest */
  10329. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  10330. /** mag = linear and min = nearest and mip = linear */
  10331. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  10332. /** mag = linear and min = linear and mip = none */
  10333. static readonly TEXTURE_LINEAR_LINEAR: number;
  10334. /** mag = linear and min = nearest and mip = none */
  10335. static readonly TEXTURE_LINEAR_NEAREST: number;
  10336. /** Explicit coordinates mode */
  10337. static readonly TEXTURE_EXPLICIT_MODE: number;
  10338. /** Spherical coordinates mode */
  10339. static readonly TEXTURE_SPHERICAL_MODE: number;
  10340. /** Planar coordinates mode */
  10341. static readonly TEXTURE_PLANAR_MODE: number;
  10342. /** Cubic coordinates mode */
  10343. static readonly TEXTURE_CUBIC_MODE: number;
  10344. /** Projection coordinates mode */
  10345. static readonly TEXTURE_PROJECTION_MODE: number;
  10346. /** Skybox coordinates mode */
  10347. static readonly TEXTURE_SKYBOX_MODE: number;
  10348. /** Inverse Cubic coordinates mode */
  10349. static readonly TEXTURE_INVCUBIC_MODE: number;
  10350. /** Equirectangular coordinates mode */
  10351. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  10352. /** Equirectangular Fixed coordinates mode */
  10353. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  10354. /** Equirectangular Fixed Mirrored coordinates mode */
  10355. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  10356. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  10357. static readonly SCALEMODE_FLOOR: number;
  10358. /** Defines that texture rescaling will look for the nearest power of 2 size */
  10359. static readonly SCALEMODE_NEAREST: number;
  10360. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  10361. static readonly SCALEMODE_CEILING: number;
  10362. /**
  10363. * Returns the current version of the framework
  10364. */
  10365. static readonly Version: string;
  10366. /**
  10367. * Returns a string describing the current engine
  10368. */
  10369. readonly description: string;
  10370. /**
  10371. * Gets or sets the epsilon value used by collision engine
  10372. */
  10373. static CollisionsEpsilon: number;
  10374. /**
  10375. * Gets or sets the relative url used to load code if using the engine in non-minified mode
  10376. */
  10377. static CodeRepository: string;
  10378. /**
  10379. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  10380. */
  10381. static ShadersRepository: string;
  10382. /**
  10383. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  10384. */
  10385. forcePOTTextures: boolean;
  10386. /**
  10387. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  10388. */
  10389. isFullscreen: boolean;
  10390. /**
  10391. * Gets a boolean indicating if the pointer is currently locked
  10392. */
  10393. isPointerLock: boolean;
  10394. /**
  10395. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  10396. */
  10397. cullBackFaces: boolean;
  10398. /**
  10399. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  10400. */
  10401. renderEvenInBackground: boolean;
  10402. /**
  10403. * Gets or sets a boolean indicating that cache can be kept between frames
  10404. */
  10405. preventCacheWipeBetweenFrames: boolean;
  10406. /**
  10407. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  10408. **/
  10409. enableOfflineSupport: boolean;
  10410. /**
  10411. * 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)
  10412. **/
  10413. disableManifestCheck: boolean;
  10414. /**
  10415. * Gets the list of created scenes
  10416. */
  10417. scenes: Scene[];
  10418. /**
  10419. * Event raised when a new scene is created
  10420. */
  10421. onNewSceneAddedObservable: Observable<Scene>;
  10422. /**
  10423. * Gets the list of created postprocesses
  10424. */
  10425. postProcesses: PostProcess[];
  10426. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  10427. validateShaderPrograms: boolean;
  10428. /**
  10429. * Observable event triggered each time the rendering canvas is resized
  10430. */
  10431. onResizeObservable: Observable<Engine>;
  10432. /**
  10433. * Observable event triggered each time the canvas loses focus
  10434. */
  10435. onCanvasBlurObservable: Observable<Engine>;
  10436. /**
  10437. * Observable event triggered each time the canvas gains focus
  10438. */
  10439. onCanvasFocusObservable: Observable<Engine>;
  10440. /**
  10441. * Observable event triggered each time the canvas receives pointerout event
  10442. */
  10443. onCanvasPointerOutObservable: Observable<PointerEvent>;
  10444. /**
  10445. * Observable event triggered before each texture is initialized
  10446. */
  10447. onBeforeTextureInitObservable: Observable<Texture>;
  10448. private _vrDisplay;
  10449. private _vrSupported;
  10450. private _oldSize;
  10451. private _oldHardwareScaleFactor;
  10452. private _vrExclusivePointerMode;
  10453. private _webVRInitPromise;
  10454. /**
  10455. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  10456. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  10457. */
  10458. readonly isInVRExclusivePointerMode: boolean;
  10459. /**
  10460. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  10461. */
  10462. disableUniformBuffers: boolean;
  10463. /** @hidden */
  10464. _uniformBuffers: UniformBuffer[];
  10465. /**
  10466. * Gets a boolean indicating that the engine supports uniform buffers
  10467. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  10468. */
  10469. readonly supportsUniformBuffers: boolean;
  10470. /**
  10471. * Observable raised when the engine begins a new frame
  10472. */
  10473. onBeginFrameObservable: Observable<Engine>;
  10474. /**
  10475. * If set, will be used to request the next animation frame for the render loop
  10476. */
  10477. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  10478. /**
  10479. * Observable raised when the engine ends the current frame
  10480. */
  10481. onEndFrameObservable: Observable<Engine>;
  10482. /**
  10483. * Observable raised when the engine is about to compile a shader
  10484. */
  10485. onBeforeShaderCompilationObservable: Observable<Engine>;
  10486. /**
  10487. * Observable raised when the engine has jsut compiled a shader
  10488. */
  10489. onAfterShaderCompilationObservable: Observable<Engine>;
  10490. /** @hidden */
  10491. _gl: WebGLRenderingContext;
  10492. private _renderingCanvas;
  10493. private _windowIsBackground;
  10494. private _webGLVersion;
  10495. /**
  10496. * Gets a boolean indicating that only power of 2 textures are supported
  10497. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  10498. */
  10499. readonly needPOTTextures: boolean;
  10500. /** @hidden */
  10501. _badOS: boolean;
  10502. /** @hidden */
  10503. _badDesktopOS: boolean;
  10504. /**
  10505. * Gets or sets a value indicating if we want to disable texture binding optimization.
  10506. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  10507. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  10508. */
  10509. disableTextureBindingOptimization: boolean;
  10510. /**
  10511. * Gets the audio engine
  10512. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  10513. * @ignorenaming
  10514. */
  10515. static audioEngine: IAudioEngine;
  10516. /**
  10517. * Default AudioEngine factory responsible of creating the Audio Engine.
  10518. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  10519. */
  10520. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  10521. /**
  10522. * Default offline support factory responsible of creating a tool used to store data locally.
  10523. * By default, this will create a Database object if the workload has been embedded.
  10524. */
  10525. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  10526. private _onFocus;
  10527. private _onBlur;
  10528. private _onCanvasPointerOut;
  10529. private _onCanvasBlur;
  10530. private _onCanvasFocus;
  10531. private _onFullscreenChange;
  10532. private _onPointerLockChange;
  10533. private _onVRDisplayPointerRestricted;
  10534. private _onVRDisplayPointerUnrestricted;
  10535. private _onVrDisplayConnect;
  10536. private _onVrDisplayDisconnect;
  10537. private _onVrDisplayPresentChange;
  10538. /**
  10539. * Observable signaled when VR display mode changes
  10540. */
  10541. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  10542. /**
  10543. * Observable signaled when VR request present is complete
  10544. */
  10545. onVRRequestPresentComplete: Observable<boolean>;
  10546. /**
  10547. * Observable signaled when VR request present starts
  10548. */
  10549. onVRRequestPresentStart: Observable<Engine>;
  10550. private _hardwareScalingLevel;
  10551. /** @hidden */
  10552. protected _caps: EngineCapabilities;
  10553. private _pointerLockRequested;
  10554. private _isStencilEnable;
  10555. private _colorWrite;
  10556. private _loadingScreen;
  10557. /** @hidden */
  10558. _drawCalls: PerfCounter;
  10559. /** @hidden */
  10560. _textureCollisions: PerfCounter;
  10561. private _glVersion;
  10562. private _glRenderer;
  10563. private _glVendor;
  10564. private _videoTextureSupported;
  10565. private _renderingQueueLaunched;
  10566. private _activeRenderLoops;
  10567. private _deterministicLockstep;
  10568. private _lockstepMaxSteps;
  10569. /**
  10570. * Observable signaled when a context lost event is raised
  10571. */
  10572. onContextLostObservable: Observable<Engine>;
  10573. /**
  10574. * Observable signaled when a context restored event is raised
  10575. */
  10576. onContextRestoredObservable: Observable<Engine>;
  10577. private _onContextLost;
  10578. private _onContextRestored;
  10579. private _contextWasLost;
  10580. private _doNotHandleContextLost;
  10581. /**
  10582. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  10583. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  10584. */
  10585. doNotHandleContextLost: boolean;
  10586. private _performanceMonitor;
  10587. private _fps;
  10588. private _deltaTime;
  10589. /**
  10590. * Turn this value on if you want to pause FPS computation when in background
  10591. */
  10592. disablePerformanceMonitorInBackground: boolean;
  10593. /**
  10594. * Gets the performance monitor attached to this engine
  10595. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  10596. */
  10597. readonly performanceMonitor: PerformanceMonitor;
  10598. /** @hidden */
  10599. protected _depthCullingState: _DepthCullingState;
  10600. /** @hidden */
  10601. protected _stencilState: _StencilState;
  10602. /** @hidden */
  10603. protected _alphaState: _AlphaState;
  10604. /** @hidden */
  10605. protected _alphaMode: number;
  10606. protected _internalTexturesCache: InternalTexture[];
  10607. /** @hidden */
  10608. protected _activeChannel: number;
  10609. private _currentTextureChannel;
  10610. /** @hidden */
  10611. protected _boundTexturesCache: {
  10612. [key: string]: Nullable<InternalTexture>;
  10613. };
  10614. /** @hidden */
  10615. protected _currentEffect: Nullable<Effect>;
  10616. /** @hidden */
  10617. protected _currentProgram: Nullable<WebGLProgram>;
  10618. private _compiledEffects;
  10619. private _vertexAttribArraysEnabled;
  10620. /** @hidden */
  10621. protected _cachedViewport: Nullable<Viewport>;
  10622. private _cachedVertexArrayObject;
  10623. /** @hidden */
  10624. protected _cachedVertexBuffers: any;
  10625. /** @hidden */
  10626. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  10627. /** @hidden */
  10628. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  10629. /** @hidden */
  10630. protected _currentRenderTarget: Nullable<InternalTexture>;
  10631. private _uintIndicesCurrentlySet;
  10632. private _currentBoundBuffer;
  10633. /** @hidden */
  10634. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  10635. private _currentBufferPointers;
  10636. private _currentInstanceLocations;
  10637. private _currentInstanceBuffers;
  10638. private _textureUnits;
  10639. private _firstBoundInternalTextureTracker;
  10640. private _lastBoundInternalTextureTracker;
  10641. private _workingCanvas;
  10642. private _workingContext;
  10643. private _rescalePostProcess;
  10644. private _dummyFramebuffer;
  10645. private _externalData;
  10646. private _bindedRenderFunction;
  10647. private _vaoRecordInProgress;
  10648. private _mustWipeVertexAttributes;
  10649. private _emptyTexture;
  10650. private _emptyCubeTexture;
  10651. private _emptyTexture3D;
  10652. /** @hidden */
  10653. _frameHandler: number;
  10654. private _nextFreeTextureSlots;
  10655. private _maxSimultaneousTextures;
  10656. private _activeRequests;
  10657. private _texturesSupported;
  10658. private _textureFormatInUse;
  10659. /**
  10660. * Gets the list of texture formats supported
  10661. */
  10662. readonly texturesSupported: Array<string>;
  10663. /**
  10664. * Gets the list of texture formats in use
  10665. */
  10666. readonly textureFormatInUse: Nullable<string>;
  10667. /**
  10668. * Gets the current viewport
  10669. */
  10670. readonly currentViewport: Nullable<Viewport>;
  10671. /**
  10672. * Gets the default empty texture
  10673. */
  10674. readonly emptyTexture: InternalTexture;
  10675. /**
  10676. * Gets the default empty 3D texture
  10677. */
  10678. readonly emptyTexture3D: InternalTexture;
  10679. /**
  10680. * Gets the default empty cube texture
  10681. */
  10682. readonly emptyCubeTexture: InternalTexture;
  10683. /**
  10684. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  10685. */
  10686. readonly premultipliedAlpha: boolean;
  10687. /**
  10688. * Creates a new engine
  10689. * @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
  10690. * @param antialias defines enable antialiasing (default: false)
  10691. * @param options defines further options to be sent to the getContext() function
  10692. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  10693. */
  10694. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  10695. private _rebuildInternalTextures;
  10696. private _rebuildEffects;
  10697. /**
  10698. * Gets a boolean indicating if all created effects are ready
  10699. * @returns true if all effects are ready
  10700. */
  10701. areAllEffectsReady(): boolean;
  10702. private _rebuildBuffers;
  10703. private _initGLContext;
  10704. /**
  10705. * Gets version of the current webGL context
  10706. */
  10707. readonly webGLVersion: number;
  10708. /**
  10709. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  10710. */
  10711. readonly isStencilEnable: boolean;
  10712. private _prepareWorkingCanvas;
  10713. /**
  10714. * Reset the texture cache to empty state
  10715. */
  10716. resetTextureCache(): void;
  10717. /**
  10718. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  10719. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  10720. * @returns true if engine is in deterministic lock step mode
  10721. */
  10722. isDeterministicLockStep(): boolean;
  10723. /**
  10724. * Gets the max steps when engine is running in deterministic lock step
  10725. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  10726. * @returns the max steps
  10727. */
  10728. getLockstepMaxSteps(): number;
  10729. /**
  10730. * Gets an object containing information about the current webGL context
  10731. * @returns an object containing the vender, the renderer and the version of the current webGL context
  10732. */
  10733. getGlInfo(): {
  10734. vendor: string;
  10735. renderer: string;
  10736. version: string;
  10737. };
  10738. /**
  10739. * Gets current aspect ratio
  10740. * @param camera defines the camera to use to get the aspect ratio
  10741. * @param useScreen defines if screen size must be used (or the current render target if any)
  10742. * @returns a number defining the aspect ratio
  10743. */
  10744. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  10745. /**
  10746. * Gets current screen aspect ratio
  10747. * @returns a number defining the aspect ratio
  10748. */
  10749. getScreenAspectRatio(): number;
  10750. /**
  10751. * Gets the current render width
  10752. * @param useScreen defines if screen size must be used (or the current render target if any)
  10753. * @returns a number defining the current render width
  10754. */
  10755. getRenderWidth(useScreen?: boolean): number;
  10756. /**
  10757. * Gets the current render height
  10758. * @param useScreen defines if screen size must be used (or the current render target if any)
  10759. * @returns a number defining the current render height
  10760. */
  10761. getRenderHeight(useScreen?: boolean): number;
  10762. /**
  10763. * Gets the HTML canvas attached with the current webGL context
  10764. * @returns a HTML canvas
  10765. */
  10766. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  10767. /**
  10768. * Gets the client rect of the HTML canvas attached with the current webGL context
  10769. * @returns a client rectanglee
  10770. */
  10771. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  10772. /**
  10773. * Defines the hardware scaling level.
  10774. * By default the hardware scaling level is computed from the window device ratio.
  10775. * 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.
  10776. * @param level defines the level to use
  10777. */
  10778. setHardwareScalingLevel(level: number): void;
  10779. /**
  10780. * Gets the current hardware scaling level.
  10781. * By default the hardware scaling level is computed from the window device ratio.
  10782. * 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.
  10783. * @returns a number indicating the current hardware scaling level
  10784. */
  10785. getHardwareScalingLevel(): number;
  10786. /**
  10787. * Gets the list of loaded textures
  10788. * @returns an array containing all loaded textures
  10789. */
  10790. getLoadedTexturesCache(): InternalTexture[];
  10791. /**
  10792. * Gets the object containing all engine capabilities
  10793. * @returns the EngineCapabilities object
  10794. */
  10795. getCaps(): EngineCapabilities;
  10796. /**
  10797. * Gets the current depth function
  10798. * @returns a number defining the depth function
  10799. */
  10800. getDepthFunction(): Nullable<number>;
  10801. /**
  10802. * Sets the current depth function
  10803. * @param depthFunc defines the function to use
  10804. */
  10805. setDepthFunction(depthFunc: number): void;
  10806. /**
  10807. * Sets the current depth function to GREATER
  10808. */
  10809. setDepthFunctionToGreater(): void;
  10810. /**
  10811. * Sets the current depth function to GEQUAL
  10812. */
  10813. setDepthFunctionToGreaterOrEqual(): void;
  10814. /**
  10815. * Sets the current depth function to LESS
  10816. */
  10817. setDepthFunctionToLess(): void;
  10818. /**
  10819. * Sets the current depth function to LEQUAL
  10820. */
  10821. setDepthFunctionToLessOrEqual(): void;
  10822. /**
  10823. * Gets a boolean indicating if stencil buffer is enabled
  10824. * @returns the current stencil buffer state
  10825. */
  10826. getStencilBuffer(): boolean;
  10827. /**
  10828. * Enable or disable the stencil buffer
  10829. * @param enable defines if the stencil buffer must be enabled or disabled
  10830. */
  10831. setStencilBuffer(enable: boolean): void;
  10832. /**
  10833. * Gets the current stencil mask
  10834. * @returns a number defining the new stencil mask to use
  10835. */
  10836. getStencilMask(): number;
  10837. /**
  10838. * Sets the current stencil mask
  10839. * @param mask defines the new stencil mask to use
  10840. */
  10841. setStencilMask(mask: number): void;
  10842. /**
  10843. * Gets the current stencil function
  10844. * @returns a number defining the stencil function to use
  10845. */
  10846. getStencilFunction(): number;
  10847. /**
  10848. * Gets the current stencil reference value
  10849. * @returns a number defining the stencil reference value to use
  10850. */
  10851. getStencilFunctionReference(): number;
  10852. /**
  10853. * Gets the current stencil mask
  10854. * @returns a number defining the stencil mask to use
  10855. */
  10856. getStencilFunctionMask(): number;
  10857. /**
  10858. * Sets the current stencil function
  10859. * @param stencilFunc defines the new stencil function to use
  10860. */
  10861. setStencilFunction(stencilFunc: number): void;
  10862. /**
  10863. * Sets the current stencil reference
  10864. * @param reference defines the new stencil reference to use
  10865. */
  10866. setStencilFunctionReference(reference: number): void;
  10867. /**
  10868. * Sets the current stencil mask
  10869. * @param mask defines the new stencil mask to use
  10870. */
  10871. setStencilFunctionMask(mask: number): void;
  10872. /**
  10873. * Gets the current stencil operation when stencil fails
  10874. * @returns a number defining stencil operation to use when stencil fails
  10875. */
  10876. getStencilOperationFail(): number;
  10877. /**
  10878. * Gets the current stencil operation when depth fails
  10879. * @returns a number defining stencil operation to use when depth fails
  10880. */
  10881. getStencilOperationDepthFail(): number;
  10882. /**
  10883. * Gets the current stencil operation when stencil passes
  10884. * @returns a number defining stencil operation to use when stencil passes
  10885. */
  10886. getStencilOperationPass(): number;
  10887. /**
  10888. * Sets the stencil operation to use when stencil fails
  10889. * @param operation defines the stencil operation to use when stencil fails
  10890. */
  10891. setStencilOperationFail(operation: number): void;
  10892. /**
  10893. * Sets the stencil operation to use when depth fails
  10894. * @param operation defines the stencil operation to use when depth fails
  10895. */
  10896. setStencilOperationDepthFail(operation: number): void;
  10897. /**
  10898. * Sets the stencil operation to use when stencil passes
  10899. * @param operation defines the stencil operation to use when stencil passes
  10900. */
  10901. setStencilOperationPass(operation: number): void;
  10902. /**
  10903. * Sets a boolean indicating if the dithering state is enabled or disabled
  10904. * @param value defines the dithering state
  10905. */
  10906. setDitheringState(value: boolean): void;
  10907. /**
  10908. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  10909. * @param value defines the rasterizer state
  10910. */
  10911. setRasterizerState(value: boolean): void;
  10912. /**
  10913. * stop executing a render loop function and remove it from the execution array
  10914. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  10915. */
  10916. stopRenderLoop(renderFunction?: () => void): void;
  10917. /** @hidden */
  10918. _renderLoop(): void;
  10919. /**
  10920. * Register and execute a render loop. The engine can have more than one render function
  10921. * @param renderFunction defines the function to continuously execute
  10922. */
  10923. runRenderLoop(renderFunction: () => void): void;
  10924. /**
  10925. * Toggle full screen mode
  10926. * @param requestPointerLock defines if a pointer lock should be requested from the user
  10927. */
  10928. switchFullscreen(requestPointerLock: boolean): void;
  10929. /**
  10930. * Clear the current render buffer or the current render target (if any is set up)
  10931. * @param color defines the color to use
  10932. * @param backBuffer defines if the back buffer must be cleared
  10933. * @param depth defines if the depth buffer must be cleared
  10934. * @param stencil defines if the stencil buffer must be cleared
  10935. */
  10936. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  10937. /**
  10938. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  10939. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  10940. * @param y defines the y-coordinate of the corner of the clear rectangle
  10941. * @param width defines the width of the clear rectangle
  10942. * @param height defines the height of the clear rectangle
  10943. * @param clearColor defines the clear color
  10944. */
  10945. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  10946. /**
  10947. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  10948. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  10949. * @param y defines the y-coordinate of the corner of the clear rectangle
  10950. * @param width defines the width of the clear rectangle
  10951. * @param height defines the height of the clear rectangle
  10952. */
  10953. enableScissor(x: number, y: number, width: number, height: number): void;
  10954. /**
  10955. * Disable previously set scissor test rectangle
  10956. */
  10957. disableScissor(): void;
  10958. private _viewportCached;
  10959. /** @hidden */
  10960. _viewport(x: number, y: number, width: number, height: number): void;
  10961. /**
  10962. * Set the WebGL's viewport
  10963. * @param viewport defines the viewport element to be used
  10964. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  10965. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  10966. */
  10967. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  10968. /**
  10969. * Directly set the WebGL Viewport
  10970. * @param x defines the x coordinate of the viewport (in screen space)
  10971. * @param y defines the y coordinate of the viewport (in screen space)
  10972. * @param width defines the width of the viewport (in screen space)
  10973. * @param height defines the height of the viewport (in screen space)
  10974. * @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
  10975. */
  10976. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  10977. /**
  10978. * Begin a new frame
  10979. */
  10980. beginFrame(): void;
  10981. /**
  10982. * Enf the current frame
  10983. */
  10984. endFrame(): void;
  10985. /**
  10986. * Resize the view according to the canvas' size
  10987. */
  10988. resize(): void;
  10989. /**
  10990. * Force a specific size of the canvas
  10991. * @param width defines the new canvas' width
  10992. * @param height defines the new canvas' height
  10993. */
  10994. setSize(width: number, height: number): void;
  10995. /**
  10996. * Gets a boolean indicating if a webVR device was detected
  10997. * @returns true if a webVR device was detected
  10998. */
  10999. isVRDevicePresent(): boolean;
  11000. /**
  11001. * Gets the current webVR device
  11002. * @returns the current webVR device (or null)
  11003. */
  11004. getVRDevice(): any;
  11005. /**
  11006. * Initializes a webVR display and starts listening to display change events
  11007. * The onVRDisplayChangedObservable will be notified upon these changes
  11008. * @returns The onVRDisplayChangedObservable
  11009. */
  11010. initWebVR(): Observable<IDisplayChangedEventArgs>;
  11011. /**
  11012. * Initializes a webVR display and starts listening to display change events
  11013. * The onVRDisplayChangedObservable will be notified upon these changes
  11014. * @returns A promise containing a VRDisplay and if vr is supported
  11015. */
  11016. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  11017. /**
  11018. * Call this function to switch to webVR mode
  11019. * Will do nothing if webVR is not supported or if there is no webVR device
  11020. * @see http://doc.babylonjs.com/how_to/webvr_camera
  11021. */
  11022. enableVR(): void;
  11023. /**
  11024. * Call this function to leave webVR mode
  11025. * Will do nothing if webVR is not supported or if there is no webVR device
  11026. * @see http://doc.babylonjs.com/how_to/webvr_camera
  11027. */
  11028. disableVR(): void;
  11029. private _onVRFullScreenTriggered;
  11030. private _getVRDisplaysAsync;
  11031. /**
  11032. * Binds the frame buffer to the specified texture.
  11033. * @param texture The texture to render to or null for the default canvas
  11034. * @param faceIndex The face of the texture to render to in case of cube texture
  11035. * @param requiredWidth The width of the target to render to
  11036. * @param requiredHeight The height of the target to render to
  11037. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  11038. * @param depthStencilTexture The depth stencil texture to use to render
  11039. * @param lodLevel defines le lod level to bind to the frame buffer
  11040. */
  11041. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  11042. private bindUnboundFramebuffer;
  11043. /**
  11044. * Unbind the current render target texture from the webGL context
  11045. * @param texture defines the render target texture to unbind
  11046. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  11047. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  11048. */
  11049. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  11050. /**
  11051. * Unbind a list of render target textures from the webGL context
  11052. * This is used only when drawBuffer extension or webGL2 are active
  11053. * @param textures defines the render target textures to unbind
  11054. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  11055. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  11056. */
  11057. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  11058. /**
  11059. * Force the mipmap generation for the given render target texture
  11060. * @param texture defines the render target texture to use
  11061. */
  11062. generateMipMapsForCubemap(texture: InternalTexture): void;
  11063. /**
  11064. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  11065. */
  11066. flushFramebuffer(): void;
  11067. /**
  11068. * Unbind the current render target and bind the default framebuffer
  11069. */
  11070. restoreDefaultFramebuffer(): void;
  11071. /**
  11072. * Create an uniform buffer
  11073. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  11074. * @param elements defines the content of the uniform buffer
  11075. * @returns the webGL uniform buffer
  11076. */
  11077. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  11078. /**
  11079. * Create a dynamic uniform buffer
  11080. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  11081. * @param elements defines the content of the uniform buffer
  11082. * @returns the webGL uniform buffer
  11083. */
  11084. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  11085. /**
  11086. * Update an existing uniform buffer
  11087. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  11088. * @param uniformBuffer defines the target uniform buffer
  11089. * @param elements defines the content to update
  11090. * @param offset defines the offset in the uniform buffer where update should start
  11091. * @param count defines the size of the data to update
  11092. */
  11093. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  11094. private _resetVertexBufferBinding;
  11095. /**
  11096. * Creates a vertex buffer
  11097. * @param data the data for the vertex buffer
  11098. * @returns the new WebGL static buffer
  11099. */
  11100. createVertexBuffer(data: DataArray): WebGLBuffer;
  11101. /**
  11102. * Creates a dynamic vertex buffer
  11103. * @param data the data for the dynamic vertex buffer
  11104. * @returns the new WebGL dynamic buffer
  11105. */
  11106. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  11107. /**
  11108. * Update a dynamic index buffer
  11109. * @param indexBuffer defines the target index buffer
  11110. * @param indices defines the data to update
  11111. * @param offset defines the offset in the target index buffer where update should start
  11112. */
  11113. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  11114. /**
  11115. * Updates a dynamic vertex buffer.
  11116. * @param vertexBuffer the vertex buffer to update
  11117. * @param data the data used to update the vertex buffer
  11118. * @param byteOffset the byte offset of the data
  11119. * @param byteLength the byte length of the data
  11120. */
  11121. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  11122. private _resetIndexBufferBinding;
  11123. /**
  11124. * Creates a new index buffer
  11125. * @param indices defines the content of the index buffer
  11126. * @param updatable defines if the index buffer must be updatable
  11127. * @returns a new webGL buffer
  11128. */
  11129. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  11130. /**
  11131. * Bind a webGL buffer to the webGL context
  11132. * @param buffer defines the buffer to bind
  11133. */
  11134. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  11135. /**
  11136. * Bind an uniform buffer to the current webGL context
  11137. * @param buffer defines the buffer to bind
  11138. */
  11139. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  11140. /**
  11141. * Bind a buffer to the current webGL context at a given location
  11142. * @param buffer defines the buffer to bind
  11143. * @param location defines the index where to bind the buffer
  11144. */
  11145. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  11146. /**
  11147. * Bind a specific block at a given index in a specific shader program
  11148. * @param shaderProgram defines the shader program
  11149. * @param blockName defines the block name
  11150. * @param index defines the index where to bind the block
  11151. */
  11152. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  11153. private bindIndexBuffer;
  11154. private bindBuffer;
  11155. /**
  11156. * update the bound buffer with the given data
  11157. * @param data defines the data to update
  11158. */
  11159. updateArrayBuffer(data: Float32Array): void;
  11160. private _vertexAttribPointer;
  11161. private _bindIndexBufferWithCache;
  11162. private _bindVertexBuffersAttributes;
  11163. /**
  11164. * Records a vertex array object
  11165. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  11166. * @param vertexBuffers defines the list of vertex buffers to store
  11167. * @param indexBuffer defines the index buffer to store
  11168. * @param effect defines the effect to store
  11169. * @returns the new vertex array object
  11170. */
  11171. recordVertexArrayObject(vertexBuffers: {
  11172. [key: string]: VertexBuffer;
  11173. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  11174. /**
  11175. * Bind a specific vertex array object
  11176. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  11177. * @param vertexArrayObject defines the vertex array object to bind
  11178. * @param indexBuffer defines the index buffer to bind
  11179. */
  11180. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  11181. /**
  11182. * Bind webGl buffers directly to the webGL context
  11183. * @param vertexBuffer defines the vertex buffer to bind
  11184. * @param indexBuffer defines the index buffer to bind
  11185. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  11186. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  11187. * @param effect defines the effect associated with the vertex buffer
  11188. */
  11189. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  11190. private _unbindVertexArrayObject;
  11191. /**
  11192. * Bind a list of vertex buffers to the webGL context
  11193. * @param vertexBuffers defines the list of vertex buffers to bind
  11194. * @param indexBuffer defines the index buffer to bind
  11195. * @param effect defines the effect associated with the vertex buffers
  11196. */
  11197. bindBuffers(vertexBuffers: {
  11198. [key: string]: Nullable<VertexBuffer>;
  11199. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  11200. /**
  11201. * Unbind all instance attributes
  11202. */
  11203. unbindInstanceAttributes(): void;
  11204. /**
  11205. * Release and free the memory of a vertex array object
  11206. * @param vao defines the vertex array object to delete
  11207. */
  11208. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  11209. /** @hidden */
  11210. _releaseBuffer(buffer: WebGLBuffer): boolean;
  11211. /**
  11212. * Creates a webGL buffer to use with instanciation
  11213. * @param capacity defines the size of the buffer
  11214. * @returns the webGL buffer
  11215. */
  11216. createInstancesBuffer(capacity: number): WebGLBuffer;
  11217. /**
  11218. * Delete a webGL buffer used with instanciation
  11219. * @param buffer defines the webGL buffer to delete
  11220. */
  11221. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  11222. /**
  11223. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  11224. * @param instancesBuffer defines the webGL buffer to update and bind
  11225. * @param data defines the data to store in the buffer
  11226. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  11227. */
  11228. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  11229. /**
  11230. * Apply all cached states (depth, culling, stencil and alpha)
  11231. */
  11232. applyStates(): void;
  11233. /**
  11234. * Send a draw order
  11235. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  11236. * @param indexStart defines the starting index
  11237. * @param indexCount defines the number of index to draw
  11238. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11239. */
  11240. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  11241. /**
  11242. * Draw a list of points
  11243. * @param verticesStart defines the index of first vertex to draw
  11244. * @param verticesCount defines the count of vertices to draw
  11245. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11246. */
  11247. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  11248. /**
  11249. * Draw a list of unindexed primitives
  11250. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  11251. * @param verticesStart defines the index of first vertex to draw
  11252. * @param verticesCount defines the count of vertices to draw
  11253. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11254. */
  11255. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  11256. /**
  11257. * Draw a list of indexed primitives
  11258. * @param fillMode defines the primitive to use
  11259. * @param indexStart defines the starting index
  11260. * @param indexCount defines the number of index to draw
  11261. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11262. */
  11263. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  11264. /**
  11265. * Draw a list of unindexed primitives
  11266. * @param fillMode defines the primitive to use
  11267. * @param verticesStart defines the index of first vertex to draw
  11268. * @param verticesCount defines the count of vertices to draw
  11269. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11270. */
  11271. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  11272. private _drawMode;
  11273. /** @hidden */
  11274. _releaseEffect(effect: Effect): void;
  11275. /** @hidden */
  11276. _deleteProgram(program: WebGLProgram): void;
  11277. /**
  11278. * Create a new effect (used to store vertex/fragment shaders)
  11279. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  11280. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  11281. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  11282. * @param samplers defines an array of string used to represent textures
  11283. * @param defines defines the string containing the defines to use to compile the shaders
  11284. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  11285. * @param onCompiled defines a function to call when the effect creation is successful
  11286. * @param onError defines a function to call when the effect creation has failed
  11287. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  11288. * @returns the new Effect
  11289. */
  11290. 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;
  11291. private _compileShader;
  11292. private _compileRawShader;
  11293. /**
  11294. * Directly creates a webGL program
  11295. * @param vertexCode defines the vertex shader code to use
  11296. * @param fragmentCode defines the fragment shader code to use
  11297. * @param context defines the webGL context to use (if not set, the current one will be used)
  11298. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  11299. * @returns the new webGL program
  11300. */
  11301. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  11302. /**
  11303. * Creates a webGL program
  11304. * @param vertexCode defines the vertex shader code to use
  11305. * @param fragmentCode defines the fragment shader code to use
  11306. * @param defines defines the string containing the defines to use to compile the shaders
  11307. * @param context defines the webGL context to use (if not set, the current one will be used)
  11308. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  11309. * @returns the new webGL program
  11310. */
  11311. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  11312. private _createShaderProgram;
  11313. private _finalizeProgram;
  11314. /** @hidden */
  11315. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  11316. /** @hidden */
  11317. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  11318. /**
  11319. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  11320. * @param shaderProgram defines the webGL program to use
  11321. * @param uniformsNames defines the list of uniform names
  11322. * @returns an array of webGL uniform locations
  11323. */
  11324. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  11325. /**
  11326. * Gets the lsit of active attributes for a given webGL program
  11327. * @param shaderProgram defines the webGL program to use
  11328. * @param attributesNames defines the list of attribute names to get
  11329. * @returns an array of indices indicating the offset of each attribute
  11330. */
  11331. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  11332. /**
  11333. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  11334. * @param effect defines the effect to activate
  11335. */
  11336. enableEffect(effect: Nullable<Effect>): void;
  11337. /**
  11338. * Set the value of an uniform to an array of int32
  11339. * @param uniform defines the webGL uniform location where to store the value
  11340. * @param array defines the array of int32 to store
  11341. */
  11342. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  11343. /**
  11344. * Set the value of an uniform to an array of int32 (stored as vec2)
  11345. * @param uniform defines the webGL uniform location where to store the value
  11346. * @param array defines the array of int32 to store
  11347. */
  11348. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  11349. /**
  11350. * Set the value of an uniform to an array of int32 (stored as vec3)
  11351. * @param uniform defines the webGL uniform location where to store the value
  11352. * @param array defines the array of int32 to store
  11353. */
  11354. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  11355. /**
  11356. * Set the value of an uniform to an array of int32 (stored as vec4)
  11357. * @param uniform defines the webGL uniform location where to store the value
  11358. * @param array defines the array of int32 to store
  11359. */
  11360. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  11361. /**
  11362. * Set the value of an uniform to an array of float32
  11363. * @param uniform defines the webGL uniform location where to store the value
  11364. * @param array defines the array of float32 to store
  11365. */
  11366. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  11367. /**
  11368. * Set the value of an uniform to an array of float32 (stored as vec2)
  11369. * @param uniform defines the webGL uniform location where to store the value
  11370. * @param array defines the array of float32 to store
  11371. */
  11372. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  11373. /**
  11374. * Set the value of an uniform to an array of float32 (stored as vec3)
  11375. * @param uniform defines the webGL uniform location where to store the value
  11376. * @param array defines the array of float32 to store
  11377. */
  11378. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  11379. /**
  11380. * Set the value of an uniform to an array of float32 (stored as vec4)
  11381. * @param uniform defines the webGL uniform location where to store the value
  11382. * @param array defines the array of float32 to store
  11383. */
  11384. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  11385. /**
  11386. * Set the value of an uniform to an array of number
  11387. * @param uniform defines the webGL uniform location where to store the value
  11388. * @param array defines the array of number to store
  11389. */
  11390. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  11391. /**
  11392. * Set the value of an uniform to an array of number (stored as vec2)
  11393. * @param uniform defines the webGL uniform location where to store the value
  11394. * @param array defines the array of number to store
  11395. */
  11396. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  11397. /**
  11398. * Set the value of an uniform to an array of number (stored as vec3)
  11399. * @param uniform defines the webGL uniform location where to store the value
  11400. * @param array defines the array of number to store
  11401. */
  11402. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  11403. /**
  11404. * Set the value of an uniform to an array of number (stored as vec4)
  11405. * @param uniform defines the webGL uniform location where to store the value
  11406. * @param array defines the array of number to store
  11407. */
  11408. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  11409. /**
  11410. * Set the value of an uniform to an array of float32 (stored as matrices)
  11411. * @param uniform defines the webGL uniform location where to store the value
  11412. * @param matrices defines the array of float32 to store
  11413. */
  11414. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  11415. /**
  11416. * Set the value of an uniform to a matrix
  11417. * @param uniform defines the webGL uniform location where to store the value
  11418. * @param matrix defines the matrix to store
  11419. */
  11420. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  11421. /**
  11422. * Set the value of an uniform to a matrix (3x3)
  11423. * @param uniform defines the webGL uniform location where to store the value
  11424. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  11425. */
  11426. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  11427. /**
  11428. * Set the value of an uniform to a matrix (2x2)
  11429. * @param uniform defines the webGL uniform location where to store the value
  11430. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  11431. */
  11432. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  11433. /**
  11434. * Set the value of an uniform to a number (int)
  11435. * @param uniform defines the webGL uniform location where to store the value
  11436. * @param value defines the int number to store
  11437. */
  11438. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  11439. /**
  11440. * Set the value of an uniform to a number (float)
  11441. * @param uniform defines the webGL uniform location where to store the value
  11442. * @param value defines the float number to store
  11443. */
  11444. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  11445. /**
  11446. * Set the value of an uniform to a vec2
  11447. * @param uniform defines the webGL uniform location where to store the value
  11448. * @param x defines the 1st component of the value
  11449. * @param y defines the 2nd component of the value
  11450. */
  11451. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  11452. /**
  11453. * Set the value of an uniform to a vec3
  11454. * @param uniform defines the webGL uniform location where to store the value
  11455. * @param x defines the 1st component of the value
  11456. * @param y defines the 2nd component of the value
  11457. * @param z defines the 3rd component of the value
  11458. */
  11459. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  11460. /**
  11461. * Set the value of an uniform to a boolean
  11462. * @param uniform defines the webGL uniform location where to store the value
  11463. * @param bool defines the boolean to store
  11464. */
  11465. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  11466. /**
  11467. * Set the value of an uniform to a vec4
  11468. * @param uniform defines the webGL uniform location where to store the value
  11469. * @param x defines the 1st component of the value
  11470. * @param y defines the 2nd component of the value
  11471. * @param z defines the 3rd component of the value
  11472. * @param w defines the 4th component of the value
  11473. */
  11474. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  11475. /**
  11476. * Set the value of an uniform to a Color3
  11477. * @param uniform defines the webGL uniform location where to store the value
  11478. * @param color3 defines the color to store
  11479. */
  11480. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  11481. /**
  11482. * Set the value of an uniform to a Color3 and an alpha value
  11483. * @param uniform defines the webGL uniform location where to store the value
  11484. * @param color3 defines the color to store
  11485. * @param alpha defines the alpha component to store
  11486. */
  11487. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  11488. /**
  11489. * Sets a Color4 on a uniform variable
  11490. * @param uniform defines the uniform location
  11491. * @param color4 defines the value to be set
  11492. */
  11493. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  11494. /**
  11495. * Set various states to the webGL context
  11496. * @param culling defines backface culling state
  11497. * @param zOffset defines the value to apply to zOffset (0 by default)
  11498. * @param force defines if states must be applied even if cache is up to date
  11499. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  11500. */
  11501. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  11502. /**
  11503. * Set the z offset to apply to current rendering
  11504. * @param value defines the offset to apply
  11505. */
  11506. setZOffset(value: number): void;
  11507. /**
  11508. * Gets the current value of the zOffset
  11509. * @returns the current zOffset state
  11510. */
  11511. getZOffset(): number;
  11512. /**
  11513. * Enable or disable depth buffering
  11514. * @param enable defines the state to set
  11515. */
  11516. setDepthBuffer(enable: boolean): void;
  11517. /**
  11518. * Gets a boolean indicating if depth writing is enabled
  11519. * @returns the current depth writing state
  11520. */
  11521. getDepthWrite(): boolean;
  11522. /**
  11523. * Enable or disable depth writing
  11524. * @param enable defines the state to set
  11525. */
  11526. setDepthWrite(enable: boolean): void;
  11527. /**
  11528. * Enable or disable color writing
  11529. * @param enable defines the state to set
  11530. */
  11531. setColorWrite(enable: boolean): void;
  11532. /**
  11533. * Gets a boolean indicating if color writing is enabled
  11534. * @returns the current color writing state
  11535. */
  11536. getColorWrite(): boolean;
  11537. /**
  11538. * Sets alpha constants used by some alpha blending modes
  11539. * @param r defines the red component
  11540. * @param g defines the green component
  11541. * @param b defines the blue component
  11542. * @param a defines the alpha component
  11543. */
  11544. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  11545. /**
  11546. * Sets the current alpha mode
  11547. * @param mode defines the mode to use (one of the BABYLON.Engine.ALPHA_XXX)
  11548. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  11549. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  11550. */
  11551. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  11552. /**
  11553. * Gets the current alpha mode
  11554. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  11555. * @returns the current alpha mode
  11556. */
  11557. getAlphaMode(): number;
  11558. /**
  11559. * Clears the list of texture accessible through engine.
  11560. * This can help preventing texture load conflict due to name collision.
  11561. */
  11562. clearInternalTexturesCache(): void;
  11563. /**
  11564. * Force the entire cache to be cleared
  11565. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  11566. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  11567. */
  11568. wipeCaches(bruteForce?: boolean): void;
  11569. /**
  11570. * Set the compressed texture format to use, based on the formats you have, and the formats
  11571. * supported by the hardware / browser.
  11572. *
  11573. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  11574. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  11575. * to API arguments needed to compressed textures. This puts the burden on the container
  11576. * generator to house the arcane code for determining these for current & future formats.
  11577. *
  11578. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  11579. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  11580. *
  11581. * Note: The result of this call is not taken into account when a texture is base64.
  11582. *
  11583. * @param formatsAvailable defines the list of those format families you have created
  11584. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  11585. *
  11586. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  11587. * @returns The extension selected.
  11588. */
  11589. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  11590. private _getSamplingParameters;
  11591. private _partialLoadImg;
  11592. private _cascadeLoadImgs;
  11593. /** @hidden */
  11594. _createTexture(): WebGLTexture;
  11595. /**
  11596. * Usually called from BABYLON.Texture.ts.
  11597. * Passed information to create a WebGLTexture
  11598. * @param urlArg defines a value which contains one of the following:
  11599. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  11600. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  11601. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  11602. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  11603. * @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)
  11604. * @param scene needed for loading to the correct scene
  11605. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  11606. * @param onLoad optional callback to be called upon successful completion
  11607. * @param onError optional callback to be called upon failure
  11608. * @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
  11609. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  11610. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  11611. * @param forcedExtension defines the extension to use to pick the right loader
  11612. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  11613. * @returns a InternalTexture for assignment back into BABYLON.Texture
  11614. */
  11615. 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;
  11616. private _rescaleTexture;
  11617. /**
  11618. * Update a raw texture
  11619. * @param texture defines the texture to update
  11620. * @param data defines the data to store in the texture
  11621. * @param format defines the format of the data
  11622. * @param invertY defines if data must be stored with Y axis inverted
  11623. * @param compression defines the compression used (null by default)
  11624. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11625. */
  11626. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  11627. /**
  11628. * Creates a raw texture
  11629. * @param data defines the data to store in the texture
  11630. * @param width defines the width of the texture
  11631. * @param height defines the height of the texture
  11632. * @param format defines the format of the data
  11633. * @param generateMipMaps defines if the engine should generate the mip levels
  11634. * @param invertY defines if data must be stored with Y axis inverted
  11635. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  11636. * @param compression defines the compression used (null by default)
  11637. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11638. * @returns the raw texture inside an InternalTexture
  11639. */
  11640. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  11641. private _unpackFlipYCached;
  11642. /**
  11643. * In case you are sharing the context with other applications, it might
  11644. * be interested to not cache the unpack flip y state to ensure a consistent
  11645. * value would be set.
  11646. */
  11647. enableUnpackFlipYCached: boolean;
  11648. /** @hidden */
  11649. _unpackFlipY(value: boolean): void;
  11650. /** @hidden */
  11651. _getUnpackAlignement(): number;
  11652. /**
  11653. * Creates a dynamic texture
  11654. * @param width defines the width of the texture
  11655. * @param height defines the height of the texture
  11656. * @param generateMipMaps defines if the engine should generate the mip levels
  11657. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  11658. * @returns the dynamic texture inside an InternalTexture
  11659. */
  11660. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  11661. /**
  11662. * Update the sampling mode of a given texture
  11663. * @param samplingMode defines the required sampling mode
  11664. * @param texture defines the texture to update
  11665. */
  11666. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  11667. /**
  11668. * Update the content of a dynamic texture
  11669. * @param texture defines the texture to update
  11670. * @param canvas defines the canvas containing the source
  11671. * @param invertY defines if data must be stored with Y axis inverted
  11672. * @param premulAlpha defines if alpha is stored as premultiplied
  11673. * @param format defines the format of the data
  11674. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  11675. */
  11676. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  11677. /**
  11678. * Update a video texture
  11679. * @param texture defines the texture to update
  11680. * @param video defines the video element to use
  11681. * @param invertY defines if data must be stored with Y axis inverted
  11682. */
  11683. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  11684. /**
  11685. * Updates a depth texture Comparison Mode and Function.
  11686. * If the comparison Function is equal to 0, the mode will be set to none.
  11687. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  11688. * @param texture The texture to set the comparison function for
  11689. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  11690. */
  11691. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  11692. private _setupDepthStencilTexture;
  11693. /**
  11694. * Creates a depth stencil texture.
  11695. * This is only available in WebGL 2 or with the depth texture extension available.
  11696. * @param size The size of face edge in the texture.
  11697. * @param options The options defining the texture.
  11698. * @returns The texture
  11699. */
  11700. createDepthStencilTexture(size: number | {
  11701. width: number;
  11702. height: number;
  11703. }, options: DepthTextureCreationOptions): InternalTexture;
  11704. /**
  11705. * Creates a depth stencil texture.
  11706. * This is only available in WebGL 2 or with the depth texture extension available.
  11707. * @param size The size of face edge in the texture.
  11708. * @param options The options defining the texture.
  11709. * @returns The texture
  11710. */
  11711. private _createDepthStencilTexture;
  11712. /**
  11713. * Creates a depth stencil cube texture.
  11714. * This is only available in WebGL 2.
  11715. * @param size The size of face edge in the cube texture.
  11716. * @param options The options defining the cube texture.
  11717. * @returns The cube texture
  11718. */
  11719. private _createDepthStencilCubeTexture;
  11720. /**
  11721. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  11722. * @param renderTarget The render target to set the frame buffer for
  11723. */
  11724. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  11725. /**
  11726. * Creates a new render target texture
  11727. * @param size defines the size of the texture
  11728. * @param options defines the options used to create the texture
  11729. * @returns a new render target texture stored in an InternalTexture
  11730. */
  11731. createRenderTargetTexture(size: number | {
  11732. width: number;
  11733. height: number;
  11734. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  11735. /**
  11736. * Create a multi render target texture
  11737. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  11738. * @param size defines the size of the texture
  11739. * @param options defines the creation options
  11740. * @returns the cube texture as an InternalTexture
  11741. */
  11742. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  11743. private _setupFramebufferDepthAttachments;
  11744. /**
  11745. * Updates the sample count of a render target texture
  11746. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  11747. * @param texture defines the texture to update
  11748. * @param samples defines the sample count to set
  11749. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  11750. */
  11751. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  11752. /**
  11753. * Update the sample count for a given multiple render target texture
  11754. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  11755. * @param textures defines the textures to update
  11756. * @param samples defines the sample count to set
  11757. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  11758. */
  11759. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  11760. /** @hidden */
  11761. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  11762. /** @hidden */
  11763. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  11764. /** @hidden */
  11765. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  11766. /** @hidden */
  11767. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  11768. /**
  11769. * Creates a new render target cube texture
  11770. * @param size defines the size of the texture
  11771. * @param options defines the options used to create the texture
  11772. * @returns a new render target cube texture stored in an InternalTexture
  11773. */
  11774. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11775. /**
  11776. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  11777. * @param rootUrl defines the url where the file to load is located
  11778. * @param scene defines the current scene
  11779. * @param lodScale defines scale to apply to the mip map selection
  11780. * @param lodOffset defines offset to apply to the mip map selection
  11781. * @param onLoad defines an optional callback raised when the texture is loaded
  11782. * @param onError defines an optional callback raised if there is an issue to load the texture
  11783. * @param format defines the format of the data
  11784. * @param forcedExtension defines the extension to use to pick the right loader
  11785. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  11786. * @returns the cube texture as an InternalTexture
  11787. */
  11788. 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;
  11789. /**
  11790. * Creates a cube texture
  11791. * @param rootUrl defines the url where the files to load is located
  11792. * @param scene defines the current scene
  11793. * @param files defines the list of files to load (1 per face)
  11794. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  11795. * @param onLoad defines an optional callback raised when the texture is loaded
  11796. * @param onError defines an optional callback raised if there is an issue to load the texture
  11797. * @param format defines the format of the data
  11798. * @param forcedExtension defines the extension to use to pick the right loader
  11799. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  11800. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  11801. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  11802. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  11803. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  11804. * @returns the cube texture as an InternalTexture
  11805. */
  11806. 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;
  11807. /**
  11808. * @hidden
  11809. */
  11810. _setCubeMapTextureParams(loadMipmap: boolean): void;
  11811. /**
  11812. * Update a raw cube texture
  11813. * @param texture defines the texture to udpdate
  11814. * @param data defines the data to store
  11815. * @param format defines the data format
  11816. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11817. * @param invertY defines if data must be stored with Y axis inverted
  11818. * @param compression defines the compression used (null by default)
  11819. * @param level defines which level of the texture to update
  11820. */
  11821. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  11822. /**
  11823. * Creates a new raw cube texture
  11824. * @param data defines the array of data to use to create each face
  11825. * @param size defines the size of the textures
  11826. * @param format defines the format of the data
  11827. * @param type defines the type of the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  11828. * @param generateMipMaps defines if the engine should generate the mip levels
  11829. * @param invertY defines if data must be stored with Y axis inverted
  11830. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  11831. * @param compression defines the compression used (null by default)
  11832. * @returns the cube texture as an InternalTexture
  11833. */
  11834. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  11835. /**
  11836. * Creates a new raw cube texture from a specified url
  11837. * @param url defines the url where the data is located
  11838. * @param scene defines the current scene
  11839. * @param size defines the size of the textures
  11840. * @param format defines the format of the data
  11841. * @param type defines the type fo the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  11842. * @param noMipmap defines if the engine should avoid generating the mip levels
  11843. * @param callback defines a callback used to extract texture data from loaded data
  11844. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11845. * @param onLoad defines a callback called when texture is loaded
  11846. * @param onError defines a callback called if there is an error
  11847. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  11848. * @param invertY defines if data must be stored with Y axis inverted
  11849. * @returns the cube texture as an InternalTexture
  11850. */
  11851. 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;
  11852. /**
  11853. * Update a raw 3D texture
  11854. * @param texture defines the texture to update
  11855. * @param data defines the data to store
  11856. * @param format defines the data format
  11857. * @param invertY defines if data must be stored with Y axis inverted
  11858. * @param compression defines the used compression (can be null)
  11859. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11860. */
  11861. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  11862. /**
  11863. * Creates a new raw 3D texture
  11864. * @param data defines the data used to create the texture
  11865. * @param width defines the width of the texture
  11866. * @param height defines the height of the texture
  11867. * @param depth defines the depth of the texture
  11868. * @param format defines the format of the texture
  11869. * @param generateMipMaps defines if the engine must generate mip levels
  11870. * @param invertY defines if data must be stored with Y axis inverted
  11871. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  11872. * @param compression defines the compressed used (can be null)
  11873. * @param textureType defines the compressed used (can be null)
  11874. * @returns a new raw 3D texture (stored in an InternalTexture)
  11875. */
  11876. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  11877. private _prepareWebGLTextureContinuation;
  11878. private _prepareWebGLTexture;
  11879. private _convertRGBtoRGBATextureData;
  11880. /** @hidden */
  11881. _releaseFramebufferObjects(texture: InternalTexture): void;
  11882. /** @hidden */
  11883. _releaseTexture(texture: InternalTexture): void;
  11884. private setProgram;
  11885. private _boundUniforms;
  11886. /**
  11887. * Binds an effect to the webGL context
  11888. * @param effect defines the effect to bind
  11889. */
  11890. bindSamplers(effect: Effect): void;
  11891. private _moveBoundTextureOnTop;
  11892. private _getCorrectTextureChannel;
  11893. private _linkTrackers;
  11894. private _removeDesignatedSlot;
  11895. private _activateCurrentTexture;
  11896. /** @hidden */
  11897. protected _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  11898. /** @hidden */
  11899. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  11900. /**
  11901. * Sets a texture to the webGL context from a postprocess
  11902. * @param channel defines the channel to use
  11903. * @param postProcess defines the source postprocess
  11904. */
  11905. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  11906. /**
  11907. * Binds the output of the passed in post process to the texture channel specified
  11908. * @param channel The channel the texture should be bound to
  11909. * @param postProcess The post process which's output should be bound
  11910. */
  11911. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  11912. /**
  11913. * Unbind all textures from the webGL context
  11914. */
  11915. unbindAllTextures(): void;
  11916. /**
  11917. * Sets a texture to the according uniform.
  11918. * @param channel The texture channel
  11919. * @param uniform The uniform to set
  11920. * @param texture The texture to apply
  11921. */
  11922. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  11923. /**
  11924. * Sets a depth stencil texture from a render target to the according uniform.
  11925. * @param channel The texture channel
  11926. * @param uniform The uniform to set
  11927. * @param texture The render target texture containing the depth stencil texture to apply
  11928. */
  11929. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  11930. private _bindSamplerUniformToChannel;
  11931. private _getTextureWrapMode;
  11932. private _setTexture;
  11933. /**
  11934. * Sets an array of texture to the webGL context
  11935. * @param channel defines the channel where the texture array must be set
  11936. * @param uniform defines the associated uniform location
  11937. * @param textures defines the array of textures to bind
  11938. */
  11939. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  11940. /** @hidden */
  11941. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  11942. private _setTextureParameterFloat;
  11943. private _setTextureParameterInteger;
  11944. /**
  11945. * Reads pixels from the current frame buffer. Please note that this function can be slow
  11946. * @param x defines the x coordinate of the rectangle where pixels must be read
  11947. * @param y defines the y coordinate of the rectangle where pixels must be read
  11948. * @param width defines the width of the rectangle where pixels must be read
  11949. * @param height defines the height of the rectangle where pixels must be read
  11950. * @returns a Uint8Array containing RGBA colors
  11951. */
  11952. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  11953. /**
  11954. * Add an externaly attached data from its key.
  11955. * This method call will fail and return false, if such key already exists.
  11956. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  11957. * @param key the unique key that identifies the data
  11958. * @param data the data object to associate to the key for this Engine instance
  11959. * @return true if no such key were already present and the data was added successfully, false otherwise
  11960. */
  11961. addExternalData<T>(key: string, data: T): boolean;
  11962. /**
  11963. * Get an externaly attached data from its key
  11964. * @param key the unique key that identifies the data
  11965. * @return the associated data, if present (can be null), or undefined if not present
  11966. */
  11967. getExternalData<T>(key: string): T;
  11968. /**
  11969. * Get an externaly attached data from its key, create it using a factory if it's not already present
  11970. * @param key the unique key that identifies the data
  11971. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  11972. * @return the associated data, can be null if the factory returned null.
  11973. */
  11974. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  11975. /**
  11976. * Remove an externaly attached data from the Engine instance
  11977. * @param key the unique key that identifies the data
  11978. * @return true if the data was successfully removed, false if it doesn't exist
  11979. */
  11980. removeExternalData(key: string): boolean;
  11981. /**
  11982. * Unbind all vertex attributes from the webGL context
  11983. */
  11984. unbindAllAttributes(): void;
  11985. /**
  11986. * 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
  11987. */
  11988. releaseEffects(): void;
  11989. /**
  11990. * Dispose and release all associated resources
  11991. */
  11992. dispose(): void;
  11993. /**
  11994. * Display the loading screen
  11995. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11996. */
  11997. displayLoadingUI(): void;
  11998. /**
  11999. * Hide the loading screen
  12000. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  12001. */
  12002. hideLoadingUI(): void;
  12003. /**
  12004. * Gets the current loading screen object
  12005. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  12006. */
  12007. /**
  12008. * Sets the current loading screen object
  12009. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  12010. */
  12011. loadingScreen: ILoadingScreen;
  12012. /**
  12013. * Sets the current loading screen text
  12014. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  12015. */
  12016. loadingUIText: string;
  12017. /**
  12018. * Sets the current loading screen background color
  12019. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  12020. */
  12021. loadingUIBackgroundColor: string;
  12022. /**
  12023. * Attach a new callback raised when context lost event is fired
  12024. * @param callback defines the callback to call
  12025. */
  12026. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  12027. /**
  12028. * Attach a new callback raised when context restored event is fired
  12029. * @param callback defines the callback to call
  12030. */
  12031. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  12032. /**
  12033. * Gets the source code of the vertex shader associated with a specific webGL program
  12034. * @param program defines the program to use
  12035. * @returns a string containing the source code of the vertex shader associated with the program
  12036. */
  12037. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  12038. /**
  12039. * Gets the source code of the fragment shader associated with a specific webGL program
  12040. * @param program defines the program to use
  12041. * @returns a string containing the source code of the fragment shader associated with the program
  12042. */
  12043. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  12044. /**
  12045. * Get the current error code of the webGL context
  12046. * @returns the error code
  12047. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  12048. */
  12049. getError(): number;
  12050. /**
  12051. * Gets the current framerate
  12052. * @returns a number representing the framerate
  12053. */
  12054. getFps(): number;
  12055. /**
  12056. * Gets the time spent between current and previous frame
  12057. * @returns a number representing the delta time in ms
  12058. */
  12059. getDeltaTime(): number;
  12060. private _measureFps;
  12061. /** @hidden */
  12062. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  12063. private _canRenderToFloatFramebuffer;
  12064. private _canRenderToHalfFloatFramebuffer;
  12065. private _canRenderToFramebuffer;
  12066. /** @hidden */
  12067. _getWebGLTextureType(type: number): number;
  12068. private _getInternalFormat;
  12069. /** @hidden */
  12070. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  12071. /** @hidden */
  12072. _getRGBAMultiSampleBufferFormat(type: number): number;
  12073. /** @hidden */
  12074. _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;
  12075. /** @hidden */
  12076. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  12077. private _partialLoadFile;
  12078. private _cascadeLoadFiles;
  12079. /**
  12080. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  12081. * @returns true if the engine can be created
  12082. * @ignorenaming
  12083. */
  12084. static isSupported(): boolean;
  12085. }
  12086. }
  12087. declare module BABYLON {
  12088. /**
  12089. * Options to create the null engine
  12090. */
  12091. class NullEngineOptions {
  12092. /**
  12093. * Render width (Default: 512)
  12094. */
  12095. renderWidth: number;
  12096. /**
  12097. * Render height (Default: 256)
  12098. */
  12099. renderHeight: number;
  12100. /**
  12101. * Texture size (Default: 512)
  12102. */
  12103. textureSize: number;
  12104. /**
  12105. * If delta time between frames should be constant
  12106. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  12107. */
  12108. deterministicLockstep: boolean;
  12109. /**
  12110. * Maximum about of steps between frames (Default: 4)
  12111. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  12112. */
  12113. lockstepMaxSteps: number;
  12114. }
  12115. /**
  12116. * The null engine class provides support for headless version of babylon.js.
  12117. * This can be used in server side scenario or for testing purposes
  12118. */
  12119. class NullEngine extends Engine {
  12120. private _options;
  12121. /**
  12122. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  12123. */
  12124. isDeterministicLockStep(): boolean;
  12125. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  12126. getLockstepMaxSteps(): number;
  12127. /**
  12128. * Sets hardware scaling, used to save performance if needed
  12129. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  12130. */
  12131. getHardwareScalingLevel(): number;
  12132. constructor(options?: NullEngineOptions);
  12133. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  12134. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  12135. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  12136. getRenderWidth(useScreen?: boolean): number;
  12137. getRenderHeight(useScreen?: boolean): number;
  12138. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  12139. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  12140. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  12141. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  12142. bindSamplers(effect: Effect): void;
  12143. enableEffect(effect: Effect): void;
  12144. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  12145. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  12146. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  12147. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  12148. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  12149. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  12150. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  12151. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  12152. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  12153. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  12154. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  12155. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  12156. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  12157. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  12158. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  12159. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  12160. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  12161. setFloat(uniform: WebGLUniformLocation, value: number): void;
  12162. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  12163. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  12164. setBool(uniform: WebGLUniformLocation, bool: number): void;
  12165. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  12166. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  12167. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  12168. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  12169. bindBuffers(vertexBuffers: {
  12170. [key: string]: VertexBuffer;
  12171. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  12172. wipeCaches(bruteForce?: boolean): void;
  12173. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  12174. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  12175. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  12176. /** @hidden */
  12177. _createTexture(): WebGLTexture;
  12178. /** @hidden */
  12179. _releaseTexture(texture: InternalTexture): void;
  12180. 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;
  12181. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  12182. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  12183. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  12184. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  12185. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  12186. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  12187. areAllEffectsReady(): boolean;
  12188. /**
  12189. * @hidden
  12190. * Get the current error code of the webGL context
  12191. * @returns the error code
  12192. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  12193. */
  12194. getError(): number;
  12195. /** @hidden */
  12196. _getUnpackAlignement(): number;
  12197. /** @hidden */
  12198. _unpackFlipY(value: boolean): void;
  12199. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  12200. /**
  12201. * Updates a dynamic vertex buffer.
  12202. * @param vertexBuffer the vertex buffer to update
  12203. * @param data the data used to update the vertex buffer
  12204. * @param byteOffset the byte offset of the data (optional)
  12205. * @param byteLength the byte length of the data (optional)
  12206. */
  12207. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  12208. protected _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  12209. /** @hidden */
  12210. _bindTexture(channel: number, texture: InternalTexture): void;
  12211. /** @hidden */
  12212. _releaseBuffer(buffer: WebGLBuffer): boolean;
  12213. releaseEffects(): void;
  12214. displayLoadingUI(): void;
  12215. hideLoadingUI(): void;
  12216. /** @hidden */
  12217. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  12218. /** @hidden */
  12219. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  12220. /** @hidden */
  12221. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  12222. /** @hidden */
  12223. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  12224. }
  12225. }
  12226. interface WebGLRenderingContext {
  12227. readonly RASTERIZER_DISCARD: number;
  12228. readonly DEPTH_COMPONENT24: number;
  12229. readonly TEXTURE_3D: number;
  12230. readonly TEXTURE_2D_ARRAY: number;
  12231. readonly TEXTURE_COMPARE_FUNC: number;
  12232. readonly TEXTURE_COMPARE_MODE: number;
  12233. readonly COMPARE_REF_TO_TEXTURE: number;
  12234. readonly TEXTURE_WRAP_R: number;
  12235. readonly HALF_FLOAT: number;
  12236. readonly RGB8: number;
  12237. readonly RED_INTEGER: number;
  12238. readonly RG_INTEGER: number;
  12239. readonly RGB_INTEGER: number;
  12240. readonly RGBA_INTEGER: number;
  12241. readonly R8_SNORM: number;
  12242. readonly RG8_SNORM: number;
  12243. readonly RGB8_SNORM: number;
  12244. readonly RGBA8_SNORM: number;
  12245. readonly R8I: number;
  12246. readonly RG8I: number;
  12247. readonly RGB8I: number;
  12248. readonly RGBA8I: number;
  12249. readonly R8UI: number;
  12250. readonly RG8UI: number;
  12251. readonly RGB8UI: number;
  12252. readonly RGBA8UI: number;
  12253. readonly R16I: number;
  12254. readonly RG16I: number;
  12255. readonly RGB16I: number;
  12256. readonly RGBA16I: number;
  12257. readonly R16UI: number;
  12258. readonly RG16UI: number;
  12259. readonly RGB16UI: number;
  12260. readonly RGBA16UI: number;
  12261. readonly R32I: number;
  12262. readonly RG32I: number;
  12263. readonly RGB32I: number;
  12264. readonly RGBA32I: number;
  12265. readonly R32UI: number;
  12266. readonly RG32UI: number;
  12267. readonly RGB32UI: number;
  12268. readonly RGBA32UI: number;
  12269. readonly RGB10_A2UI: number;
  12270. readonly R11F_G11F_B10F: number;
  12271. readonly RGB9_E5: number;
  12272. readonly RGB10_A2: number;
  12273. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  12274. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  12275. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  12276. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  12277. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  12278. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  12279. 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;
  12280. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  12281. readonly TRANSFORM_FEEDBACK: number;
  12282. readonly INTERLEAVED_ATTRIBS: number;
  12283. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  12284. createTransformFeedback(): WebGLTransformFeedback;
  12285. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  12286. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  12287. beginTransformFeedback(primitiveMode: number): void;
  12288. endTransformFeedback(): void;
  12289. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  12290. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  12291. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  12292. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  12293. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  12294. }
  12295. interface ImageBitmap {
  12296. readonly width: number;
  12297. readonly height: number;
  12298. close(): void;
  12299. }
  12300. interface WebGLQuery extends WebGLObject {
  12301. }
  12302. declare var WebGLQuery: {
  12303. prototype: WebGLQuery;
  12304. new (): WebGLQuery;
  12305. };
  12306. interface WebGLSampler extends WebGLObject {
  12307. }
  12308. declare var WebGLSampler: {
  12309. prototype: WebGLSampler;
  12310. new (): WebGLSampler;
  12311. };
  12312. interface WebGLSync extends WebGLObject {
  12313. }
  12314. declare var WebGLSync: {
  12315. prototype: WebGLSync;
  12316. new (): WebGLSync;
  12317. };
  12318. interface WebGLTransformFeedback extends WebGLObject {
  12319. }
  12320. declare var WebGLTransformFeedback: {
  12321. prototype: WebGLTransformFeedback;
  12322. new (): WebGLTransformFeedback;
  12323. };
  12324. interface WebGLVertexArrayObject extends WebGLObject {
  12325. }
  12326. declare var WebGLVertexArrayObject: {
  12327. prototype: WebGLVertexArrayObject;
  12328. new (): WebGLVertexArrayObject;
  12329. };
  12330. declare module BABYLON {
  12331. /**
  12332. * Gather the list of clipboard event types as constants.
  12333. */
  12334. class ClipboardEventTypes {
  12335. /**
  12336. * The clipboard event is fired when a copy command is active (pressed).
  12337. */
  12338. static readonly COPY: number;
  12339. /**
  12340. * The clipboard event is fired when a cut command is active (pressed).
  12341. */
  12342. static readonly CUT: number;
  12343. /**
  12344. * The clipboard event is fired when a paste command is active (pressed).
  12345. */
  12346. static readonly PASTE: number;
  12347. }
  12348. /**
  12349. * This class is used to store clipboard related info for the onClipboardObservable event.
  12350. */
  12351. class ClipboardInfo {
  12352. /**
  12353. * Defines the type of event (BABYLON.ClipboardEventTypes)
  12354. */
  12355. type: number;
  12356. /**
  12357. * Defines the related dom event
  12358. */
  12359. event: ClipboardEvent;
  12360. /**
  12361. *Creates an instance of ClipboardInfo.
  12362. * @param {number} type
  12363. * @param {ClipboardEvent} event
  12364. */
  12365. constructor(
  12366. /**
  12367. * Defines the type of event (BABYLON.ClipboardEventTypes)
  12368. */
  12369. type: number,
  12370. /**
  12371. * Defines the related dom event
  12372. */
  12373. event: ClipboardEvent);
  12374. /**
  12375. * Get the clipboard event's type from the keycode.
  12376. * @param keyCode Defines the keyCode for the current keyboard event.
  12377. * @return {number}
  12378. */
  12379. static GetTypeFromCharacter(keyCode: number): number;
  12380. }
  12381. }
  12382. declare module BABYLON {
  12383. /**
  12384. * Gather the list of keyboard event types as constants.
  12385. */
  12386. class KeyboardEventTypes {
  12387. /**
  12388. * The keydown event is fired when a key becomes active (pressed).
  12389. */
  12390. static readonly KEYDOWN: number;
  12391. /**
  12392. * The keyup event is fired when a key has been released.
  12393. */
  12394. static readonly KEYUP: number;
  12395. }
  12396. /**
  12397. * This class is used to store keyboard related info for the onKeyboardObservable event.
  12398. */
  12399. class KeyboardInfo {
  12400. /**
  12401. * Defines the type of event (BABYLON.KeyboardEventTypes)
  12402. */
  12403. type: number;
  12404. /**
  12405. * Defines the related dom event
  12406. */
  12407. event: KeyboardEvent;
  12408. /**
  12409. * Instantiates a new keyboard info.
  12410. * This class is used to store keyboard related info for the onKeyboardObservable event.
  12411. * @param type Defines the type of event (BABYLON.KeyboardEventTypes)
  12412. * @param event Defines the related dom event
  12413. */
  12414. constructor(
  12415. /**
  12416. * Defines the type of event (BABYLON.KeyboardEventTypes)
  12417. */
  12418. type: number,
  12419. /**
  12420. * Defines the related dom event
  12421. */
  12422. event: KeyboardEvent);
  12423. }
  12424. /**
  12425. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  12426. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  12427. */
  12428. class KeyboardInfoPre extends KeyboardInfo {
  12429. /**
  12430. * Defines the type of event (BABYLON.KeyboardEventTypes)
  12431. */
  12432. type: number;
  12433. /**
  12434. * Defines the related dom event
  12435. */
  12436. event: KeyboardEvent;
  12437. /**
  12438. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  12439. */
  12440. skipOnPointerObservable: boolean;
  12441. /**
  12442. * Instantiates a new keyboard pre info.
  12443. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  12444. * @param type Defines the type of event (BABYLON.KeyboardEventTypes)
  12445. * @param event Defines the related dom event
  12446. */
  12447. constructor(
  12448. /**
  12449. * Defines the type of event (BABYLON.KeyboardEventTypes)
  12450. */
  12451. type: number,
  12452. /**
  12453. * Defines the related dom event
  12454. */
  12455. event: KeyboardEvent);
  12456. }
  12457. }
  12458. declare module BABYLON {
  12459. /**
  12460. * Gather the list of pointer event types as constants.
  12461. */
  12462. class PointerEventTypes {
  12463. /**
  12464. * 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.
  12465. */
  12466. static readonly POINTERDOWN: number;
  12467. /**
  12468. * The pointerup event is fired when a pointer is no longer active.
  12469. */
  12470. static readonly POINTERUP: number;
  12471. /**
  12472. * The pointermove event is fired when a pointer changes coordinates.
  12473. */
  12474. static readonly POINTERMOVE: number;
  12475. /**
  12476. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12477. */
  12478. static readonly POINTERWHEEL: number;
  12479. /**
  12480. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12481. */
  12482. static readonly POINTERPICK: number;
  12483. /**
  12484. * The pointertap event is fired when a the object has been touched and released without drag.
  12485. */
  12486. static readonly POINTERTAP: number;
  12487. /**
  12488. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12489. */
  12490. static readonly POINTERDOUBLETAP: number;
  12491. }
  12492. /**
  12493. * Base class of pointer info types.
  12494. */
  12495. class PointerInfoBase {
  12496. /**
  12497. * Defines the type of event (BABYLON.PointerEventTypes)
  12498. */
  12499. type: number;
  12500. /**
  12501. * Defines the related dom event
  12502. */
  12503. event: PointerEvent | MouseWheelEvent;
  12504. /**
  12505. * Instantiates the base class of pointers info.
  12506. * @param type Defines the type of event (BABYLON.PointerEventTypes)
  12507. * @param event Defines the related dom event
  12508. */
  12509. constructor(
  12510. /**
  12511. * Defines the type of event (BABYLON.PointerEventTypes)
  12512. */
  12513. type: number,
  12514. /**
  12515. * Defines the related dom event
  12516. */
  12517. event: PointerEvent | MouseWheelEvent);
  12518. }
  12519. /**
  12520. * This class is used to store pointer related info for the onPrePointerObservable event.
  12521. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12522. */
  12523. class PointerInfoPre extends PointerInfoBase {
  12524. /**
  12525. * Ray from a pointer if availible (eg. 6dof controller)
  12526. */
  12527. ray: Nullable<Ray>;
  12528. /**
  12529. * Defines the local position of the pointer on the canvas.
  12530. */
  12531. localPosition: Vector2;
  12532. /**
  12533. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12534. */
  12535. skipOnPointerObservable: boolean;
  12536. /**
  12537. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12538. * @param type Defines the type of event (BABYLON.PointerEventTypes)
  12539. * @param event Defines the related dom event
  12540. * @param localX Defines the local x coordinates of the pointer when the event occured
  12541. * @param localY Defines the local y coordinates of the pointer when the event occured
  12542. */
  12543. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12544. }
  12545. /**
  12546. * This type contains all the data related to a pointer event in Babylon.js.
  12547. * 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.
  12548. */
  12549. class PointerInfo extends PointerInfoBase {
  12550. /**
  12551. * Defines the picking info associated to the info (if any)\
  12552. */
  12553. pickInfo: Nullable<PickingInfo>;
  12554. /**
  12555. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12556. * @param type Defines the type of event (BABYLON.PointerEventTypes)
  12557. * @param event Defines the related dom event
  12558. * @param pickInfo Defines the picking info associated to the info (if any)\
  12559. */
  12560. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12561. /**
  12562. * Defines the picking info associated to the info (if any)\
  12563. */
  12564. pickInfo: Nullable<PickingInfo>);
  12565. }
  12566. }
  12567. declare module BABYLON {
  12568. /**
  12569. * Represents a gamepad control stick position
  12570. */
  12571. class StickValues {
  12572. /**
  12573. * The x component of the control stick
  12574. */
  12575. x: number;
  12576. /**
  12577. * The y component of the control stick
  12578. */
  12579. y: number;
  12580. /**
  12581. * Initializes the gamepad x and y control stick values
  12582. * @param x The x component of the gamepad control stick value
  12583. * @param y The y component of the gamepad control stick value
  12584. */
  12585. constructor(
  12586. /**
  12587. * The x component of the control stick
  12588. */
  12589. x: number,
  12590. /**
  12591. * The y component of the control stick
  12592. */
  12593. y: number);
  12594. }
  12595. /**
  12596. * An interface which manages callbacks for gamepad button changes
  12597. */
  12598. interface GamepadButtonChanges {
  12599. /**
  12600. * Called when a gamepad has been changed
  12601. */
  12602. changed: boolean;
  12603. /**
  12604. * Called when a gamepad press event has been triggered
  12605. */
  12606. pressChanged: boolean;
  12607. /**
  12608. * Called when a touch event has been triggered
  12609. */
  12610. touchChanged: boolean;
  12611. /**
  12612. * Called when a value has changed
  12613. */
  12614. valueChanged: boolean;
  12615. }
  12616. /**
  12617. * Represents a gamepad
  12618. */
  12619. class Gamepad {
  12620. /**
  12621. * The id of the gamepad
  12622. */
  12623. id: string;
  12624. /**
  12625. * The index of the gamepad
  12626. */
  12627. index: number;
  12628. /**
  12629. * The browser gamepad
  12630. */
  12631. browserGamepad: any;
  12632. /**
  12633. * Specifies what type of gamepad this represents
  12634. */
  12635. type: number;
  12636. private _leftStick;
  12637. private _rightStick;
  12638. /** @hidden */
  12639. _isConnected: boolean;
  12640. private _leftStickAxisX;
  12641. private _leftStickAxisY;
  12642. private _rightStickAxisX;
  12643. private _rightStickAxisY;
  12644. /**
  12645. * Triggered when the left control stick has been changed
  12646. */
  12647. private _onleftstickchanged;
  12648. /**
  12649. * Triggered when the right control stick has been changed
  12650. */
  12651. private _onrightstickchanged;
  12652. /**
  12653. * Represents a gamepad controller
  12654. */
  12655. static GAMEPAD: number;
  12656. /**
  12657. * Represents a generic controller
  12658. */
  12659. static GENERIC: number;
  12660. /**
  12661. * Represents an XBox controller
  12662. */
  12663. static XBOX: number;
  12664. /**
  12665. * Represents a pose-enabled controller
  12666. */
  12667. static POSE_ENABLED: number;
  12668. /**
  12669. * Specifies whether the left control stick should be Y-inverted
  12670. */
  12671. protected _invertLeftStickY: boolean;
  12672. /**
  12673. * Specifies if the gamepad has been connected
  12674. */
  12675. readonly isConnected: boolean;
  12676. /**
  12677. * Initializes the gamepad
  12678. * @param id The id of the gamepad
  12679. * @param index The index of the gamepad
  12680. * @param browserGamepad The browser gamepad
  12681. * @param leftStickX The x component of the left joystick
  12682. * @param leftStickY The y component of the left joystick
  12683. * @param rightStickX The x component of the right joystick
  12684. * @param rightStickY The y component of the right joystick
  12685. */
  12686. constructor(
  12687. /**
  12688. * The id of the gamepad
  12689. */
  12690. id: string,
  12691. /**
  12692. * The index of the gamepad
  12693. */
  12694. index: number,
  12695. /**
  12696. * The browser gamepad
  12697. */
  12698. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12699. /**
  12700. * Callback triggered when the left joystick has changed
  12701. * @param callback
  12702. */
  12703. onleftstickchanged(callback: (values: StickValues) => void): void;
  12704. /**
  12705. * Callback triggered when the right joystick has changed
  12706. * @param callback
  12707. */
  12708. onrightstickchanged(callback: (values: StickValues) => void): void;
  12709. /**
  12710. * Gets the left joystick
  12711. */
  12712. /**
  12713. * Sets the left joystick values
  12714. */
  12715. leftStick: StickValues;
  12716. /**
  12717. * Gets the right joystick
  12718. */
  12719. /**
  12720. * Sets the right joystick value
  12721. */
  12722. rightStick: StickValues;
  12723. /**
  12724. * Updates the gamepad joystick positions
  12725. */
  12726. update(): void;
  12727. /**
  12728. * Disposes the gamepad
  12729. */
  12730. dispose(): void;
  12731. }
  12732. /**
  12733. * Represents a generic gamepad
  12734. */
  12735. class GenericPad extends Gamepad {
  12736. private _buttons;
  12737. private _onbuttondown;
  12738. private _onbuttonup;
  12739. /**
  12740. * Observable triggered when a button has been pressed
  12741. */
  12742. onButtonDownObservable: Observable<number>;
  12743. /**
  12744. * Observable triggered when a button has been released
  12745. */
  12746. onButtonUpObservable: Observable<number>;
  12747. /**
  12748. * Callback triggered when a button has been pressed
  12749. * @param callback Called when a button has been pressed
  12750. */
  12751. onbuttondown(callback: (buttonPressed: number) => void): void;
  12752. /**
  12753. * Callback triggered when a button has been released
  12754. * @param callback Called when a button has been released
  12755. */
  12756. onbuttonup(callback: (buttonReleased: number) => void): void;
  12757. /**
  12758. * Initializes the generic gamepad
  12759. * @param id The id of the generic gamepad
  12760. * @param index The index of the generic gamepad
  12761. * @param browserGamepad The browser gamepad
  12762. */
  12763. constructor(id: string, index: number, browserGamepad: any);
  12764. private _setButtonValue;
  12765. /**
  12766. * Updates the generic gamepad
  12767. */
  12768. update(): void;
  12769. /**
  12770. * Disposes the generic gamepad
  12771. */
  12772. dispose(): void;
  12773. }
  12774. }
  12775. declare module BABYLON {
  12776. /**
  12777. * Manager for handling gamepads
  12778. */
  12779. class GamepadManager {
  12780. private _scene?;
  12781. private _babylonGamepads;
  12782. private _oneGamepadConnected;
  12783. /** @hidden */
  12784. _isMonitoring: boolean;
  12785. private _gamepadEventSupported;
  12786. private _gamepadSupport;
  12787. /**
  12788. * observable to be triggered when the gamepad controller has been connected
  12789. */
  12790. onGamepadConnectedObservable: Observable<Gamepad>;
  12791. /**
  12792. * observable to be triggered when the gamepad controller has been disconnected
  12793. */
  12794. onGamepadDisconnectedObservable: Observable<Gamepad>;
  12795. private _onGamepadConnectedEvent;
  12796. private _onGamepadDisconnectedEvent;
  12797. /**
  12798. * Initializes the gamepad manager
  12799. * @param _scene BabylonJS scene
  12800. */
  12801. constructor(_scene?: Scene | undefined);
  12802. /**
  12803. * The gamepads in the game pad manager
  12804. */
  12805. readonly gamepads: Gamepad[];
  12806. /**
  12807. * Get the gamepad controllers based on type
  12808. * @param type The type of gamepad controller
  12809. * @returns Nullable gamepad
  12810. */
  12811. getGamepadByType(type?: number): Nullable<Gamepad>;
  12812. /**
  12813. * Disposes the gamepad manager
  12814. */
  12815. dispose(): void;
  12816. private _addNewGamepad;
  12817. private _startMonitoringGamepads;
  12818. private _stopMonitoringGamepads;
  12819. /** @hidden */
  12820. _checkGamepadsStatus(): void;
  12821. private _updateGamepadObjects;
  12822. }
  12823. }
  12824. declare module BABYLON {
  12825. interface Scene {
  12826. /** @hidden */
  12827. _gamepadManager: Nullable<GamepadManager>;
  12828. /**
  12829. * Gets the gamepad manager associated with the scene
  12830. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  12831. */
  12832. gamepadManager: GamepadManager;
  12833. }
  12834. /**
  12835. * Interface representing a free camera inputs manager
  12836. */
  12837. interface FreeCameraInputsManager {
  12838. /**
  12839. * Adds gamepad input support to the FreeCameraInputsManager.
  12840. * @returns the FreeCameraInputsManager
  12841. */
  12842. addGamepad(): FreeCameraInputsManager;
  12843. }
  12844. /**
  12845. * Interface representing an arc rotate camera inputs manager
  12846. */
  12847. interface ArcRotateCameraInputsManager {
  12848. /**
  12849. * Adds gamepad input support to the ArcRotateCamera InputManager.
  12850. * @returns the camera inputs manager
  12851. */
  12852. addGamepad(): ArcRotateCameraInputsManager;
  12853. }
  12854. /**
  12855. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  12856. */
  12857. class GamepadSystemSceneComponent implements ISceneComponent {
  12858. /**
  12859. * The component name helpfull to identify the component in the list of scene components.
  12860. */
  12861. readonly name: string;
  12862. /**
  12863. * The scene the component belongs to.
  12864. */
  12865. scene: Scene;
  12866. /**
  12867. * Creates a new instance of the component for the given scene
  12868. * @param scene Defines the scene to register the component in
  12869. */
  12870. constructor(scene: Scene);
  12871. /**
  12872. * Registers the component in a given scene
  12873. */
  12874. register(): void;
  12875. /**
  12876. * Rebuilds the elements related to this component in case of
  12877. * context lost for instance.
  12878. */
  12879. rebuild(): void;
  12880. /**
  12881. * Disposes the component and the associated ressources
  12882. */
  12883. dispose(): void;
  12884. private _beforeCameraUpdate;
  12885. }
  12886. }
  12887. declare module BABYLON {
  12888. /**
  12889. * Defines supported buttons for XBox360 compatible gamepads
  12890. */
  12891. enum Xbox360Button {
  12892. /** A */
  12893. A = 0,
  12894. /** B */
  12895. B = 1,
  12896. /** X */
  12897. X = 2,
  12898. /** Y */
  12899. Y = 3,
  12900. /** Start */
  12901. Start = 4,
  12902. /** Back */
  12903. Back = 5,
  12904. /** Left button */
  12905. LB = 6,
  12906. /** Right button */
  12907. RB = 7,
  12908. /** Left stick */
  12909. LeftStick = 8,
  12910. /** Right stick */
  12911. RightStick = 9
  12912. }
  12913. /** Defines values for XBox360 DPad */
  12914. enum Xbox360Dpad {
  12915. /** Up */
  12916. Up = 0,
  12917. /** Down */
  12918. Down = 1,
  12919. /** Left */
  12920. Left = 2,
  12921. /** Right */
  12922. Right = 3
  12923. }
  12924. /**
  12925. * Defines a XBox360 gamepad
  12926. */
  12927. class Xbox360Pad extends Gamepad {
  12928. private _leftTrigger;
  12929. private _rightTrigger;
  12930. private _onlefttriggerchanged;
  12931. private _onrighttriggerchanged;
  12932. private _onbuttondown;
  12933. private _onbuttonup;
  12934. private _ondpaddown;
  12935. private _ondpadup;
  12936. /** Observable raised when a button is pressed */
  12937. onButtonDownObservable: Observable<Xbox360Button>;
  12938. /** Observable raised when a button is released */
  12939. onButtonUpObservable: Observable<Xbox360Button>;
  12940. /** Observable raised when a pad is pressed */
  12941. onPadDownObservable: Observable<Xbox360Dpad>;
  12942. /** Observable raised when a pad is released */
  12943. onPadUpObservable: Observable<Xbox360Dpad>;
  12944. private _buttonA;
  12945. private _buttonB;
  12946. private _buttonX;
  12947. private _buttonY;
  12948. private _buttonBack;
  12949. private _buttonStart;
  12950. private _buttonLB;
  12951. private _buttonRB;
  12952. private _buttonLeftStick;
  12953. private _buttonRightStick;
  12954. private _dPadUp;
  12955. private _dPadDown;
  12956. private _dPadLeft;
  12957. private _dPadRight;
  12958. private _isXboxOnePad;
  12959. /**
  12960. * Creates a new XBox360 gamepad object
  12961. * @param id defines the id of this gamepad
  12962. * @param index defines its index
  12963. * @param gamepad defines the internal HTML gamepad object
  12964. * @param xboxOne defines if it is a XBox One gamepad
  12965. */
  12966. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  12967. /**
  12968. * Defines the callback to call when left trigger is pressed
  12969. * @param callback defines the callback to use
  12970. */
  12971. onlefttriggerchanged(callback: (value: number) => void): void;
  12972. /**
  12973. * Defines the callback to call when right trigger is pressed
  12974. * @param callback defines the callback to use
  12975. */
  12976. onrighttriggerchanged(callback: (value: number) => void): void;
  12977. /**
  12978. * Gets the left trigger value
  12979. */
  12980. /**
  12981. * Sets the left trigger value
  12982. */
  12983. leftTrigger: number;
  12984. /**
  12985. * Gets the right trigger value
  12986. */
  12987. /**
  12988. * Sets the right trigger value
  12989. */
  12990. rightTrigger: number;
  12991. /**
  12992. * Defines the callback to call when a button is pressed
  12993. * @param callback defines the callback to use
  12994. */
  12995. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  12996. /**
  12997. * Defines the callback to call when a button is released
  12998. * @param callback defines the callback to use
  12999. */
  13000. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  13001. /**
  13002. * Defines the callback to call when a pad is pressed
  13003. * @param callback defines the callback to use
  13004. */
  13005. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  13006. /**
  13007. * Defines the callback to call when a pad is released
  13008. * @param callback defines the callback to use
  13009. */
  13010. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  13011. private _setButtonValue;
  13012. private _setDPadValue;
  13013. /**
  13014. * Gets the value of the `A` button
  13015. */
  13016. /**
  13017. * Sets the value of the `A` button
  13018. */
  13019. buttonA: number;
  13020. /**
  13021. * Gets the value of the `B` button
  13022. */
  13023. /**
  13024. * Sets the value of the `B` button
  13025. */
  13026. buttonB: number;
  13027. /**
  13028. * Gets the value of the `X` button
  13029. */
  13030. /**
  13031. * Sets the value of the `X` button
  13032. */
  13033. buttonX: number;
  13034. /**
  13035. * Gets the value of the `Y` button
  13036. */
  13037. /**
  13038. * Sets the value of the `Y` button
  13039. */
  13040. buttonY: number;
  13041. /**
  13042. * Gets the value of the `Start` button
  13043. */
  13044. /**
  13045. * Sets the value of the `Start` button
  13046. */
  13047. buttonStart: number;
  13048. /**
  13049. * Gets the value of the `Back` button
  13050. */
  13051. /**
  13052. * Sets the value of the `Back` button
  13053. */
  13054. buttonBack: number;
  13055. /**
  13056. * Gets the value of the `Left` button
  13057. */
  13058. /**
  13059. * Sets the value of the `Left` button
  13060. */
  13061. buttonLB: number;
  13062. /**
  13063. * Gets the value of the `Right` button
  13064. */
  13065. /**
  13066. * Sets the value of the `Right` button
  13067. */
  13068. buttonRB: number;
  13069. /**
  13070. * Gets the value of the Left joystick
  13071. */
  13072. /**
  13073. * Sets the value of the Left joystick
  13074. */
  13075. buttonLeftStick: number;
  13076. /**
  13077. * Gets the value of the Right joystick
  13078. */
  13079. /**
  13080. * Sets the value of the Right joystick
  13081. */
  13082. buttonRightStick: number;
  13083. /**
  13084. * Gets the value of D-pad up
  13085. */
  13086. /**
  13087. * Sets the value of D-pad up
  13088. */
  13089. dPadUp: number;
  13090. /**
  13091. * Gets the value of D-pad down
  13092. */
  13093. /**
  13094. * Sets the value of D-pad down
  13095. */
  13096. dPadDown: number;
  13097. /**
  13098. * Gets the value of D-pad left
  13099. */
  13100. /**
  13101. * Sets the value of D-pad left
  13102. */
  13103. dPadLeft: number;
  13104. /**
  13105. * Gets the value of D-pad right
  13106. */
  13107. /**
  13108. * Sets the value of D-pad right
  13109. */
  13110. dPadRight: number;
  13111. /**
  13112. * Force the gamepad to synchronize with device values
  13113. */
  13114. update(): void;
  13115. /**
  13116. * Disposes the gamepad
  13117. */
  13118. dispose(): void;
  13119. }
  13120. }
  13121. declare module BABYLON {
  13122. /**
  13123. * Single axis drag gizmo
  13124. */
  13125. class AxisDragGizmo extends Gizmo {
  13126. /**
  13127. * Drag behavior responsible for the gizmos dragging interactions
  13128. */
  13129. dragBehavior: PointerDragBehavior;
  13130. private _pointerObserver;
  13131. /**
  13132. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  13133. */
  13134. snapDistance: number;
  13135. /**
  13136. * Event that fires each time the gizmo snaps to a new location.
  13137. * * snapDistance is the the change in distance
  13138. */
  13139. onSnapObservable: Observable<{
  13140. snapDistance: number;
  13141. }>;
  13142. /** @hidden */
  13143. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  13144. /** @hidden */
  13145. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  13146. /**
  13147. * Creates an AxisDragGizmo
  13148. * @param gizmoLayer The utility layer the gizmo will be added to
  13149. * @param dragAxis The axis which the gizmo will be able to drag on
  13150. * @param color The color of the gizmo
  13151. */
  13152. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  13153. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  13154. /**
  13155. * Disposes of the gizmo
  13156. */
  13157. dispose(): void;
  13158. }
  13159. }
  13160. declare module BABYLON {
  13161. /**
  13162. * Single axis scale gizmo
  13163. */
  13164. class AxisScaleGizmo extends Gizmo {
  13165. private _coloredMaterial;
  13166. /**
  13167. * Drag behavior responsible for the gizmos dragging interactions
  13168. */
  13169. dragBehavior: PointerDragBehavior;
  13170. private _pointerObserver;
  13171. /**
  13172. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  13173. */
  13174. snapDistance: number;
  13175. /**
  13176. * Event that fires each time the gizmo snaps to a new location.
  13177. * * snapDistance is the the change in distance
  13178. */
  13179. onSnapObservable: Observable<{
  13180. snapDistance: number;
  13181. }>;
  13182. /**
  13183. * If the scaling operation should be done on all axis (default: false)
  13184. */
  13185. uniformScaling: boolean;
  13186. /**
  13187. * Creates an AxisScaleGizmo
  13188. * @param gizmoLayer The utility layer the gizmo will be added to
  13189. * @param dragAxis The axis which the gizmo will be able to scale on
  13190. * @param color The color of the gizmo
  13191. */
  13192. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  13193. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  13194. /**
  13195. * Disposes of the gizmo
  13196. */
  13197. dispose(): void;
  13198. /**
  13199. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  13200. * @param mesh The mesh to replace the default mesh of the gizmo
  13201. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  13202. */
  13203. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  13204. }
  13205. }
  13206. declare module BABYLON {
  13207. /**
  13208. * Bounding box gizmo
  13209. */
  13210. class BoundingBoxGizmo extends Gizmo {
  13211. private _lineBoundingBox;
  13212. private _rotateSpheresParent;
  13213. private _scaleBoxesParent;
  13214. private _boundingDimensions;
  13215. private _renderObserver;
  13216. private _pointerObserver;
  13217. private _scaleDragSpeed;
  13218. private _tmpQuaternion;
  13219. private _tmpVector;
  13220. private _tmpRotationMatrix;
  13221. /**
  13222. * 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)
  13223. */
  13224. ignoreChildren: boolean;
  13225. /**
  13226. * 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)
  13227. */
  13228. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  13229. /**
  13230. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  13231. */
  13232. rotationSphereSize: number;
  13233. /**
  13234. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  13235. */
  13236. scaleBoxSize: number;
  13237. /**
  13238. * 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)
  13239. */
  13240. fixedDragMeshScreenSize: boolean;
  13241. /**
  13242. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  13243. */
  13244. fixedDragMeshScreenSizeDistanceFactor: number;
  13245. /**
  13246. * Fired when a rotation sphere or scale box is dragged
  13247. */
  13248. onDragStartObservable: Observable<{}>;
  13249. /**
  13250. * Fired when a scale box is dragged
  13251. */
  13252. onScaleBoxDragObservable: Observable<{}>;
  13253. /**
  13254. * Fired when a scale box drag is ended
  13255. */
  13256. onScaleBoxDragEndObservable: Observable<{}>;
  13257. /**
  13258. * Fired when a rotation sphere is dragged
  13259. */
  13260. onRotationSphereDragObservable: Observable<{}>;
  13261. /**
  13262. * Fired when a rotation sphere drag is ended
  13263. */
  13264. onRotationSphereDragEndObservable: Observable<{}>;
  13265. /**
  13266. * 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)
  13267. */
  13268. scalePivot: Nullable<Vector3>;
  13269. private _anchorMesh;
  13270. private _existingMeshScale;
  13271. private static _PivotCached;
  13272. private static _OldPivotPoint;
  13273. private static _PivotTranslation;
  13274. private static _PivotTmpVector;
  13275. /** @hidden */
  13276. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  13277. /** @hidden */
  13278. static _RestorePivotPoint(mesh: AbstractMesh): void;
  13279. /**
  13280. * Creates an BoundingBoxGizmo
  13281. * @param gizmoLayer The utility layer the gizmo will be added to
  13282. * @param color The color of the gizmo
  13283. */
  13284. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  13285. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  13286. private _selectNode;
  13287. /**
  13288. * Updates the bounding box information for the Gizmo
  13289. */
  13290. updateBoundingBox(): void;
  13291. private _updateRotationSpheres;
  13292. private _updateScaleBoxes;
  13293. /**
  13294. * Enables rotation on the specified axis and disables rotation on the others
  13295. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  13296. */
  13297. setEnabledRotationAxis(axis: string): void;
  13298. /**
  13299. * Disposes of the gizmo
  13300. */
  13301. dispose(): void;
  13302. /**
  13303. * 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)
  13304. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  13305. * @returns the bounding box mesh with the passed in mesh as a child
  13306. */
  13307. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  13308. /**
  13309. * CustomMeshes are not supported by this gizmo
  13310. * @param mesh The mesh to replace the default mesh of the gizmo
  13311. */
  13312. setCustomMesh(mesh: Mesh): void;
  13313. }
  13314. }
  13315. declare module BABYLON {
  13316. /**
  13317. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  13318. */
  13319. class Gizmo implements IDisposable {
  13320. /** The utility layer the gizmo will be added to */
  13321. gizmoLayer: UtilityLayerRenderer;
  13322. /**
  13323. * The root mesh of the gizmo
  13324. */
  13325. protected _rootMesh: Mesh;
  13326. private _attachedMesh;
  13327. /**
  13328. * Ratio for the scale of the gizmo (Default: 1)
  13329. */
  13330. scaleRatio: number;
  13331. private _tmpMatrix;
  13332. /**
  13333. * If a custom mesh has been set (Default: false)
  13334. */
  13335. protected _customMeshSet: boolean;
  13336. /**
  13337. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  13338. * * When set, interactions will be enabled
  13339. */
  13340. attachedMesh: Nullable<AbstractMesh>;
  13341. /**
  13342. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  13343. * @param mesh The mesh to replace the default mesh of the gizmo
  13344. */
  13345. setCustomMesh(mesh: Mesh): void;
  13346. /**
  13347. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  13348. */
  13349. updateGizmoRotationToMatchAttachedMesh: boolean;
  13350. /**
  13351. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  13352. */
  13353. updateGizmoPositionToMatchAttachedMesh: boolean;
  13354. /**
  13355. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  13356. */
  13357. protected _updateScale: boolean;
  13358. protected _interactionsEnabled: boolean;
  13359. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  13360. private _beforeRenderObserver;
  13361. /**
  13362. * Creates a gizmo
  13363. * @param gizmoLayer The utility layer the gizmo will be added to
  13364. */
  13365. constructor(
  13366. /** The utility layer the gizmo will be added to */
  13367. gizmoLayer?: UtilityLayerRenderer);
  13368. private _tempVector;
  13369. /**
  13370. * @hidden
  13371. * Updates the gizmo to match the attached mesh's position/rotation
  13372. */
  13373. protected _update(): void;
  13374. /**
  13375. * Disposes of the gizmo
  13376. */
  13377. dispose(): void;
  13378. }
  13379. }
  13380. declare module BABYLON {
  13381. /**
  13382. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  13383. */
  13384. class GizmoManager implements IDisposable {
  13385. private scene;
  13386. /**
  13387. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  13388. */
  13389. gizmos: {
  13390. positionGizmo: Nullable<PositionGizmo>;
  13391. rotationGizmo: Nullable<RotationGizmo>;
  13392. scaleGizmo: Nullable<ScaleGizmo>;
  13393. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  13394. };
  13395. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  13396. clearGizmoOnEmptyPointerEvent: boolean;
  13397. /** Fires an event when the manager is attached to a mesh */
  13398. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  13399. private _gizmosEnabled;
  13400. private _pointerObserver;
  13401. private _attachedMesh;
  13402. private _boundingBoxColor;
  13403. private _defaultUtilityLayer;
  13404. private _defaultKeepDepthUtilityLayer;
  13405. /**
  13406. * When bounding box gizmo is enabled, this can be used to track drag/end events
  13407. */
  13408. boundingBoxDragBehavior: SixDofDragBehavior;
  13409. /**
  13410. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  13411. */
  13412. attachableMeshes: Nullable<Array<AbstractMesh>>;
  13413. /**
  13414. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  13415. */
  13416. usePointerToAttachGizmos: boolean;
  13417. /**
  13418. * Instatiates a gizmo manager
  13419. * @param scene the scene to overlay the gizmos on top of
  13420. */
  13421. constructor(scene: Scene);
  13422. /**
  13423. * Attaches a set of gizmos to the specified mesh
  13424. * @param mesh The mesh the gizmo's should be attached to
  13425. */
  13426. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  13427. /**
  13428. * If the position gizmo is enabled
  13429. */
  13430. positionGizmoEnabled: boolean;
  13431. /**
  13432. * If the rotation gizmo is enabled
  13433. */
  13434. rotationGizmoEnabled: boolean;
  13435. /**
  13436. * If the scale gizmo is enabled
  13437. */
  13438. scaleGizmoEnabled: boolean;
  13439. /**
  13440. * If the boundingBox gizmo is enabled
  13441. */
  13442. boundingBoxGizmoEnabled: boolean;
  13443. /**
  13444. * Disposes of the gizmo manager
  13445. */
  13446. dispose(): void;
  13447. }
  13448. }
  13449. declare module BABYLON {
  13450. /**
  13451. * Single plane rotation gizmo
  13452. */
  13453. class PlaneRotationGizmo extends Gizmo {
  13454. /**
  13455. * Drag behavior responsible for the gizmos dragging interactions
  13456. */
  13457. dragBehavior: PointerDragBehavior;
  13458. private _pointerObserver;
  13459. /**
  13460. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  13461. */
  13462. snapDistance: number;
  13463. /**
  13464. * Event that fires each time the gizmo snaps to a new location.
  13465. * * snapDistance is the the change in distance
  13466. */
  13467. onSnapObservable: Observable<{
  13468. snapDistance: number;
  13469. }>;
  13470. /**
  13471. * Creates a PlaneRotationGizmo
  13472. * @param gizmoLayer The utility layer the gizmo will be added to
  13473. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  13474. * @param color The color of the gizmo
  13475. * @param tessellation Amount of tessellation to be used when creating rotation circles
  13476. */
  13477. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  13478. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  13479. /**
  13480. * Disposes of the gizmo
  13481. */
  13482. dispose(): void;
  13483. }
  13484. }
  13485. declare module BABYLON {
  13486. /**
  13487. * Gizmo that enables dragging a mesh along 3 axis
  13488. */
  13489. class PositionGizmo extends Gizmo {
  13490. /**
  13491. * Internal gizmo used for interactions on the x axis
  13492. */
  13493. xGizmo: AxisDragGizmo;
  13494. /**
  13495. * Internal gizmo used for interactions on the y axis
  13496. */
  13497. yGizmo: AxisDragGizmo;
  13498. /**
  13499. * Internal gizmo used for interactions on the z axis
  13500. */
  13501. zGizmo: AxisDragGizmo;
  13502. /** Fires an event when any of it's sub gizmos are dragged */
  13503. onDragStartObservable: Observable<{}>;
  13504. /** Fires an event when any of it's sub gizmos are released from dragging */
  13505. onDragEndObservable: Observable<{}>;
  13506. attachedMesh: Nullable<AbstractMesh>;
  13507. /**
  13508. * Creates a PositionGizmo
  13509. * @param gizmoLayer The utility layer the gizmo will be added to
  13510. */
  13511. constructor(gizmoLayer?: UtilityLayerRenderer);
  13512. updateGizmoRotationToMatchAttachedMesh: boolean;
  13513. /**
  13514. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  13515. */
  13516. snapDistance: number;
  13517. /**
  13518. * Ratio for the scale of the gizmo (Default: 1)
  13519. */
  13520. scaleRatio: number;
  13521. /**
  13522. * Disposes of the gizmo
  13523. */
  13524. dispose(): void;
  13525. /**
  13526. * CustomMeshes are not supported by this gizmo
  13527. * @param mesh The mesh to replace the default mesh of the gizmo
  13528. */
  13529. setCustomMesh(mesh: Mesh): void;
  13530. }
  13531. }
  13532. declare module BABYLON {
  13533. /**
  13534. * Gizmo that enables rotating a mesh along 3 axis
  13535. */
  13536. class RotationGizmo extends Gizmo {
  13537. /**
  13538. * Internal gizmo used for interactions on the x axis
  13539. */
  13540. xGizmo: PlaneRotationGizmo;
  13541. /**
  13542. * Internal gizmo used for interactions on the y axis
  13543. */
  13544. yGizmo: PlaneRotationGizmo;
  13545. /**
  13546. * Internal gizmo used for interactions on the z axis
  13547. */
  13548. zGizmo: PlaneRotationGizmo;
  13549. /** Fires an event when any of it's sub gizmos are dragged */
  13550. onDragStartObservable: Observable<{}>;
  13551. /** Fires an event when any of it's sub gizmos are released from dragging */
  13552. onDragEndObservable: Observable<{}>;
  13553. attachedMesh: Nullable<AbstractMesh>;
  13554. /**
  13555. * Creates a RotationGizmo
  13556. * @param gizmoLayer The utility layer the gizmo will be added to
  13557. * @param tessellation Amount of tessellation to be used when creating rotation circles
  13558. */
  13559. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  13560. updateGizmoRotationToMatchAttachedMesh: boolean;
  13561. /**
  13562. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  13563. */
  13564. snapDistance: number;
  13565. /**
  13566. * Ratio for the scale of the gizmo (Default: 1)
  13567. */
  13568. scaleRatio: number;
  13569. /**
  13570. * Disposes of the gizmo
  13571. */
  13572. dispose(): void;
  13573. /**
  13574. * CustomMeshes are not supported by this gizmo
  13575. * @param mesh The mesh to replace the default mesh of the gizmo
  13576. */
  13577. setCustomMesh(mesh: Mesh): void;
  13578. }
  13579. }
  13580. declare module BABYLON {
  13581. /**
  13582. * Gizmo that enables scaling a mesh along 3 axis
  13583. */
  13584. class ScaleGizmo extends Gizmo {
  13585. /**
  13586. * Internal gizmo used for interactions on the x axis
  13587. */
  13588. xGizmo: AxisScaleGizmo;
  13589. /**
  13590. * Internal gizmo used for interactions on the y axis
  13591. */
  13592. yGizmo: AxisScaleGizmo;
  13593. /**
  13594. * Internal gizmo used for interactions on the z axis
  13595. */
  13596. zGizmo: AxisScaleGizmo;
  13597. /**
  13598. * Internal gizmo used to scale all axis equally
  13599. */
  13600. uniformScaleGizmo: AxisScaleGizmo;
  13601. /** Fires an event when any of it's sub gizmos are dragged */
  13602. onDragStartObservable: Observable<{}>;
  13603. /** Fires an event when any of it's sub gizmos are released from dragging */
  13604. onDragEndObservable: Observable<{}>;
  13605. attachedMesh: Nullable<AbstractMesh>;
  13606. /**
  13607. * Creates a ScaleGizmo
  13608. * @param gizmoLayer The utility layer the gizmo will be added to
  13609. */
  13610. constructor(gizmoLayer?: UtilityLayerRenderer);
  13611. updateGizmoRotationToMatchAttachedMesh: boolean;
  13612. /**
  13613. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  13614. */
  13615. snapDistance: number;
  13616. /**
  13617. * Ratio for the scale of the gizmo (Default: 1)
  13618. */
  13619. scaleRatio: number;
  13620. /**
  13621. * Disposes of the gizmo
  13622. */
  13623. dispose(): void;
  13624. }
  13625. }
  13626. declare module BABYLON {
  13627. /**
  13628. * Represents the different options available during the creation of
  13629. * a Environment helper.
  13630. *
  13631. * This can control the default ground, skybox and image processing setup of your scene.
  13632. */
  13633. interface IEnvironmentHelperOptions {
  13634. /**
  13635. * Specifies wether or not to create a ground.
  13636. * True by default.
  13637. */
  13638. createGround: boolean;
  13639. /**
  13640. * Specifies the ground size.
  13641. * 15 by default.
  13642. */
  13643. groundSize: number;
  13644. /**
  13645. * The texture used on the ground for the main color.
  13646. * Comes from the BabylonJS CDN by default.
  13647. *
  13648. * Remarks: Can be either a texture or a url.
  13649. */
  13650. groundTexture: string | BaseTexture;
  13651. /**
  13652. * The color mixed in the ground texture by default.
  13653. * BabylonJS clearColor by default.
  13654. */
  13655. groundColor: Color3;
  13656. /**
  13657. * Specifies the ground opacity.
  13658. * 1 by default.
  13659. */
  13660. groundOpacity: number;
  13661. /**
  13662. * Enables the ground to receive shadows.
  13663. * True by default.
  13664. */
  13665. enableGroundShadow: boolean;
  13666. /**
  13667. * Helps preventing the shadow to be fully black on the ground.
  13668. * 0.5 by default.
  13669. */
  13670. groundShadowLevel: number;
  13671. /**
  13672. * Creates a mirror texture attach to the ground.
  13673. * false by default.
  13674. */
  13675. enableGroundMirror: boolean;
  13676. /**
  13677. * Specifies the ground mirror size ratio.
  13678. * 0.3 by default as the default kernel is 64.
  13679. */
  13680. groundMirrorSizeRatio: number;
  13681. /**
  13682. * Specifies the ground mirror blur kernel size.
  13683. * 64 by default.
  13684. */
  13685. groundMirrorBlurKernel: number;
  13686. /**
  13687. * Specifies the ground mirror visibility amount.
  13688. * 1 by default
  13689. */
  13690. groundMirrorAmount: number;
  13691. /**
  13692. * Specifies the ground mirror reflectance weight.
  13693. * This uses the standard weight of the background material to setup the fresnel effect
  13694. * of the mirror.
  13695. * 1 by default.
  13696. */
  13697. groundMirrorFresnelWeight: number;
  13698. /**
  13699. * Specifies the ground mirror Falloff distance.
  13700. * This can helps reducing the size of the reflection.
  13701. * 0 by Default.
  13702. */
  13703. groundMirrorFallOffDistance: number;
  13704. /**
  13705. * Specifies the ground mirror texture type.
  13706. * Unsigned Int by Default.
  13707. */
  13708. groundMirrorTextureType: number;
  13709. /**
  13710. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  13711. * the shown objects.
  13712. */
  13713. groundYBias: number;
  13714. /**
  13715. * Specifies wether or not to create a skybox.
  13716. * True by default.
  13717. */
  13718. createSkybox: boolean;
  13719. /**
  13720. * Specifies the skybox size.
  13721. * 20 by default.
  13722. */
  13723. skyboxSize: number;
  13724. /**
  13725. * The texture used on the skybox for the main color.
  13726. * Comes from the BabylonJS CDN by default.
  13727. *
  13728. * Remarks: Can be either a texture or a url.
  13729. */
  13730. skyboxTexture: string | BaseTexture;
  13731. /**
  13732. * The color mixed in the skybox texture by default.
  13733. * BabylonJS clearColor by default.
  13734. */
  13735. skyboxColor: Color3;
  13736. /**
  13737. * The background rotation around the Y axis of the scene.
  13738. * This helps aligning the key lights of your scene with the background.
  13739. * 0 by default.
  13740. */
  13741. backgroundYRotation: number;
  13742. /**
  13743. * Compute automatically the size of the elements to best fit with the scene.
  13744. */
  13745. sizeAuto: boolean;
  13746. /**
  13747. * Default position of the rootMesh if autoSize is not true.
  13748. */
  13749. rootPosition: Vector3;
  13750. /**
  13751. * Sets up the image processing in the scene.
  13752. * true by default.
  13753. */
  13754. setupImageProcessing: boolean;
  13755. /**
  13756. * The texture used as your environment texture in the scene.
  13757. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  13758. *
  13759. * Remarks: Can be either a texture or a url.
  13760. */
  13761. environmentTexture: string | BaseTexture;
  13762. /**
  13763. * The value of the exposure to apply to the scene.
  13764. * 0.6 by default if setupImageProcessing is true.
  13765. */
  13766. cameraExposure: number;
  13767. /**
  13768. * The value of the contrast to apply to the scene.
  13769. * 1.6 by default if setupImageProcessing is true.
  13770. */
  13771. cameraContrast: number;
  13772. /**
  13773. * Specifies wether or not tonemapping should be enabled in the scene.
  13774. * true by default if setupImageProcessing is true.
  13775. */
  13776. toneMappingEnabled: boolean;
  13777. }
  13778. /**
  13779. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  13780. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  13781. * It also helps with the default setup of your imageProcessing configuration.
  13782. */
  13783. class EnvironmentHelper {
  13784. /**
  13785. * Default ground texture URL.
  13786. */
  13787. private static _groundTextureCDNUrl;
  13788. /**
  13789. * Default skybox texture URL.
  13790. */
  13791. private static _skyboxTextureCDNUrl;
  13792. /**
  13793. * Default environment texture URL.
  13794. */
  13795. private static _environmentTextureCDNUrl;
  13796. /**
  13797. * Creates the default options for the helper.
  13798. */
  13799. private static _getDefaultOptions;
  13800. private _rootMesh;
  13801. /**
  13802. * Gets the root mesh created by the helper.
  13803. */
  13804. readonly rootMesh: Mesh;
  13805. private _skybox;
  13806. /**
  13807. * Gets the skybox created by the helper.
  13808. */
  13809. readonly skybox: Nullable<Mesh>;
  13810. private _skyboxTexture;
  13811. /**
  13812. * Gets the skybox texture created by the helper.
  13813. */
  13814. readonly skyboxTexture: Nullable<BaseTexture>;
  13815. private _skyboxMaterial;
  13816. /**
  13817. * Gets the skybox material created by the helper.
  13818. */
  13819. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  13820. private _ground;
  13821. /**
  13822. * Gets the ground mesh created by the helper.
  13823. */
  13824. readonly ground: Nullable<Mesh>;
  13825. private _groundTexture;
  13826. /**
  13827. * Gets the ground texture created by the helper.
  13828. */
  13829. readonly groundTexture: Nullable<BaseTexture>;
  13830. private _groundMirror;
  13831. /**
  13832. * Gets the ground mirror created by the helper.
  13833. */
  13834. readonly groundMirror: Nullable<MirrorTexture>;
  13835. /**
  13836. * Gets the ground mirror render list to helps pushing the meshes
  13837. * you wish in the ground reflection.
  13838. */
  13839. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  13840. private _groundMaterial;
  13841. /**
  13842. * Gets the ground material created by the helper.
  13843. */
  13844. readonly groundMaterial: Nullable<BackgroundMaterial>;
  13845. /**
  13846. * Stores the creation options.
  13847. */
  13848. private readonly _scene;
  13849. private _options;
  13850. /**
  13851. * This observable will be notified with any error during the creation of the environment,
  13852. * mainly texture creation errors.
  13853. */
  13854. onErrorObservable: Observable<{
  13855. message?: string;
  13856. exception?: any;
  13857. }>;
  13858. /**
  13859. * constructor
  13860. * @param options
  13861. * @param scene The scene to add the material to
  13862. */
  13863. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  13864. /**
  13865. * Updates the background according to the new options
  13866. * @param options
  13867. */
  13868. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  13869. /**
  13870. * Sets the primary color of all the available elements.
  13871. * @param color the main color to affect to the ground and the background
  13872. */
  13873. setMainColor(color: Color3): void;
  13874. /**
  13875. * Setup the image processing according to the specified options.
  13876. */
  13877. private _setupImageProcessing;
  13878. /**
  13879. * Setup the environment texture according to the specified options.
  13880. */
  13881. private _setupEnvironmentTexture;
  13882. /**
  13883. * Setup the background according to the specified options.
  13884. */
  13885. private _setupBackground;
  13886. /**
  13887. * Get the scene sizes according to the setup.
  13888. */
  13889. private _getSceneSize;
  13890. /**
  13891. * Setup the ground according to the specified options.
  13892. */
  13893. private _setupGround;
  13894. /**
  13895. * Setup the ground material according to the specified options.
  13896. */
  13897. private _setupGroundMaterial;
  13898. /**
  13899. * Setup the ground diffuse texture according to the specified options.
  13900. */
  13901. private _setupGroundDiffuseTexture;
  13902. /**
  13903. * Setup the ground mirror texture according to the specified options.
  13904. */
  13905. private _setupGroundMirrorTexture;
  13906. /**
  13907. * Setup the ground to receive the mirror texture.
  13908. */
  13909. private _setupMirrorInGroundMaterial;
  13910. /**
  13911. * Setup the skybox according to the specified options.
  13912. */
  13913. private _setupSkybox;
  13914. /**
  13915. * Setup the skybox material according to the specified options.
  13916. */
  13917. private _setupSkyboxMaterial;
  13918. /**
  13919. * Setup the skybox reflection texture according to the specified options.
  13920. */
  13921. private _setupSkyboxReflectionTexture;
  13922. private _errorHandler;
  13923. /**
  13924. * Dispose all the elements created by the Helper.
  13925. */
  13926. dispose(): void;
  13927. }
  13928. }
  13929. declare module BABYLON {
  13930. /**
  13931. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  13932. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  13933. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  13934. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  13935. */
  13936. class PhotoDome extends TransformNode {
  13937. private _useDirectMapping;
  13938. /**
  13939. * The texture being displayed on the sphere
  13940. */
  13941. protected _photoTexture: Texture;
  13942. /**
  13943. * Gets or sets the texture being displayed on the sphere
  13944. */
  13945. photoTexture: Texture;
  13946. /**
  13947. * Observable raised when an error occured while loading the 360 image
  13948. */
  13949. onLoadErrorObservable: Observable<string>;
  13950. /**
  13951. * The skybox material
  13952. */
  13953. protected _material: BackgroundMaterial;
  13954. /**
  13955. * The surface used for the skybox
  13956. */
  13957. protected _mesh: Mesh;
  13958. /**
  13959. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  13960. * Also see the options.resolution property.
  13961. */
  13962. fovMultiplier: number;
  13963. /**
  13964. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  13965. * @param name Element's name, child elements will append suffixes for their own names.
  13966. * @param urlsOfPhoto defines the url of the photo to display
  13967. * @param options defines an object containing optional or exposed sub element properties
  13968. * @param onError defines a callback called when an error occured while loading the texture
  13969. */
  13970. constructor(name: string, urlOfPhoto: string, options: {
  13971. resolution?: number;
  13972. size?: number;
  13973. useDirectMapping?: boolean;
  13974. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  13975. /**
  13976. * Releases resources associated with this node.
  13977. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  13978. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  13979. */
  13980. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  13981. }
  13982. }
  13983. declare module BABYLON {
  13984. interface Scene {
  13985. /**
  13986. * Creates a default light for the scene.
  13987. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  13988. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  13989. */
  13990. createDefaultLight(replace?: boolean): void;
  13991. /**
  13992. * Creates a default camera for the scene.
  13993. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  13994. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  13995. * @param replace has default false, when true replaces the active camera in the scene
  13996. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  13997. */
  13998. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  13999. /**
  14000. * Creates a default camera and a default light.
  14001. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  14002. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  14003. * @param replace has the default false, when true replaces the active camera/light in the scene
  14004. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  14005. */
  14006. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  14007. /**
  14008. * Creates a new sky box
  14009. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  14010. * @param environmentTexture defines the texture to use as environment texture
  14011. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  14012. * @param scale defines the overall scale of the skybox
  14013. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  14014. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  14015. * @returns a new mesh holding the sky box
  14016. */
  14017. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  14018. /**
  14019. * Creates a new environment
  14020. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  14021. * @param options defines the options you can use to configure the environment
  14022. * @returns the new EnvironmentHelper
  14023. */
  14024. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  14025. /**
  14026. * Creates a new VREXperienceHelper
  14027. * @see http://doc.babylonjs.com/how_to/webvr_helper
  14028. * @param webVROptions defines the options used to create the new VREXperienceHelper
  14029. * @returns a new VREXperienceHelper
  14030. */
  14031. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  14032. /**
  14033. * Creates a new XREXperienceHelper
  14034. * @see http://doc.babylonjs.com/how_to/webxr
  14035. * @returns a promise for a new XREXperienceHelper
  14036. */
  14037. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  14038. }
  14039. }
  14040. declare module BABYLON {
  14041. /**
  14042. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  14043. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  14044. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  14045. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  14046. */
  14047. class VideoDome extends TransformNode {
  14048. private _useDirectMapping;
  14049. /**
  14050. * The video texture being displayed on the sphere
  14051. */
  14052. protected _videoTexture: VideoTexture;
  14053. /**
  14054. * Gets the video texture being displayed on the sphere
  14055. */
  14056. readonly videoTexture: VideoTexture;
  14057. /**
  14058. * The skybox material
  14059. */
  14060. protected _material: BackgroundMaterial;
  14061. /**
  14062. * The surface used for the skybox
  14063. */
  14064. protected _mesh: Mesh;
  14065. /**
  14066. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  14067. * Also see the options.resolution property.
  14068. */
  14069. fovMultiplier: number;
  14070. /**
  14071. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  14072. * @param name Element's name, child elements will append suffixes for their own names.
  14073. * @param urlsOrVideo defines the url(s) or the video element to use
  14074. * @param options An object containing optional or exposed sub element properties
  14075. */
  14076. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  14077. resolution?: number;
  14078. clickToPlay?: boolean;
  14079. autoPlay?: boolean;
  14080. loop?: boolean;
  14081. size?: number;
  14082. poster?: string;
  14083. useDirectMapping?: boolean;
  14084. }, scene: Scene);
  14085. /**
  14086. * Releases resources associated with this node.
  14087. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14088. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14089. */
  14090. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14091. }
  14092. }
  14093. declare module BABYLON {
  14094. /**
  14095. * This class can be used to get instrumentation data from a Babylon engine
  14096. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  14097. */
  14098. class EngineInstrumentation implements IDisposable {
  14099. /**
  14100. * Define the instrumented engine.
  14101. */
  14102. engine: Engine;
  14103. private _captureGPUFrameTime;
  14104. private _gpuFrameTimeToken;
  14105. private _gpuFrameTime;
  14106. private _captureShaderCompilationTime;
  14107. private _shaderCompilationTime;
  14108. private _onBeginFrameObserver;
  14109. private _onEndFrameObserver;
  14110. private _onBeforeShaderCompilationObserver;
  14111. private _onAfterShaderCompilationObserver;
  14112. /**
  14113. * Gets the perf counter used for GPU frame time
  14114. */
  14115. readonly gpuFrameTimeCounter: PerfCounter;
  14116. /**
  14117. * Gets the GPU frame time capture status
  14118. */
  14119. /**
  14120. * Enable or disable the GPU frame time capture
  14121. */
  14122. captureGPUFrameTime: boolean;
  14123. /**
  14124. * Gets the perf counter used for shader compilation time
  14125. */
  14126. readonly shaderCompilationTimeCounter: PerfCounter;
  14127. /**
  14128. * Gets the shader compilation time capture status
  14129. */
  14130. /**
  14131. * Enable or disable the shader compilation time capture
  14132. */
  14133. captureShaderCompilationTime: boolean;
  14134. /**
  14135. * Instantiates a new engine instrumentation.
  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. * @param engine Defines the engine to instrument
  14139. */
  14140. constructor(
  14141. /**
  14142. * Define the instrumented engine.
  14143. */
  14144. engine: Engine);
  14145. /**
  14146. * Dispose and release associated resources.
  14147. */
  14148. dispose(): void;
  14149. }
  14150. }
  14151. declare module BABYLON {
  14152. /**
  14153. * This class can be used to get instrumentation data from a Babylon engine
  14154. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  14155. */
  14156. class SceneInstrumentation implements IDisposable {
  14157. /**
  14158. * Defines the scene to instrument
  14159. */
  14160. scene: Scene;
  14161. private _captureActiveMeshesEvaluationTime;
  14162. private _activeMeshesEvaluationTime;
  14163. private _captureRenderTargetsRenderTime;
  14164. private _renderTargetsRenderTime;
  14165. private _captureFrameTime;
  14166. private _frameTime;
  14167. private _captureRenderTime;
  14168. private _renderTime;
  14169. private _captureInterFrameTime;
  14170. private _interFrameTime;
  14171. private _captureParticlesRenderTime;
  14172. private _particlesRenderTime;
  14173. private _captureSpritesRenderTime;
  14174. private _spritesRenderTime;
  14175. private _capturePhysicsTime;
  14176. private _physicsTime;
  14177. private _captureAnimationsTime;
  14178. private _animationsTime;
  14179. private _captureCameraRenderTime;
  14180. private _cameraRenderTime;
  14181. private _onBeforeActiveMeshesEvaluationObserver;
  14182. private _onAfterActiveMeshesEvaluationObserver;
  14183. private _onBeforeRenderTargetsRenderObserver;
  14184. private _onAfterRenderTargetsRenderObserver;
  14185. private _onAfterRenderObserver;
  14186. private _onBeforeDrawPhaseObserver;
  14187. private _onAfterDrawPhaseObserver;
  14188. private _onBeforeAnimationsObserver;
  14189. private _onBeforeParticlesRenderingObserver;
  14190. private _onAfterParticlesRenderingObserver;
  14191. private _onBeforeSpritesRenderingObserver;
  14192. private _onAfterSpritesRenderingObserver;
  14193. private _onBeforePhysicsObserver;
  14194. private _onAfterPhysicsObserver;
  14195. private _onAfterAnimationsObserver;
  14196. private _onBeforeCameraRenderObserver;
  14197. private _onAfterCameraRenderObserver;
  14198. /**
  14199. * Gets the perf counter used for active meshes evaluation time
  14200. */
  14201. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  14202. /**
  14203. * Gets the active meshes evaluation time capture status
  14204. */
  14205. /**
  14206. * Enable or disable the active meshes evaluation time capture
  14207. */
  14208. captureActiveMeshesEvaluationTime: boolean;
  14209. /**
  14210. * Gets the perf counter used for render targets render time
  14211. */
  14212. readonly renderTargetsRenderTimeCounter: PerfCounter;
  14213. /**
  14214. * Gets the render targets render time capture status
  14215. */
  14216. /**
  14217. * Enable or disable the render targets render time capture
  14218. */
  14219. captureRenderTargetsRenderTime: boolean;
  14220. /**
  14221. * Gets the perf counter used for particles render time
  14222. */
  14223. readonly particlesRenderTimeCounter: PerfCounter;
  14224. /**
  14225. * Gets the particles render time capture status
  14226. */
  14227. /**
  14228. * Enable or disable the particles render time capture
  14229. */
  14230. captureParticlesRenderTime: boolean;
  14231. /**
  14232. * Gets the perf counter used for sprites render time
  14233. */
  14234. readonly spritesRenderTimeCounter: PerfCounter;
  14235. /**
  14236. * Gets the sprites render time capture status
  14237. */
  14238. /**
  14239. * Enable or disable the sprites render time capture
  14240. */
  14241. captureSpritesRenderTime: boolean;
  14242. /**
  14243. * Gets the perf counter used for physics time
  14244. */
  14245. readonly physicsTimeCounter: PerfCounter;
  14246. /**
  14247. * Gets the physics time capture status
  14248. */
  14249. /**
  14250. * Enable or disable the physics time capture
  14251. */
  14252. capturePhysicsTime: boolean;
  14253. /**
  14254. * Gets the perf counter used for animations time
  14255. */
  14256. readonly animationsTimeCounter: PerfCounter;
  14257. /**
  14258. * Gets the animations time capture status
  14259. */
  14260. /**
  14261. * Enable or disable the animations time capture
  14262. */
  14263. captureAnimationsTime: boolean;
  14264. /**
  14265. * Gets the perf counter used for frame time capture
  14266. */
  14267. readonly frameTimeCounter: PerfCounter;
  14268. /**
  14269. * Gets the frame time capture status
  14270. */
  14271. /**
  14272. * Enable or disable the frame time capture
  14273. */
  14274. captureFrameTime: boolean;
  14275. /**
  14276. * Gets the perf counter used for inter-frames time capture
  14277. */
  14278. readonly interFrameTimeCounter: PerfCounter;
  14279. /**
  14280. * Gets the inter-frames time capture status
  14281. */
  14282. /**
  14283. * Enable or disable the inter-frames time capture
  14284. */
  14285. captureInterFrameTime: boolean;
  14286. /**
  14287. * Gets the perf counter used for render time capture
  14288. */
  14289. readonly renderTimeCounter: PerfCounter;
  14290. /**
  14291. * Gets the render time capture status
  14292. */
  14293. /**
  14294. * Enable or disable the render time capture
  14295. */
  14296. captureRenderTime: boolean;
  14297. /**
  14298. * Gets the perf counter used for camera render time capture
  14299. */
  14300. readonly cameraRenderTimeCounter: PerfCounter;
  14301. /**
  14302. * Gets the camera render time capture status
  14303. */
  14304. /**
  14305. * Enable or disable the camera render time capture
  14306. */
  14307. captureCameraRenderTime: boolean;
  14308. /**
  14309. * Gets the perf counter used for draw calls
  14310. */
  14311. readonly drawCallsCounter: PerfCounter;
  14312. /**
  14313. * Gets the perf counter used for texture collisions
  14314. */
  14315. readonly textureCollisionsCounter: PerfCounter;
  14316. /**
  14317. * Instantiates a new scene instrumentation.
  14318. * This class can be used to get instrumentation data from a Babylon engine
  14319. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  14320. * @param scene Defines the scene to instrument
  14321. */
  14322. constructor(
  14323. /**
  14324. * Defines the scene to instrument
  14325. */
  14326. scene: Scene);
  14327. /**
  14328. * Dispose and release associated resources.
  14329. */
  14330. dispose(): void;
  14331. }
  14332. }
  14333. declare module BABYLON {
  14334. /**
  14335. * @hidden
  14336. **/
  14337. class _TimeToken {
  14338. _startTimeQuery: Nullable<WebGLQuery>;
  14339. _endTimeQuery: Nullable<WebGLQuery>;
  14340. _timeElapsedQuery: Nullable<WebGLQuery>;
  14341. _timeElapsedQueryEnded: boolean;
  14342. }
  14343. }
  14344. declare module BABYLON {
  14345. /**
  14346. * Effect layer options. This helps customizing the behaviour
  14347. * of the effect layer.
  14348. */
  14349. interface IEffectLayerOptions {
  14350. /**
  14351. * Multiplication factor apply to the canvas size to compute the render target size
  14352. * used to generated the objects (the smaller the faster).
  14353. */
  14354. mainTextureRatio: number;
  14355. /**
  14356. * Enforces a fixed size texture to ensure effect stability across devices.
  14357. */
  14358. mainTextureFixedSize?: number;
  14359. /**
  14360. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  14361. */
  14362. alphaBlendingMode: number;
  14363. /**
  14364. * The camera attached to the layer.
  14365. */
  14366. camera: Nullable<Camera>;
  14367. /**
  14368. * The rendering group to draw the layer in.
  14369. */
  14370. renderingGroupId: number;
  14371. }
  14372. /**
  14373. * The effect layer Helps adding post process effect blended with the main pass.
  14374. *
  14375. * This can be for instance use to generate glow or higlight effects on the scene.
  14376. *
  14377. * The effect layer class can not be used directly and is intented to inherited from to be
  14378. * customized per effects.
  14379. */
  14380. abstract class EffectLayer {
  14381. private _vertexBuffers;
  14382. private _indexBuffer;
  14383. private _cachedDefines;
  14384. private _effectLayerMapGenerationEffect;
  14385. private _effectLayerOptions;
  14386. private _mergeEffect;
  14387. protected _scene: Scene;
  14388. protected _engine: Engine;
  14389. protected _maxSize: number;
  14390. protected _mainTextureDesiredSize: ISize;
  14391. protected _mainTexture: RenderTargetTexture;
  14392. protected _shouldRender: boolean;
  14393. protected _postProcesses: PostProcess[];
  14394. protected _textures: BaseTexture[];
  14395. protected _emissiveTextureAndColor: {
  14396. texture: Nullable<BaseTexture>;
  14397. color: Color4;
  14398. };
  14399. /**
  14400. * The name of the layer
  14401. */
  14402. name: string;
  14403. /**
  14404. * The clear color of the texture used to generate the glow map.
  14405. */
  14406. neutralColor: Color4;
  14407. /**
  14408. * Specifies wether the highlight layer is enabled or not.
  14409. */
  14410. isEnabled: boolean;
  14411. /**
  14412. * Gets the camera attached to the layer.
  14413. */
  14414. readonly camera: Nullable<Camera>;
  14415. /**
  14416. * Gets the rendering group id the layer should render in.
  14417. */
  14418. readonly renderingGroupId: number;
  14419. /**
  14420. * An event triggered when the effect layer has been disposed.
  14421. */
  14422. onDisposeObservable: Observable<EffectLayer>;
  14423. /**
  14424. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  14425. */
  14426. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  14427. /**
  14428. * An event triggered when the generated texture is being merged in the scene.
  14429. */
  14430. onBeforeComposeObservable: Observable<EffectLayer>;
  14431. /**
  14432. * An event triggered when the generated texture has been merged in the scene.
  14433. */
  14434. onAfterComposeObservable: Observable<EffectLayer>;
  14435. /**
  14436. * An event triggered when the efffect layer changes its size.
  14437. */
  14438. onSizeChangedObservable: Observable<EffectLayer>;
  14439. /**
  14440. * Instantiates a new effect Layer and references it in the scene.
  14441. * @param name The name of the layer
  14442. * @param scene The scene to use the layer in
  14443. */
  14444. constructor(
  14445. /** The Friendly of the effect in the scene */
  14446. name: string, scene: Scene);
  14447. /**
  14448. * Get the effect name of the layer.
  14449. * @return The effect name
  14450. */
  14451. abstract getEffectName(): string;
  14452. /**
  14453. * Checks for the readiness of the element composing the layer.
  14454. * @param subMesh the mesh to check for
  14455. * @param useInstances specify wether or not to use instances to render the mesh
  14456. * @return true if ready otherwise, false
  14457. */
  14458. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  14459. /**
  14460. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  14461. * @returns true if the effect requires stencil during the main canvas render pass.
  14462. */
  14463. abstract needStencil(): boolean;
  14464. /**
  14465. * Create the merge effect. This is the shader use to blit the information back
  14466. * to the main canvas at the end of the scene rendering.
  14467. * @returns The effect containing the shader used to merge the effect on the main canvas
  14468. */
  14469. protected abstract _createMergeEffect(): Effect;
  14470. /**
  14471. * Creates the render target textures and post processes used in the effect layer.
  14472. */
  14473. protected abstract _createTextureAndPostProcesses(): void;
  14474. /**
  14475. * Implementation specific of rendering the generating effect on the main canvas.
  14476. * @param effect The effect used to render through
  14477. */
  14478. protected abstract _internalRender(effect: Effect): void;
  14479. /**
  14480. * Sets the required values for both the emissive texture and and the main color.
  14481. */
  14482. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  14483. /**
  14484. * Free any resources and references associated to a mesh.
  14485. * Internal use
  14486. * @param mesh The mesh to free.
  14487. */
  14488. abstract _disposeMesh(mesh: Mesh): void;
  14489. /**
  14490. * Serializes this layer (Glow or Highlight for example)
  14491. * @returns a serialized layer object
  14492. */
  14493. abstract serialize?(): any;
  14494. /**
  14495. * Initializes the effect layer with the required options.
  14496. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  14497. */
  14498. protected _init(options: Partial<IEffectLayerOptions>): void;
  14499. /**
  14500. * Generates the index buffer of the full screen quad blending to the main canvas.
  14501. */
  14502. private _generateIndexBuffer;
  14503. /**
  14504. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  14505. */
  14506. private _genrateVertexBuffer;
  14507. /**
  14508. * Sets the main texture desired size which is the closest power of two
  14509. * of the engine canvas size.
  14510. */
  14511. private _setMainTextureSize;
  14512. /**
  14513. * Creates the main texture for the effect layer.
  14514. */
  14515. protected _createMainTexture(): void;
  14516. /**
  14517. * Checks for the readiness of the element composing the layer.
  14518. * @param subMesh the mesh to check for
  14519. * @param useInstances specify wether or not to use instances to render the mesh
  14520. * @param emissiveTexture the associated emissive texture used to generate the glow
  14521. * @return true if ready otherwise, false
  14522. */
  14523. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  14524. /**
  14525. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  14526. */
  14527. render(): void;
  14528. /**
  14529. * Determine if a given mesh will be used in the current effect.
  14530. * @param mesh mesh to test
  14531. * @returns true if the mesh will be used
  14532. */
  14533. hasMesh(mesh: AbstractMesh): boolean;
  14534. /**
  14535. * Returns true if the layer contains information to display, otherwise false.
  14536. * @returns true if the glow layer should be rendered
  14537. */
  14538. shouldRender(): boolean;
  14539. /**
  14540. * Returns true if the mesh should render, otherwise false.
  14541. * @param mesh The mesh to render
  14542. * @returns true if it should render otherwise false
  14543. */
  14544. protected _shouldRenderMesh(mesh: Mesh): boolean;
  14545. /**
  14546. * Returns true if the mesh should render, otherwise false.
  14547. * @param mesh The mesh to render
  14548. * @returns true if it should render otherwise false
  14549. */
  14550. protected _shouldRenderEmissiveTextureForMesh(mesh: Mesh): boolean;
  14551. /**
  14552. * Renders the submesh passed in parameter to the generation map.
  14553. */
  14554. protected _renderSubMesh(subMesh: SubMesh): void;
  14555. /**
  14556. * Rebuild the required buffers.
  14557. * @hidden Internal use only.
  14558. */
  14559. _rebuild(): void;
  14560. /**
  14561. * Dispose only the render target textures and post process.
  14562. */
  14563. private _disposeTextureAndPostProcesses;
  14564. /**
  14565. * Dispose the highlight layer and free resources.
  14566. */
  14567. dispose(): void;
  14568. /**
  14569. * Gets the class name of the effect layer
  14570. * @returns the string with the class name of the effect layer
  14571. */
  14572. getClassName(): string;
  14573. /**
  14574. * Creates an effect layer from parsed effect layer data
  14575. * @param parsedEffectLayer defines effect layer data
  14576. * @param scene defines the current scene
  14577. * @param rootUrl defines the root URL containing the effect layer information
  14578. * @returns a parsed effect Layer
  14579. */
  14580. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  14581. }
  14582. }
  14583. declare module BABYLON {
  14584. interface AbstractScene {
  14585. /**
  14586. * The list of effect layers (highlights/glow) added to the scene
  14587. * @see http://doc.babylonjs.com/how_to/highlight_layer
  14588. * @see http://doc.babylonjs.com/how_to/glow_layer
  14589. */
  14590. effectLayers: Array<EffectLayer>;
  14591. /**
  14592. * Removes the given effect layer from this scene.
  14593. * @param toRemove defines the effect layer to remove
  14594. * @returns the index of the removed effect layer
  14595. */
  14596. removeEffectLayer(toRemove: EffectLayer): number;
  14597. /**
  14598. * Adds the given effect layer to this scene
  14599. * @param newEffectLayer defines the effect layer to add
  14600. */
  14601. addEffectLayer(newEffectLayer: EffectLayer): void;
  14602. }
  14603. /**
  14604. * Defines the layer scene component responsible to manage any effect layers
  14605. * in a given scene.
  14606. */
  14607. class EffectLayerSceneComponent implements ISceneSerializableComponent {
  14608. /**
  14609. * The component name helpfull to identify the component in the list of scene components.
  14610. */
  14611. readonly name: string;
  14612. /**
  14613. * The scene the component belongs to.
  14614. */
  14615. scene: Scene;
  14616. private _engine;
  14617. private _renderEffects;
  14618. private _needStencil;
  14619. private _previousStencilState;
  14620. /**
  14621. * Creates a new instance of the component for the given scene
  14622. * @param scene Defines the scene to register the component in
  14623. */
  14624. constructor(scene: Scene);
  14625. /**
  14626. * Registers the component in a given scene
  14627. */
  14628. register(): void;
  14629. /**
  14630. * Rebuilds the elements related to this component in case of
  14631. * context lost for instance.
  14632. */
  14633. rebuild(): void;
  14634. /**
  14635. * Serializes the component data to the specified json object
  14636. * @param serializationObject The object to serialize to
  14637. */
  14638. serialize(serializationObject: any): void;
  14639. /**
  14640. * Adds all the element from the container to the scene
  14641. * @param container the container holding the elements
  14642. */
  14643. addFromContainer(container: AbstractScene): void;
  14644. /**
  14645. * Removes all the elements in the container from the scene
  14646. * @param container contains the elements to remove
  14647. */
  14648. removeFromContainer(container: AbstractScene): void;
  14649. /**
  14650. * Disposes the component and the associated ressources.
  14651. */
  14652. dispose(): void;
  14653. private _isReadyForMesh;
  14654. private _renderMainTexture;
  14655. private _setStencil;
  14656. private _setStencilBack;
  14657. private _draw;
  14658. private _drawCamera;
  14659. private _drawRenderingGroup;
  14660. }
  14661. }
  14662. declare module BABYLON {
  14663. interface AbstractScene {
  14664. /**
  14665. * Return a the first highlight layer of the scene with a given name.
  14666. * @param name The name of the highlight layer to look for.
  14667. * @return The highlight layer if found otherwise null.
  14668. */
  14669. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  14670. }
  14671. /**
  14672. * Glow layer options. This helps customizing the behaviour
  14673. * of the glow layer.
  14674. */
  14675. interface IGlowLayerOptions {
  14676. /**
  14677. * Multiplication factor apply to the canvas size to compute the render target size
  14678. * used to generated the glowing objects (the smaller the faster).
  14679. */
  14680. mainTextureRatio: number;
  14681. /**
  14682. * Enforces a fixed size texture to ensure resize independant blur.
  14683. */
  14684. mainTextureFixedSize?: number;
  14685. /**
  14686. * How big is the kernel of the blur texture.
  14687. */
  14688. blurKernelSize: number;
  14689. /**
  14690. * The camera attached to the layer.
  14691. */
  14692. camera: Nullable<Camera>;
  14693. /**
  14694. * Enable MSAA by chosing the number of samples.
  14695. */
  14696. mainTextureSamples?: number;
  14697. /**
  14698. * The rendering group to draw the layer in.
  14699. */
  14700. renderingGroupId: number;
  14701. }
  14702. /**
  14703. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  14704. *
  14705. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  14706. * glowy meshes to your scene.
  14707. *
  14708. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  14709. */
  14710. class GlowLayer extends EffectLayer {
  14711. /**
  14712. * Effect Name of the layer.
  14713. */
  14714. static readonly EffectName: string;
  14715. /**
  14716. * The default blur kernel size used for the glow.
  14717. */
  14718. static DefaultBlurKernelSize: number;
  14719. /**
  14720. * The default texture size ratio used for the glow.
  14721. */
  14722. static DefaultTextureRatio: number;
  14723. /**
  14724. * Sets the kernel size of the blur.
  14725. */
  14726. /**
  14727. * Gets the kernel size of the blur.
  14728. */
  14729. blurKernelSize: number;
  14730. /**
  14731. * Sets the glow intensity.
  14732. */
  14733. /**
  14734. * Gets the glow intensity.
  14735. */
  14736. intensity: number;
  14737. private _options;
  14738. private _intensity;
  14739. private _horizontalBlurPostprocess1;
  14740. private _verticalBlurPostprocess1;
  14741. private _horizontalBlurPostprocess2;
  14742. private _verticalBlurPostprocess2;
  14743. private _blurTexture1;
  14744. private _blurTexture2;
  14745. private _postProcesses1;
  14746. private _postProcesses2;
  14747. private _includedOnlyMeshes;
  14748. private _excludedMeshes;
  14749. /**
  14750. * Callback used to let the user override the color selection on a per mesh basis
  14751. */
  14752. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  14753. /**
  14754. * Callback used to let the user override the texture selection on a per mesh basis
  14755. */
  14756. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  14757. /**
  14758. * Instantiates a new glow Layer and references it to the scene.
  14759. * @param name The name of the layer
  14760. * @param scene The scene to use the layer in
  14761. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  14762. */
  14763. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  14764. /**
  14765. * Get the effect name of the layer.
  14766. * @return The effect name
  14767. */
  14768. getEffectName(): string;
  14769. /**
  14770. * Create the merge effect. This is the shader use to blit the information back
  14771. * to the main canvas at the end of the scene rendering.
  14772. */
  14773. protected _createMergeEffect(): Effect;
  14774. /**
  14775. * Creates the render target textures and post processes used in the glow layer.
  14776. */
  14777. protected _createTextureAndPostProcesses(): void;
  14778. /**
  14779. * Checks for the readiness of the element composing the layer.
  14780. * @param subMesh the mesh to check for
  14781. * @param useInstances specify wether or not to use instances to render the mesh
  14782. * @param emissiveTexture the associated emissive texture used to generate the glow
  14783. * @return true if ready otherwise, false
  14784. */
  14785. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  14786. /**
  14787. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  14788. */
  14789. needStencil(): boolean;
  14790. /**
  14791. * Implementation specific of rendering the generating effect on the main canvas.
  14792. * @param effect The effect used to render through
  14793. */
  14794. protected _internalRender(effect: Effect): void;
  14795. /**
  14796. * Sets the required values for both the emissive texture and and the main color.
  14797. */
  14798. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  14799. /**
  14800. * Returns true if the mesh should render, otherwise false.
  14801. * @param mesh The mesh to render
  14802. * @returns true if it should render otherwise false
  14803. */
  14804. protected _shouldRenderMesh(mesh: Mesh): boolean;
  14805. /**
  14806. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  14807. * @param mesh The mesh to exclude from the glow layer
  14808. */
  14809. addExcludedMesh(mesh: Mesh): void;
  14810. /**
  14811. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  14812. * @param mesh The mesh to remove
  14813. */
  14814. removeExcludedMesh(mesh: Mesh): void;
  14815. /**
  14816. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  14817. * @param mesh The mesh to include in the glow layer
  14818. */
  14819. addIncludedOnlyMesh(mesh: Mesh): void;
  14820. /**
  14821. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  14822. * @param mesh The mesh to remove
  14823. */
  14824. removeIncludedOnlyMesh(mesh: Mesh): void;
  14825. /**
  14826. * Determine if a given mesh will be used in the glow layer
  14827. * @param mesh The mesh to test
  14828. * @returns true if the mesh will be highlighted by the current glow layer
  14829. */
  14830. hasMesh(mesh: AbstractMesh): boolean;
  14831. /**
  14832. * Free any resources and references associated to a mesh.
  14833. * Internal use
  14834. * @param mesh The mesh to free.
  14835. * @hidden
  14836. */
  14837. _disposeMesh(mesh: Mesh): void;
  14838. /**
  14839. * Gets the class name of the effect layer
  14840. * @returns the string with the class name of the effect layer
  14841. */
  14842. getClassName(): string;
  14843. /**
  14844. * Serializes this glow layer
  14845. * @returns a serialized glow layer object
  14846. */
  14847. serialize(): any;
  14848. /**
  14849. * Creates a Glow Layer from parsed glow layer data
  14850. * @param parsedGlowLayer defines glow layer data
  14851. * @param scene defines the current scene
  14852. * @param rootUrl defines the root URL containing the glow layer information
  14853. * @returns a parsed Glow Layer
  14854. */
  14855. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  14856. }
  14857. }
  14858. declare module BABYLON {
  14859. interface AbstractScene {
  14860. /**
  14861. * Return a the first highlight layer of the scene with a given name.
  14862. * @param name The name of the highlight layer to look for.
  14863. * @return The highlight layer if found otherwise null.
  14864. */
  14865. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  14866. }
  14867. /**
  14868. * Highlight layer options. This helps customizing the behaviour
  14869. * of the highlight layer.
  14870. */
  14871. interface IHighlightLayerOptions {
  14872. /**
  14873. * Multiplication factor apply to the canvas size to compute the render target size
  14874. * used to generated the glowing objects (the smaller the faster).
  14875. */
  14876. mainTextureRatio: number;
  14877. /**
  14878. * Enforces a fixed size texture to ensure resize independant blur.
  14879. */
  14880. mainTextureFixedSize?: number;
  14881. /**
  14882. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  14883. * of the picture to blur (the smaller the faster).
  14884. */
  14885. blurTextureSizeRatio: number;
  14886. /**
  14887. * How big in texel of the blur texture is the vertical blur.
  14888. */
  14889. blurVerticalSize: number;
  14890. /**
  14891. * How big in texel of the blur texture is the horizontal blur.
  14892. */
  14893. blurHorizontalSize: number;
  14894. /**
  14895. * Alpha blending mode used to apply the blur. Default is combine.
  14896. */
  14897. alphaBlendingMode: number;
  14898. /**
  14899. * The camera attached to the layer.
  14900. */
  14901. camera: Nullable<Camera>;
  14902. /**
  14903. * Should we display highlight as a solid stroke?
  14904. */
  14905. isStroke?: boolean;
  14906. /**
  14907. * The rendering group to draw the layer in.
  14908. */
  14909. renderingGroupId: number;
  14910. }
  14911. /**
  14912. * The highlight layer Helps adding a glow effect around a mesh.
  14913. *
  14914. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  14915. * glowy meshes to your scene.
  14916. *
  14917. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  14918. */
  14919. class HighlightLayer extends EffectLayer {
  14920. name: string;
  14921. /**
  14922. * Effect Name of the highlight layer.
  14923. */
  14924. static readonly EffectName: string;
  14925. /**
  14926. * The neutral color used during the preparation of the glow effect.
  14927. * This is black by default as the blend operation is a blend operation.
  14928. */
  14929. static NeutralColor: Color4;
  14930. /**
  14931. * Stencil value used for glowing meshes.
  14932. */
  14933. static GlowingMeshStencilReference: number;
  14934. /**
  14935. * Stencil value used for the other meshes in the scene.
  14936. */
  14937. static NormalMeshStencilReference: number;
  14938. /**
  14939. * Specifies whether or not the inner glow is ACTIVE in the layer.
  14940. */
  14941. innerGlow: boolean;
  14942. /**
  14943. * Specifies whether or not the outer glow is ACTIVE in the layer.
  14944. */
  14945. outerGlow: boolean;
  14946. /**
  14947. * Specifies the horizontal size of the blur.
  14948. */
  14949. /**
  14950. * Gets the horizontal size of the blur.
  14951. */
  14952. blurHorizontalSize: number;
  14953. /**
  14954. * Specifies the vertical size of the blur.
  14955. */
  14956. /**
  14957. * Gets the vertical size of the blur.
  14958. */
  14959. blurVerticalSize: number;
  14960. /**
  14961. * An event triggered when the highlight layer is being blurred.
  14962. */
  14963. onBeforeBlurObservable: Observable<HighlightLayer>;
  14964. /**
  14965. * An event triggered when the highlight layer has been blurred.
  14966. */
  14967. onAfterBlurObservable: Observable<HighlightLayer>;
  14968. private _instanceGlowingMeshStencilReference;
  14969. private _options;
  14970. private _downSamplePostprocess;
  14971. private _horizontalBlurPostprocess;
  14972. private _verticalBlurPostprocess;
  14973. private _blurTexture;
  14974. private _meshes;
  14975. private _excludedMeshes;
  14976. /**
  14977. * Instantiates a new highlight Layer and references it to the scene..
  14978. * @param name The name of the layer
  14979. * @param scene The scene to use the layer in
  14980. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  14981. */
  14982. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  14983. /**
  14984. * Get the effect name of the layer.
  14985. * @return The effect name
  14986. */
  14987. getEffectName(): string;
  14988. /**
  14989. * Create the merge effect. This is the shader use to blit the information back
  14990. * to the main canvas at the end of the scene rendering.
  14991. */
  14992. protected _createMergeEffect(): Effect;
  14993. /**
  14994. * Creates the render target textures and post processes used in the highlight layer.
  14995. */
  14996. protected _createTextureAndPostProcesses(): void;
  14997. /**
  14998. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  14999. */
  15000. needStencil(): boolean;
  15001. /**
  15002. * Checks for the readiness of the element composing the layer.
  15003. * @param subMesh the mesh to check for
  15004. * @param useInstances specify wether or not to use instances to render the mesh
  15005. * @param emissiveTexture the associated emissive texture used to generate the glow
  15006. * @return true if ready otherwise, false
  15007. */
  15008. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  15009. /**
  15010. * Implementation specific of rendering the generating effect on the main canvas.
  15011. * @param effect The effect used to render through
  15012. */
  15013. protected _internalRender(effect: Effect): void;
  15014. /**
  15015. * Returns true if the layer contains information to display, otherwise false.
  15016. */
  15017. shouldRender(): boolean;
  15018. /**
  15019. * Returns true if the mesh should render, otherwise false.
  15020. * @param mesh The mesh to render
  15021. * @returns true if it should render otherwise false
  15022. */
  15023. protected _shouldRenderMesh(mesh: Mesh): boolean;
  15024. /**
  15025. * Sets the required values for both the emissive texture and and the main color.
  15026. */
  15027. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  15028. /**
  15029. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  15030. * @param mesh The mesh to exclude from the highlight layer
  15031. */
  15032. addExcludedMesh(mesh: Mesh): void;
  15033. /**
  15034. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  15035. * @param mesh The mesh to highlight
  15036. */
  15037. removeExcludedMesh(mesh: Mesh): void;
  15038. /**
  15039. * Determine if a given mesh will be highlighted by the current HighlightLayer
  15040. * @param mesh mesh to test
  15041. * @returns true if the mesh will be highlighted by the current HighlightLayer
  15042. */
  15043. hasMesh(mesh: AbstractMesh): boolean;
  15044. /**
  15045. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  15046. * @param mesh The mesh to highlight
  15047. * @param color The color of the highlight
  15048. * @param glowEmissiveOnly Extract the glow from the emissive texture
  15049. */
  15050. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  15051. /**
  15052. * Remove a mesh from the highlight layer in order to make it stop glowing.
  15053. * @param mesh The mesh to highlight
  15054. */
  15055. removeMesh(mesh: Mesh): void;
  15056. /**
  15057. * Force the stencil to the normal expected value for none glowing parts
  15058. */
  15059. private _defaultStencilReference;
  15060. /**
  15061. * Free any resources and references associated to a mesh.
  15062. * Internal use
  15063. * @param mesh The mesh to free.
  15064. * @hidden
  15065. */
  15066. _disposeMesh(mesh: Mesh): void;
  15067. /**
  15068. * Dispose the highlight layer and free resources.
  15069. */
  15070. dispose(): void;
  15071. /**
  15072. * Gets the class name of the effect layer
  15073. * @returns the string with the class name of the effect layer
  15074. */
  15075. getClassName(): string;
  15076. /**
  15077. * Serializes this Highlight layer
  15078. * @returns a serialized Highlight layer object
  15079. */
  15080. serialize(): any;
  15081. /**
  15082. * Creates a Highlight layer from parsed Highlight layer data
  15083. * @param parsedHightlightLayer defines the Highlight layer data
  15084. * @param scene defines the current scene
  15085. * @param rootUrl defines the root URL containing the Highlight layer information
  15086. * @returns a parsed Highlight layer
  15087. */
  15088. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  15089. }
  15090. }
  15091. declare module BABYLON {
  15092. /**
  15093. * This represents a full screen 2d layer.
  15094. * This can be useful to display a picture in the background of your scene for instance.
  15095. * @see https://www.babylonjs-playground.com/#08A2BS#1
  15096. */
  15097. class Layer {
  15098. /**
  15099. * Define the name of the layer.
  15100. */
  15101. name: string;
  15102. /**
  15103. * Define the texture the layer should display.
  15104. */
  15105. texture: Nullable<Texture>;
  15106. /**
  15107. * Is the layer in background or foreground.
  15108. */
  15109. isBackground: boolean;
  15110. /**
  15111. * Define the color of the layer (instead of texture).
  15112. */
  15113. color: Color4;
  15114. /**
  15115. * Define the scale of the layer in order to zoom in out of the texture.
  15116. */
  15117. scale: Vector2;
  15118. /**
  15119. * Define an offset for the layer in order to shift the texture.
  15120. */
  15121. offset: Vector2;
  15122. /**
  15123. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  15124. */
  15125. alphaBlendingMode: number;
  15126. /**
  15127. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  15128. * Alpha test will not mix with the background color in case of transparency.
  15129. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  15130. */
  15131. alphaTest: boolean;
  15132. /**
  15133. * Define a mask to restrict the layer to only some of the scene cameras.
  15134. */
  15135. layerMask: number;
  15136. /**
  15137. * Define the list of render target the layer is visible into.
  15138. */
  15139. renderTargetTextures: RenderTargetTexture[];
  15140. /**
  15141. * Define if the layer is only used in renderTarget or if it also
  15142. * renders in the main frame buffer of the canvas.
  15143. */
  15144. renderOnlyInRenderTargetTextures: boolean;
  15145. private _scene;
  15146. private _vertexBuffers;
  15147. private _indexBuffer;
  15148. private _effect;
  15149. private _alphaTestEffect;
  15150. /**
  15151. * An event triggered when the layer is disposed.
  15152. */
  15153. onDisposeObservable: Observable<Layer>;
  15154. private _onDisposeObserver;
  15155. /**
  15156. * Back compatibility with callback before the onDisposeObservable existed.
  15157. * The set callback will be triggered when the layer has been disposed.
  15158. */
  15159. onDispose: () => void;
  15160. /**
  15161. * An event triggered before rendering the scene
  15162. */
  15163. onBeforeRenderObservable: Observable<Layer>;
  15164. private _onBeforeRenderObserver;
  15165. /**
  15166. * Back compatibility with callback before the onBeforeRenderObservable existed.
  15167. * The set callback will be triggered just before rendering the layer.
  15168. */
  15169. onBeforeRender: () => void;
  15170. /**
  15171. * An event triggered after rendering the scene
  15172. */
  15173. onAfterRenderObservable: Observable<Layer>;
  15174. private _onAfterRenderObserver;
  15175. /**
  15176. * Back compatibility with callback before the onAfterRenderObservable existed.
  15177. * The set callback will be triggered just after rendering the layer.
  15178. */
  15179. onAfterRender: () => void;
  15180. /**
  15181. * Instantiates a new layer.
  15182. * This represents a full screen 2d layer.
  15183. * This can be useful to display a picture in the background of your scene for instance.
  15184. * @see https://www.babylonjs-playground.com/#08A2BS#1
  15185. * @param name Define the name of the layer in the scene
  15186. * @param imgUrl Define the url of the texture to display in the layer
  15187. * @param scene Define the scene the layer belongs to
  15188. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  15189. * @param color Defines a color for the layer
  15190. */
  15191. constructor(
  15192. /**
  15193. * Define the name of the layer.
  15194. */
  15195. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  15196. private _createIndexBuffer;
  15197. /** @hidden */
  15198. _rebuild(): void;
  15199. /**
  15200. * Renders the layer in the scene.
  15201. */
  15202. render(): void;
  15203. /**
  15204. * Disposes and releases the associated ressources.
  15205. */
  15206. dispose(): void;
  15207. }
  15208. }
  15209. declare module BABYLON {
  15210. interface AbstractScene {
  15211. /**
  15212. * The list of layers (background and foreground) of the scene
  15213. */
  15214. layers: Array<Layer>;
  15215. }
  15216. /**
  15217. * Defines the layer scene component responsible to manage any layers
  15218. * in a given scene.
  15219. */
  15220. class LayerSceneComponent implements ISceneComponent {
  15221. /**
  15222. * The component name helpfull to identify the component in the list of scene components.
  15223. */
  15224. readonly name: string;
  15225. /**
  15226. * The scene the component belongs to.
  15227. */
  15228. scene: Scene;
  15229. private _engine;
  15230. /**
  15231. * Creates a new instance of the component for the given scene
  15232. * @param scene Defines the scene to register the component in
  15233. */
  15234. constructor(scene: Scene);
  15235. /**
  15236. * Registers the component in a given scene
  15237. */
  15238. register(): void;
  15239. /**
  15240. * Rebuilds the elements related to this component in case of
  15241. * context lost for instance.
  15242. */
  15243. rebuild(): void;
  15244. /**
  15245. * Disposes the component and the associated ressources.
  15246. */
  15247. dispose(): void;
  15248. private _draw;
  15249. private _drawCameraPredicate;
  15250. private _drawCameraBackground;
  15251. private _drawCameraForeground;
  15252. private _drawRenderTargetPredicate;
  15253. private _drawRenderTargetBackground;
  15254. private _drawRenderTargetForeground;
  15255. }
  15256. }
  15257. declare module BABYLON {
  15258. /**
  15259. * This represents one of the lens effect in a `BABYLON.lensFlareSystem`.
  15260. * It controls one of the indiviual texture used in the effect.
  15261. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15262. */
  15263. class LensFlare {
  15264. /**
  15265. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  15266. */
  15267. size: number;
  15268. /**
  15269. * 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.
  15270. */
  15271. position: number;
  15272. /**
  15273. * Define the lens color.
  15274. */
  15275. color: Color3;
  15276. /**
  15277. * Define the lens texture.
  15278. */
  15279. texture: Nullable<Texture>;
  15280. /**
  15281. * Define the alpha mode to render this particular lens.
  15282. */
  15283. alphaMode: number;
  15284. private _system;
  15285. /**
  15286. * Creates a new Lens Flare.
  15287. * This represents one of the lens effect in a `BABYLON.lensFlareSystem`.
  15288. * It controls one of the indiviual texture used in the effect.
  15289. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15290. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  15291. * @param position Define the position of the lens flare in the system. (a floating value between -1 and 1). A value of 0 is located on the emitter. A value greater than 0 is beyond the emitter and a value lesser than 0 is behind.
  15292. * @param color Define the lens color
  15293. * @param imgUrl Define the lens texture url
  15294. * @param system Define the `lensFlareSystem` this flare is part of
  15295. * @returns The newly created Lens Flare
  15296. */
  15297. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  15298. /**
  15299. * Instantiates a new Lens Flare.
  15300. * This represents one of the lens effect in a `BABYLON.lensFlareSystem`.
  15301. * It controls one of the indiviual texture used in the effect.
  15302. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15303. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  15304. * @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.
  15305. * @param color Define the lens color
  15306. * @param imgUrl Define the lens texture url
  15307. * @param system Define the `lensFlareSystem` this flare is part of
  15308. */
  15309. constructor(
  15310. /**
  15311. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  15312. */
  15313. size: number,
  15314. /**
  15315. * 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.
  15316. */
  15317. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  15318. /**
  15319. * Dispose and release the lens flare with its associated resources.
  15320. */
  15321. dispose(): void;
  15322. }
  15323. }
  15324. declare module BABYLON {
  15325. /**
  15326. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  15327. * It is usually composed of several `BABYLON.lensFlare`.
  15328. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15329. */
  15330. class LensFlareSystem {
  15331. /**
  15332. * Define the name of the lens flare system
  15333. */
  15334. name: string;
  15335. /**
  15336. * List of lens flares used in this system.
  15337. */
  15338. lensFlares: LensFlare[];
  15339. /**
  15340. * Define a limit from the border the lens flare can be visible.
  15341. */
  15342. borderLimit: number;
  15343. /**
  15344. * Define a viewport border we do not want to see the lens flare in.
  15345. */
  15346. viewportBorder: number;
  15347. /**
  15348. * Define a predicate which could limit the list of meshes able to occlude the effect.
  15349. */
  15350. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  15351. /**
  15352. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  15353. */
  15354. layerMask: number;
  15355. /**
  15356. * Define the id of the lens flare system in the scene.
  15357. * (equal to name by default)
  15358. */
  15359. id: string;
  15360. private _scene;
  15361. private _emitter;
  15362. private _vertexBuffers;
  15363. private _indexBuffer;
  15364. private _effect;
  15365. private _positionX;
  15366. private _positionY;
  15367. private _isEnabled;
  15368. /**
  15369. * Instantiates a lens flare system.
  15370. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  15371. * It is usually composed of several `BABYLON.lensFlare`.
  15372. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15373. * @param name Define the name of the lens flare system in the scene
  15374. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  15375. * @param scene Define the scene the lens flare system belongs to
  15376. */
  15377. constructor(
  15378. /**
  15379. * Define the name of the lens flare system
  15380. */
  15381. name: string, emitter: any, scene: Scene);
  15382. /**
  15383. * Define if the lens flare system is enabled.
  15384. */
  15385. isEnabled: boolean;
  15386. /**
  15387. * Get the scene the effects belongs to.
  15388. * @returns the scene holding the lens flare system
  15389. */
  15390. getScene(): Scene;
  15391. /**
  15392. * Get the emitter of the lens flare system.
  15393. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  15394. * @returns the emitter of the lens flare system
  15395. */
  15396. getEmitter(): any;
  15397. /**
  15398. * Set the emitter of the lens flare system.
  15399. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  15400. * @param newEmitter Define the new emitter of the system
  15401. */
  15402. setEmitter(newEmitter: any): void;
  15403. /**
  15404. * Get the lens flare system emitter position.
  15405. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  15406. * @returns the position
  15407. */
  15408. getEmitterPosition(): Vector3;
  15409. /**
  15410. * @hidden
  15411. */
  15412. computeEffectivePosition(globalViewport: Viewport): boolean;
  15413. /** @hidden */
  15414. _isVisible(): boolean;
  15415. /**
  15416. * @hidden
  15417. */
  15418. render(): boolean;
  15419. /**
  15420. * Dispose and release the lens flare with its associated resources.
  15421. */
  15422. dispose(): void;
  15423. /**
  15424. * Parse a lens flare system from a JSON repressentation
  15425. * @param parsedLensFlareSystem Define the JSON to parse
  15426. * @param scene Define the scene the parsed system should be instantiated in
  15427. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  15428. * @returns the parsed system
  15429. */
  15430. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  15431. /**
  15432. * Serialize the current Lens Flare System into a JSON representation.
  15433. * @returns the serialized JSON
  15434. */
  15435. serialize(): any;
  15436. }
  15437. }
  15438. declare module BABYLON {
  15439. interface AbstractScene {
  15440. /**
  15441. * The list of lens flare system added to the scene
  15442. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15443. */
  15444. lensFlareSystems: Array<LensFlareSystem>;
  15445. /**
  15446. * Removes the given lens flare system from this scene.
  15447. * @param toRemove The lens flare system to remove
  15448. * @returns The index of the removed lens flare system
  15449. */
  15450. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  15451. /**
  15452. * Adds the given lens flare system to this scene
  15453. * @param newLensFlareSystem The lens flare system to add
  15454. */
  15455. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  15456. /**
  15457. * Gets a lens flare system using its name
  15458. * @param name defines the name to look for
  15459. * @returns the lens flare system or null if not found
  15460. */
  15461. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  15462. /**
  15463. * Gets a lens flare system using its id
  15464. * @param id defines the id to look for
  15465. * @returns the lens flare system or null if not found
  15466. */
  15467. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  15468. }
  15469. /**
  15470. * Defines the lens flare scene component responsible to manage any lens flares
  15471. * in a given scene.
  15472. */
  15473. class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  15474. /**
  15475. * The component name helpfull to identify the component in the list of scene components.
  15476. */
  15477. readonly name: string;
  15478. /**
  15479. * The scene the component belongs to.
  15480. */
  15481. scene: Scene;
  15482. /**
  15483. * Creates a new instance of the component for the given scene
  15484. * @param scene Defines the scene to register the component in
  15485. */
  15486. constructor(scene: Scene);
  15487. /**
  15488. * Registers the component in a given scene
  15489. */
  15490. register(): void;
  15491. /**
  15492. * Rebuilds the elements related to this component in case of
  15493. * context lost for instance.
  15494. */
  15495. rebuild(): void;
  15496. /**
  15497. * Adds all the element from the container to the scene
  15498. * @param container the container holding the elements
  15499. */
  15500. addFromContainer(container: AbstractScene): void;
  15501. /**
  15502. * Removes all the elements in the container from the scene
  15503. * @param container contains the elements to remove
  15504. */
  15505. removeFromContainer(container: AbstractScene): void;
  15506. /**
  15507. * Serializes the component data to the specified json object
  15508. * @param serializationObject The object to serialize to
  15509. */
  15510. serialize(serializationObject: any): void;
  15511. /**
  15512. * Disposes the component and the associated ressources.
  15513. */
  15514. dispose(): void;
  15515. private _draw;
  15516. }
  15517. }
  15518. declare module BABYLON {
  15519. /**
  15520. * A directional light is defined by a direction (what a surprise!).
  15521. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  15522. * 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.
  15523. * Documentation: https://doc.babylonjs.com/babylon101/lights
  15524. */
  15525. class DirectionalLight extends ShadowLight {
  15526. private _shadowFrustumSize;
  15527. /**
  15528. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  15529. */
  15530. /**
  15531. * Specifies a fix frustum size for the shadow generation.
  15532. */
  15533. shadowFrustumSize: number;
  15534. private _shadowOrthoScale;
  15535. /**
  15536. * Gets the shadow projection scale against the optimal computed one.
  15537. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  15538. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  15539. */
  15540. /**
  15541. * Sets the shadow projection scale against the optimal computed one.
  15542. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  15543. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  15544. */
  15545. shadowOrthoScale: number;
  15546. /**
  15547. * Automatically compute the projection matrix to best fit (including all the casters)
  15548. * on each frame.
  15549. */
  15550. autoUpdateExtends: boolean;
  15551. private _orthoLeft;
  15552. private _orthoRight;
  15553. private _orthoTop;
  15554. private _orthoBottom;
  15555. /**
  15556. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  15557. * The directional light is emitted from everywhere in the given direction.
  15558. * It can cast shadows.
  15559. * Documentation : https://doc.babylonjs.com/babylon101/lights
  15560. * @param name The friendly name of the light
  15561. * @param direction The direction of the light
  15562. * @param scene The scene the light belongs to
  15563. */
  15564. constructor(name: string, direction: Vector3, scene: Scene);
  15565. /**
  15566. * Returns the string "DirectionalLight".
  15567. * @return The class name
  15568. */
  15569. getClassName(): string;
  15570. /**
  15571. * Returns the integer 1.
  15572. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15573. */
  15574. getTypeID(): number;
  15575. /**
  15576. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  15577. * Returns the DirectionalLight Shadow projection matrix.
  15578. */
  15579. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  15580. /**
  15581. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  15582. * Returns the DirectionalLight Shadow projection matrix.
  15583. */
  15584. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix): void;
  15585. /**
  15586. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  15587. * Returns the DirectionalLight Shadow projection matrix.
  15588. */
  15589. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  15590. protected _buildUniformLayout(): void;
  15591. /**
  15592. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  15593. * @param effect The effect to update
  15594. * @param lightIndex The index of the light in the effect to update
  15595. * @returns The directional light
  15596. */
  15597. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  15598. /**
  15599. * Gets the minZ used for shadow according to both the scene and the light.
  15600. *
  15601. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  15602. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  15603. * @param activeCamera The camera we are returning the min for
  15604. * @returns the depth min z
  15605. */
  15606. getDepthMinZ(activeCamera: Camera): number;
  15607. /**
  15608. * Gets the maxZ used for shadow according to both the scene and the light.
  15609. *
  15610. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  15611. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  15612. * @param activeCamera The camera we are returning the max for
  15613. * @returns the depth max z
  15614. */
  15615. getDepthMaxZ(activeCamera: Camera): number;
  15616. /**
  15617. * Prepares the list of defines specific to the light type.
  15618. * @param defines the list of defines
  15619. * @param lightIndex defines the index of the light for the effect
  15620. */
  15621. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15622. }
  15623. }
  15624. declare module BABYLON {
  15625. /**
  15626. * The HemisphericLight simulates the ambient environment light,
  15627. * so the passed direction is the light reflection direction, not the incoming direction.
  15628. */
  15629. class HemisphericLight extends Light {
  15630. /**
  15631. * The groundColor is the light in the opposite direction to the one specified during creation.
  15632. * 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.
  15633. */
  15634. groundColor: Color3;
  15635. /**
  15636. * The light reflection direction, not the incoming direction.
  15637. */
  15638. direction: Vector3;
  15639. /**
  15640. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  15641. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  15642. * The HemisphericLight can't cast shadows.
  15643. * Documentation : https://doc.babylonjs.com/babylon101/lights
  15644. * @param name The friendly name of the light
  15645. * @param direction The direction of the light reflection
  15646. * @param scene The scene the light belongs to
  15647. */
  15648. constructor(name: string, direction: Vector3, scene: Scene);
  15649. protected _buildUniformLayout(): void;
  15650. /**
  15651. * Returns the string "HemisphericLight".
  15652. * @return The class name
  15653. */
  15654. getClassName(): string;
  15655. /**
  15656. * Sets the HemisphericLight direction towards the passed target (Vector3).
  15657. * Returns the updated direction.
  15658. * @param target The target the direction should point to
  15659. * @return The computed direction
  15660. */
  15661. setDirectionToTarget(target: Vector3): Vector3;
  15662. /**
  15663. * Returns the shadow generator associated to the light.
  15664. * @returns Always null for hemispheric lights because it does not support shadows.
  15665. */
  15666. getShadowGenerator(): Nullable<IShadowGenerator>;
  15667. /**
  15668. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  15669. * @param effect The effect to update
  15670. * @param lightIndex The index of the light in the effect to update
  15671. * @returns The hemispheric light
  15672. */
  15673. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  15674. /**
  15675. * Computes the world matrix of the node
  15676. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15677. * @param useWasUpdatedFlag defines a reserved property
  15678. * @returns the world matrix
  15679. */
  15680. computeWorldMatrix(force?: boolean, useWasUpdatedFlag?: boolean): Matrix;
  15681. /**
  15682. * Returns the integer 3.
  15683. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15684. */
  15685. getTypeID(): number;
  15686. /**
  15687. * Prepares the list of defines specific to the light type.
  15688. * @param defines the list of defines
  15689. * @param lightIndex defines the index of the light for the effect
  15690. */
  15691. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15692. }
  15693. }
  15694. declare module BABYLON {
  15695. /**
  15696. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  15697. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  15698. * 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.
  15699. */
  15700. abstract class Light extends Node {
  15701. /**
  15702. * Falloff Default: light is falling off following the material specification:
  15703. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  15704. */
  15705. static readonly FALLOFF_DEFAULT: number;
  15706. /**
  15707. * Falloff Physical: light is falling off following the inverse squared distance law.
  15708. */
  15709. static readonly FALLOFF_PHYSICAL: number;
  15710. /**
  15711. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  15712. * to enhance interoperability with other engines.
  15713. */
  15714. static readonly FALLOFF_GLTF: number;
  15715. /**
  15716. * Falloff Standard: light is falling off like in the standard material
  15717. * to enhance interoperability with other materials.
  15718. */
  15719. static readonly FALLOFF_STANDARD: number;
  15720. /**
  15721. * If every light affecting the material is in this lightmapMode,
  15722. * material.lightmapTexture adds or multiplies
  15723. * (depends on material.useLightmapAsShadowmap)
  15724. * after every other light calculations.
  15725. */
  15726. static readonly LIGHTMAP_DEFAULT: number;
  15727. /**
  15728. * material.lightmapTexture as only diffuse lighting from this light
  15729. * adds only specular lighting from this light
  15730. * adds dynamic shadows
  15731. */
  15732. static readonly LIGHTMAP_SPECULAR: number;
  15733. /**
  15734. * material.lightmapTexture as only lighting
  15735. * no light calculation from this light
  15736. * only adds dynamic shadows from this light
  15737. */
  15738. static readonly LIGHTMAP_SHADOWSONLY: number;
  15739. /**
  15740. * Each light type uses the default quantity according to its type:
  15741. * point/spot lights use luminous intensity
  15742. * directional lights use illuminance
  15743. */
  15744. static readonly INTENSITYMODE_AUTOMATIC: number;
  15745. /**
  15746. * lumen (lm)
  15747. */
  15748. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  15749. /**
  15750. * candela (lm/sr)
  15751. */
  15752. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  15753. /**
  15754. * lux (lm/m^2)
  15755. */
  15756. static readonly INTENSITYMODE_ILLUMINANCE: number;
  15757. /**
  15758. * nit (cd/m^2)
  15759. */
  15760. static readonly INTENSITYMODE_LUMINANCE: number;
  15761. /**
  15762. * Light type const id of the point light.
  15763. */
  15764. static readonly LIGHTTYPEID_POINTLIGHT: number;
  15765. /**
  15766. * Light type const id of the directional light.
  15767. */
  15768. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  15769. /**
  15770. * Light type const id of the spot light.
  15771. */
  15772. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  15773. /**
  15774. * Light type const id of the hemispheric light.
  15775. */
  15776. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  15777. /**
  15778. * Diffuse gives the basic color to an object.
  15779. */
  15780. diffuse: Color3;
  15781. /**
  15782. * Specular produces a highlight color on an object.
  15783. * Note: This is note affecting PBR materials.
  15784. */
  15785. specular: Color3;
  15786. /**
  15787. * Defines the falloff type for this light. This lets overrriding how punctual light are
  15788. * falling off base on range or angle.
  15789. * This can be set to any values in Light.FALLOFF_x.
  15790. *
  15791. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  15792. * other types of materials.
  15793. */
  15794. falloffType: number;
  15795. /**
  15796. * Strength of the light.
  15797. * Note: By default it is define in the framework own unit.
  15798. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  15799. */
  15800. intensity: number;
  15801. private _range;
  15802. protected _inverseSquaredRange: number;
  15803. /**
  15804. * Defines how far from the source the light is impacting in scene units.
  15805. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  15806. */
  15807. /**
  15808. * Defines how far from the source the light is impacting in scene units.
  15809. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  15810. */
  15811. range: number;
  15812. /**
  15813. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  15814. * of light.
  15815. */
  15816. private _photometricScale;
  15817. private _intensityMode;
  15818. /**
  15819. * Gets the photometric scale used to interpret the intensity.
  15820. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  15821. */
  15822. /**
  15823. * Sets the photometric scale used to interpret the intensity.
  15824. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  15825. */
  15826. intensityMode: number;
  15827. private _radius;
  15828. /**
  15829. * Gets the light radius used by PBR Materials to simulate soft area lights.
  15830. */
  15831. /**
  15832. * sets the light radius used by PBR Materials to simulate soft area lights.
  15833. */
  15834. radius: number;
  15835. private _renderPriority;
  15836. /**
  15837. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  15838. * exceeding the number allowed of the materials.
  15839. */
  15840. renderPriority: number;
  15841. private _shadowEnabled;
  15842. /**
  15843. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  15844. * the current shadow generator.
  15845. */
  15846. /**
  15847. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  15848. * the current shadow generator.
  15849. */
  15850. shadowEnabled: boolean;
  15851. private _includedOnlyMeshes;
  15852. /**
  15853. * Gets the only meshes impacted by this light.
  15854. */
  15855. /**
  15856. * Sets the only meshes impacted by this light.
  15857. */
  15858. includedOnlyMeshes: AbstractMesh[];
  15859. private _excludedMeshes;
  15860. /**
  15861. * Gets the meshes not impacted by this light.
  15862. */
  15863. /**
  15864. * Sets the meshes not impacted by this light.
  15865. */
  15866. excludedMeshes: AbstractMesh[];
  15867. private _excludeWithLayerMask;
  15868. /**
  15869. * Gets the layer id use to find what meshes are not impacted by the light.
  15870. * Inactive if 0
  15871. */
  15872. /**
  15873. * Sets the layer id use to find what meshes are not impacted by the light.
  15874. * Inactive if 0
  15875. */
  15876. excludeWithLayerMask: number;
  15877. private _includeOnlyWithLayerMask;
  15878. /**
  15879. * Gets the layer id use to find what meshes are impacted by the light.
  15880. * Inactive if 0
  15881. */
  15882. /**
  15883. * Sets the layer id use to find what meshes are impacted by the light.
  15884. * Inactive if 0
  15885. */
  15886. includeOnlyWithLayerMask: number;
  15887. private _lightmapMode;
  15888. /**
  15889. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  15890. */
  15891. /**
  15892. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  15893. */
  15894. lightmapMode: number;
  15895. /**
  15896. * Shadow generator associted to the light.
  15897. * @hidden Internal use only.
  15898. */
  15899. _shadowGenerator: Nullable<IShadowGenerator>;
  15900. /**
  15901. * @hidden Internal use only.
  15902. */
  15903. _excludedMeshesIds: string[];
  15904. /**
  15905. * @hidden Internal use only.
  15906. */
  15907. _includedOnlyMeshesIds: string[];
  15908. /**
  15909. * The current light unifom buffer.
  15910. * @hidden Internal use only.
  15911. */
  15912. _uniformBuffer: UniformBuffer;
  15913. /**
  15914. * Creates a Light object in the scene.
  15915. * Documentation : https://doc.babylonjs.com/babylon101/lights
  15916. * @param name The firendly name of the light
  15917. * @param scene The scene the light belongs too
  15918. */
  15919. constructor(name: string, scene: Scene);
  15920. protected abstract _buildUniformLayout(): void;
  15921. /**
  15922. * Sets the passed Effect "effect" with the Light information.
  15923. * @param effect The effect to update
  15924. * @param lightIndex The index of the light in the effect to update
  15925. * @returns The light
  15926. */
  15927. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  15928. /**
  15929. * Returns the string "Light".
  15930. * @returns the class name
  15931. */
  15932. getClassName(): string;
  15933. /**
  15934. * Converts the light information to a readable string for debug purpose.
  15935. * @param fullDetails Supports for multiple levels of logging within scene loading
  15936. * @returns the human readable light info
  15937. */
  15938. toString(fullDetails?: boolean): string;
  15939. /** @hidden */
  15940. protected _syncParentEnabledState(): void;
  15941. /**
  15942. * Set the enabled state of this node.
  15943. * @param value - the new enabled state
  15944. */
  15945. setEnabled(value: boolean): void;
  15946. /**
  15947. * Returns the Light associated shadow generator if any.
  15948. * @return the associated shadow generator.
  15949. */
  15950. getShadowGenerator(): Nullable<IShadowGenerator>;
  15951. /**
  15952. * Returns a Vector3, the absolute light position in the World.
  15953. * @returns the world space position of the light
  15954. */
  15955. getAbsolutePosition(): Vector3;
  15956. /**
  15957. * Specifies if the light will affect the passed mesh.
  15958. * @param mesh The mesh to test against the light
  15959. * @return true the mesh is affected otherwise, false.
  15960. */
  15961. canAffectMesh(mesh: AbstractMesh): boolean;
  15962. /**
  15963. * Sort function to order lights for rendering.
  15964. * @param a First Light object to compare to second.
  15965. * @param b Second Light object to compare first.
  15966. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  15967. */
  15968. static CompareLightsPriority(a: Light, b: Light): number;
  15969. /**
  15970. * Releases resources associated with this node.
  15971. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15972. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15973. */
  15974. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15975. /**
  15976. * Returns the light type ID (integer).
  15977. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15978. */
  15979. getTypeID(): number;
  15980. /**
  15981. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  15982. * @returns the scaled intensity in intensity mode unit
  15983. */
  15984. getScaledIntensity(): number;
  15985. /**
  15986. * Returns a new Light object, named "name", from the current one.
  15987. * @param name The name of the cloned light
  15988. * @returns the new created light
  15989. */
  15990. clone(name: string): Nullable<Light>;
  15991. /**
  15992. * Serializes the current light into a Serialization object.
  15993. * @returns the serialized object.
  15994. */
  15995. serialize(): any;
  15996. /**
  15997. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  15998. * This new light is named "name" and added to the passed scene.
  15999. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  16000. * @param name The friendly name of the light
  16001. * @param scene The scene the new light will belong to
  16002. * @returns the constructor function
  16003. */
  16004. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  16005. /**
  16006. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  16007. * @param parsedLight The JSON representation of the light
  16008. * @param scene The scene to create the parsed light in
  16009. * @returns the created light after parsing
  16010. */
  16011. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  16012. private _hookArrayForExcluded;
  16013. private _hookArrayForIncludedOnly;
  16014. private _resyncMeshes;
  16015. /**
  16016. * Forces the meshes to update their light related information in their rendering used effects
  16017. * @hidden Internal Use Only
  16018. */
  16019. _markMeshesAsLightDirty(): void;
  16020. /**
  16021. * Recomputes the cached photometric scale if needed.
  16022. */
  16023. private _computePhotometricScale;
  16024. /**
  16025. * Returns the Photometric Scale according to the light type and intensity mode.
  16026. */
  16027. private _getPhotometricScale;
  16028. /**
  16029. * Reorder the light in the scene according to their defined priority.
  16030. * @hidden Internal Use Only
  16031. */
  16032. _reorderLightsInScene(): void;
  16033. /**
  16034. * Prepares the list of defines specific to the light type.
  16035. * @param defines the list of defines
  16036. * @param lightIndex defines the index of the light for the effect
  16037. */
  16038. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  16039. }
  16040. }
  16041. declare module BABYLON {
  16042. /**
  16043. * A point light is a light defined by an unique point in world space.
  16044. * The light is emitted in every direction from this point.
  16045. * A good example of a point light is a standard light bulb.
  16046. * Documentation: https://doc.babylonjs.com/babylon101/lights
  16047. */
  16048. class PointLight extends ShadowLight {
  16049. private _shadowAngle;
  16050. /**
  16051. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  16052. * This specifies what angle the shadow will use to be created.
  16053. *
  16054. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  16055. */
  16056. /**
  16057. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  16058. * This specifies what angle the shadow will use to be created.
  16059. *
  16060. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  16061. */
  16062. shadowAngle: number;
  16063. /**
  16064. * Gets the direction if it has been set.
  16065. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  16066. */
  16067. /**
  16068. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  16069. */
  16070. direction: Vector3;
  16071. /**
  16072. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  16073. * A PointLight emits the light in every direction.
  16074. * It can cast shadows.
  16075. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  16076. * ```javascript
  16077. * var pointLight = new BABYLON.PointLight("pl", camera.position, scene);
  16078. * ```
  16079. * Documentation : https://doc.babylonjs.com/babylon101/lights
  16080. * @param name The light friendly name
  16081. * @param position The position of the point light in the scene
  16082. * @param scene The scene the lights belongs to
  16083. */
  16084. constructor(name: string, position: Vector3, scene: Scene);
  16085. /**
  16086. * Returns the string "PointLight"
  16087. * @returns the class name
  16088. */
  16089. getClassName(): string;
  16090. /**
  16091. * Returns the integer 0.
  16092. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  16093. */
  16094. getTypeID(): number;
  16095. /**
  16096. * Specifies wether or not the shadowmap should be a cube texture.
  16097. * @returns true if the shadowmap needs to be a cube texture.
  16098. */
  16099. needCube(): boolean;
  16100. /**
  16101. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  16102. * @param faceIndex The index of the face we are computed the direction to generate shadow
  16103. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  16104. */
  16105. getShadowDirection(faceIndex?: number): Vector3;
  16106. /**
  16107. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  16108. * - fov = PI / 2
  16109. * - aspect ratio : 1.0
  16110. * - z-near and far equal to the active camera minZ and maxZ.
  16111. * Returns the PointLight.
  16112. */
  16113. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  16114. protected _buildUniformLayout(): void;
  16115. /**
  16116. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  16117. * @param effect The effect to update
  16118. * @param lightIndex The index of the light in the effect to update
  16119. * @returns The point light
  16120. */
  16121. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  16122. /**
  16123. * Prepares the list of defines specific to the light type.
  16124. * @param defines the list of defines
  16125. * @param lightIndex defines the index of the light for the effect
  16126. */
  16127. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  16128. }
  16129. }
  16130. declare module BABYLON {
  16131. /**
  16132. * Interface describing all the common properties and methods a shadow light needs to implement.
  16133. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  16134. * as well as binding the different shadow properties to the effects.
  16135. */
  16136. interface IShadowLight extends Light {
  16137. /**
  16138. * The light id in the scene (used in scene.findLighById for instance)
  16139. */
  16140. id: string;
  16141. /**
  16142. * The position the shdow will be casted from.
  16143. */
  16144. position: Vector3;
  16145. /**
  16146. * In 2d mode (needCube being false), the direction used to cast the shadow.
  16147. */
  16148. direction: Vector3;
  16149. /**
  16150. * The transformed position. Position of the light in world space taking parenting in account.
  16151. */
  16152. transformedPosition: Vector3;
  16153. /**
  16154. * The transformed direction. Direction of the light in world space taking parenting in account.
  16155. */
  16156. transformedDirection: Vector3;
  16157. /**
  16158. * The friendly name of the light in the scene.
  16159. */
  16160. name: string;
  16161. /**
  16162. * Defines the shadow projection clipping minimum z value.
  16163. */
  16164. shadowMinZ: number;
  16165. /**
  16166. * Defines the shadow projection clipping maximum z value.
  16167. */
  16168. shadowMaxZ: number;
  16169. /**
  16170. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  16171. * @returns true if the information has been computed, false if it does not need to (no parenting)
  16172. */
  16173. computeTransformedInformation(): boolean;
  16174. /**
  16175. * Gets the scene the light belongs to.
  16176. * @returns The scene
  16177. */
  16178. getScene(): Scene;
  16179. /**
  16180. * Callback defining a custom Projection Matrix Builder.
  16181. * This can be used to override the default projection matrix computation.
  16182. */
  16183. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  16184. /**
  16185. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  16186. * @param matrix The materix to updated with the projection information
  16187. * @param viewMatrix The transform matrix of the light
  16188. * @param renderList The list of mesh to render in the map
  16189. * @returns The current light
  16190. */
  16191. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  16192. /**
  16193. * Gets the current depth scale used in ESM.
  16194. * @returns The scale
  16195. */
  16196. getDepthScale(): number;
  16197. /**
  16198. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  16199. * @returns true if a cube texture needs to be use
  16200. */
  16201. needCube(): boolean;
  16202. /**
  16203. * Detects if the projection matrix requires to be recomputed this frame.
  16204. * @returns true if it requires to be recomputed otherwise, false.
  16205. */
  16206. needProjectionMatrixCompute(): boolean;
  16207. /**
  16208. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  16209. */
  16210. forceProjectionMatrixCompute(): void;
  16211. /**
  16212. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  16213. * @param faceIndex The index of the face we are computed the direction to generate shadow
  16214. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  16215. */
  16216. getShadowDirection(faceIndex?: number): Vector3;
  16217. /**
  16218. * Gets the minZ used for shadow according to both the scene and the light.
  16219. * @param activeCamera The camera we are returning the min for
  16220. * @returns the depth min z
  16221. */
  16222. getDepthMinZ(activeCamera: Camera): number;
  16223. /**
  16224. * Gets the maxZ used for shadow according to both the scene and the light.
  16225. * @param activeCamera The camera we are returning the max for
  16226. * @returns the depth max z
  16227. */
  16228. getDepthMaxZ(activeCamera: Camera): number;
  16229. }
  16230. /**
  16231. * Base implementation IShadowLight
  16232. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  16233. */
  16234. abstract class ShadowLight extends Light implements IShadowLight {
  16235. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  16236. protected _position: Vector3;
  16237. protected _setPosition(value: Vector3): void;
  16238. /**
  16239. * Sets the position the shadow will be casted from. Also use as the light position for both
  16240. * point and spot lights.
  16241. */
  16242. /**
  16243. * Sets the position the shadow will be casted from. Also use as the light position for both
  16244. * point and spot lights.
  16245. */
  16246. position: Vector3;
  16247. protected _direction: Vector3;
  16248. protected _setDirection(value: Vector3): void;
  16249. /**
  16250. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  16251. * Also use as the light direction on spot and directional lights.
  16252. */
  16253. /**
  16254. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  16255. * Also use as the light direction on spot and directional lights.
  16256. */
  16257. direction: Vector3;
  16258. private _shadowMinZ;
  16259. /**
  16260. * Gets the shadow projection clipping minimum z value.
  16261. */
  16262. /**
  16263. * Sets the shadow projection clipping minimum z value.
  16264. */
  16265. shadowMinZ: number;
  16266. private _shadowMaxZ;
  16267. /**
  16268. * Sets the shadow projection clipping maximum z value.
  16269. */
  16270. /**
  16271. * Gets the shadow projection clipping maximum z value.
  16272. */
  16273. shadowMaxZ: number;
  16274. /**
  16275. * Callback defining a custom Projection Matrix Builder.
  16276. * This can be used to override the default projection matrix computation.
  16277. */
  16278. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  16279. /**
  16280. * The transformed position. Position of the light in world space taking parenting in account.
  16281. */
  16282. transformedPosition: Vector3;
  16283. /**
  16284. * The transformed direction. Direction of the light in world space taking parenting in account.
  16285. */
  16286. transformedDirection: Vector3;
  16287. private _needProjectionMatrixCompute;
  16288. /**
  16289. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  16290. * @returns true if the information has been computed, false if it does not need to (no parenting)
  16291. */
  16292. computeTransformedInformation(): boolean;
  16293. /**
  16294. * Return the depth scale used for the shadow map.
  16295. * @returns the depth scale.
  16296. */
  16297. getDepthScale(): number;
  16298. /**
  16299. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  16300. * @param faceIndex The index of the face we are computed the direction to generate shadow
  16301. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  16302. */
  16303. getShadowDirection(faceIndex?: number): Vector3;
  16304. /**
  16305. * Returns the ShadowLight absolute position in the World.
  16306. * @returns the position vector in world space
  16307. */
  16308. getAbsolutePosition(): Vector3;
  16309. /**
  16310. * Sets the ShadowLight direction toward the passed target.
  16311. * @param target The point tot target in local space
  16312. * @returns the updated ShadowLight direction
  16313. */
  16314. setDirectionToTarget(target: Vector3): Vector3;
  16315. /**
  16316. * Returns the light rotation in euler definition.
  16317. * @returns the x y z rotation in local space.
  16318. */
  16319. getRotation(): Vector3;
  16320. /**
  16321. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  16322. * @returns true if a cube texture needs to be use
  16323. */
  16324. needCube(): boolean;
  16325. /**
  16326. * Detects if the projection matrix requires to be recomputed this frame.
  16327. * @returns true if it requires to be recomputed otherwise, false.
  16328. */
  16329. needProjectionMatrixCompute(): boolean;
  16330. /**
  16331. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  16332. */
  16333. forceProjectionMatrixCompute(): void;
  16334. /** @hidden */
  16335. _initCache(): void;
  16336. /** @hidden */
  16337. _isSynchronized(): boolean;
  16338. /**
  16339. * Computes the world matrix of the node
  16340. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  16341. * @returns the world matrix
  16342. */
  16343. computeWorldMatrix(force?: boolean): Matrix;
  16344. /**
  16345. * Gets the minZ used for shadow according to both the scene and the light.
  16346. * @param activeCamera The camera we are returning the min for
  16347. * @returns the depth min z
  16348. */
  16349. getDepthMinZ(activeCamera: Camera): number;
  16350. /**
  16351. * Gets the maxZ used for shadow according to both the scene and the light.
  16352. * @param activeCamera The camera we are returning the max for
  16353. * @returns the depth max z
  16354. */
  16355. getDepthMaxZ(activeCamera: Camera): number;
  16356. /**
  16357. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  16358. * @param matrix The materix to updated with the projection information
  16359. * @param viewMatrix The transform matrix of the light
  16360. * @param renderList The list of mesh to render in the map
  16361. * @returns The current light
  16362. */
  16363. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  16364. }
  16365. }
  16366. declare module BABYLON {
  16367. /**
  16368. * A spot light is defined by a position, a direction, an angle, and an exponent.
  16369. * These values define a cone of light starting from the position, emitting toward the direction.
  16370. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  16371. * and the exponent defines the speed of the decay of the light with distance (reach).
  16372. * Documentation: https://doc.babylonjs.com/babylon101/lights
  16373. */
  16374. class SpotLight extends ShadowLight {
  16375. private _angle;
  16376. private _innerAngle;
  16377. private _cosHalfAngle;
  16378. private _lightAngleScale;
  16379. private _lightAngleOffset;
  16380. /**
  16381. * Gets the cone angle of the spot light in Radians.
  16382. */
  16383. /**
  16384. * Sets the cone angle of the spot light in Radians.
  16385. */
  16386. angle: number;
  16387. /**
  16388. * Only used in gltf falloff mode, this defines the angle where
  16389. * the directional falloff will start before cutting at angle which could be seen
  16390. * as outer angle.
  16391. */
  16392. /**
  16393. * Only used in gltf falloff mode, this defines the angle where
  16394. * the directional falloff will start before cutting at angle which could be seen
  16395. * as outer angle.
  16396. */
  16397. innerAngle: number;
  16398. private _shadowAngleScale;
  16399. /**
  16400. * Allows scaling the angle of the light for shadow generation only.
  16401. */
  16402. /**
  16403. * Allows scaling the angle of the light for shadow generation only.
  16404. */
  16405. shadowAngleScale: number;
  16406. /**
  16407. * The light decay speed with the distance from the emission spot.
  16408. */
  16409. exponent: number;
  16410. private _projectionTextureMatrix;
  16411. /**
  16412. * Allows reading the projecton texture
  16413. */
  16414. readonly projectionTextureMatrix: Matrix;
  16415. protected _projectionTextureLightNear: number;
  16416. /**
  16417. * Gets the near clip of the Spotlight for texture projection.
  16418. */
  16419. /**
  16420. * Sets the near clip of the Spotlight for texture projection.
  16421. */
  16422. projectionTextureLightNear: number;
  16423. protected _projectionTextureLightFar: number;
  16424. /**
  16425. * Gets the far clip of the Spotlight for texture projection.
  16426. */
  16427. /**
  16428. * Sets the far clip of the Spotlight for texture projection.
  16429. */
  16430. projectionTextureLightFar: number;
  16431. protected _projectionTextureUpDirection: Vector3;
  16432. /**
  16433. * Gets the Up vector of the Spotlight for texture projection.
  16434. */
  16435. /**
  16436. * Sets the Up vector of the Spotlight for texture projection.
  16437. */
  16438. projectionTextureUpDirection: Vector3;
  16439. private _projectionTexture;
  16440. /**
  16441. * Gets the projection texture of the light.
  16442. */
  16443. /**
  16444. * Sets the projection texture of the light.
  16445. */
  16446. projectionTexture: Nullable<BaseTexture>;
  16447. private _projectionTextureViewLightDirty;
  16448. private _projectionTextureProjectionLightDirty;
  16449. private _projectionTextureDirty;
  16450. private _projectionTextureViewTargetVector;
  16451. private _projectionTextureViewLightMatrix;
  16452. private _projectionTextureProjectionLightMatrix;
  16453. private _projectionTextureScalingMatrix;
  16454. /**
  16455. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  16456. * It can cast shadows.
  16457. * Documentation : https://doc.babylonjs.com/babylon101/lights
  16458. * @param name The light friendly name
  16459. * @param position The position of the spot light in the scene
  16460. * @param direction The direction of the light in the scene
  16461. * @param angle The cone angle of the light in Radians
  16462. * @param exponent The light decay speed with the distance from the emission spot
  16463. * @param scene The scene the lights belongs to
  16464. */
  16465. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  16466. /**
  16467. * Returns the string "SpotLight".
  16468. * @returns the class name
  16469. */
  16470. getClassName(): string;
  16471. /**
  16472. * Returns the integer 2.
  16473. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  16474. */
  16475. getTypeID(): number;
  16476. /**
  16477. * Overrides the direction setter to recompute the projection texture view light Matrix.
  16478. */
  16479. protected _setDirection(value: Vector3): void;
  16480. /**
  16481. * Overrides the position setter to recompute the projection texture view light Matrix.
  16482. */
  16483. protected _setPosition(value: Vector3): void;
  16484. /**
  16485. * 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.
  16486. * Returns the SpotLight.
  16487. */
  16488. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  16489. protected _computeProjectionTextureViewLightMatrix(): void;
  16490. protected _computeProjectionTextureProjectionLightMatrix(): void;
  16491. /**
  16492. * Main function for light texture projection matrix computing.
  16493. */
  16494. protected _computeProjectionTextureMatrix(): void;
  16495. protected _buildUniformLayout(): void;
  16496. private _computeAngleValues;
  16497. /**
  16498. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  16499. * @param effect The effect to update
  16500. * @param lightIndex The index of the light in the effect to update
  16501. * @returns The spot light
  16502. */
  16503. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  16504. /**
  16505. * Disposes the light and the associated resources.
  16506. */
  16507. dispose(): void;
  16508. /**
  16509. * Prepares the list of defines specific to the light type.
  16510. * @param defines the list of defines
  16511. * @param lightIndex defines the index of the light for the effect
  16512. */
  16513. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  16514. }
  16515. }
  16516. declare module BABYLON {
  16517. /**
  16518. * Interface used to present a loading screen while loading a scene
  16519. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  16520. */
  16521. interface ILoadingScreen {
  16522. /**
  16523. * Function called to display the loading screen
  16524. */
  16525. displayLoadingUI: () => void;
  16526. /**
  16527. * Function called to hide the loading screen
  16528. */
  16529. hideLoadingUI: () => void;
  16530. /**
  16531. * Gets or sets the color to use for the background
  16532. */
  16533. loadingUIBackgroundColor: string;
  16534. /**
  16535. * Gets or sets the text to display while loading
  16536. */
  16537. loadingUIText: string;
  16538. }
  16539. /**
  16540. * Class used for the default loading screen
  16541. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  16542. */
  16543. class DefaultLoadingScreen implements ILoadingScreen {
  16544. private _renderingCanvas;
  16545. private _loadingText;
  16546. private _loadingDivBackgroundColor;
  16547. private _loadingDiv;
  16548. private _loadingTextDiv;
  16549. /**
  16550. * Creates a new default loading screen
  16551. * @param _renderingCanvas defines the canvas used to render the scene
  16552. * @param _loadingText defines the default text to display
  16553. * @param _loadingDivBackgroundColor defines the default background color
  16554. */
  16555. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  16556. /**
  16557. * Function called to display the loading screen
  16558. */
  16559. displayLoadingUI(): void;
  16560. /**
  16561. * Function called to hide the loading screen
  16562. */
  16563. hideLoadingUI(): void;
  16564. /**
  16565. * Gets or sets the text to display while loading
  16566. */
  16567. loadingUIText: string;
  16568. /**
  16569. * Gets or sets the color to use for the background
  16570. */
  16571. loadingUIBackgroundColor: string;
  16572. private _resizeLoadingUI;
  16573. }
  16574. }
  16575. declare module BABYLON {
  16576. /**
  16577. * Class used to represent data loading progression
  16578. */
  16579. class SceneLoaderProgressEvent {
  16580. /** defines if data length to load can be evaluated */
  16581. readonly lengthComputable: boolean;
  16582. /** defines the loaded data length */
  16583. readonly loaded: number;
  16584. /** defines the data length to load */
  16585. readonly total: number;
  16586. /**
  16587. * Create a new progress event
  16588. * @param lengthComputable defines if data length to load can be evaluated
  16589. * @param loaded defines the loaded data length
  16590. * @param total defines the data length to load
  16591. */
  16592. constructor(
  16593. /** defines if data length to load can be evaluated */
  16594. lengthComputable: boolean,
  16595. /** defines the loaded data length */
  16596. loaded: number,
  16597. /** defines the data length to load */
  16598. total: number);
  16599. /**
  16600. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  16601. * @param event defines the source event
  16602. * @returns a new SceneLoaderProgressEvent
  16603. */
  16604. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  16605. }
  16606. /**
  16607. * Interface used by SceneLoader plugins to define supported file extensions
  16608. */
  16609. interface ISceneLoaderPluginExtensions {
  16610. /**
  16611. * Defines the list of supported extensions
  16612. */
  16613. [extension: string]: {
  16614. isBinary: boolean;
  16615. };
  16616. }
  16617. /**
  16618. * Interface used by SceneLoader plugin factory
  16619. */
  16620. interface ISceneLoaderPluginFactory {
  16621. /**
  16622. * Defines the name of the factory
  16623. */
  16624. name: string;
  16625. /**
  16626. * Function called to create a new plugin
  16627. * @return the new plugin
  16628. */
  16629. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  16630. /**
  16631. * Boolean indicating if the plugin can direct load specific data
  16632. */
  16633. canDirectLoad?: (data: string) => boolean;
  16634. }
  16635. /**
  16636. * Interface used to define a SceneLoader plugin
  16637. */
  16638. interface ISceneLoaderPlugin {
  16639. /**
  16640. * The friendly name of this plugin.
  16641. */
  16642. name: string;
  16643. /**
  16644. * The file extensions supported by this plugin.
  16645. */
  16646. extensions: string | ISceneLoaderPluginExtensions;
  16647. /**
  16648. * Import meshes into a scene.
  16649. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  16650. * @param scene The scene to import into
  16651. * @param data The data to import
  16652. * @param rootUrl The root url for scene and resources
  16653. * @param meshes The meshes array to import into
  16654. * @param particleSystems The particle systems array to import into
  16655. * @param skeletons The skeletons array to import into
  16656. * @param onError The callback when import fails
  16657. * @returns True if successful or false otherwise
  16658. */
  16659. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  16660. /**
  16661. * Load into a scene.
  16662. * @param scene The scene to load into
  16663. * @param data The data to import
  16664. * @param rootUrl The root url for scene and resources
  16665. * @param onError The callback when import fails
  16666. * @returns true if successful or false otherwise
  16667. */
  16668. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  16669. /**
  16670. * The callback that returns true if the data can be directly loaded.
  16671. */
  16672. canDirectLoad?: (data: string) => boolean;
  16673. /**
  16674. * The callback that allows custom handling of the root url based on the response url.
  16675. */
  16676. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  16677. /**
  16678. * Load into an asset container.
  16679. * @param scene The scene to load into
  16680. * @param data The data to import
  16681. * @param rootUrl The root url for scene and resources
  16682. * @param onError The callback when import fails
  16683. * @returns The loaded asset container
  16684. */
  16685. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  16686. }
  16687. /**
  16688. * Interface used to define an async SceneLoader plugin
  16689. */
  16690. interface ISceneLoaderPluginAsync {
  16691. /**
  16692. * The friendly name of this plugin.
  16693. */
  16694. name: string;
  16695. /**
  16696. * The file extensions supported by this plugin.
  16697. */
  16698. extensions: string | ISceneLoaderPluginExtensions;
  16699. /**
  16700. * Import meshes into a scene.
  16701. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  16702. * @param scene The scene to import into
  16703. * @param data The data to import
  16704. * @param rootUrl The root url for scene and resources
  16705. * @param onProgress The callback when the load progresses
  16706. * @param fileName Defines the name of the file to load
  16707. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  16708. */
  16709. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  16710. meshes: AbstractMesh[];
  16711. particleSystems: IParticleSystem[];
  16712. skeletons: Skeleton[];
  16713. animationGroups: AnimationGroup[];
  16714. }>;
  16715. /**
  16716. * Load into a scene.
  16717. * @param scene The scene to load into
  16718. * @param data The data to import
  16719. * @param rootUrl The root url for scene and resources
  16720. * @param onProgress The callback when the load progresses
  16721. * @param fileName Defines the name of the file to load
  16722. * @returns Nothing
  16723. */
  16724. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  16725. /**
  16726. * The callback that returns true if the data can be directly loaded.
  16727. */
  16728. canDirectLoad?: (data: string) => boolean;
  16729. /**
  16730. * The callback that allows custom handling of the root url based on the response url.
  16731. */
  16732. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  16733. /**
  16734. * Load into an asset container.
  16735. * @param scene The scene to load into
  16736. * @param data The data to import
  16737. * @param rootUrl The root url for scene and resources
  16738. * @param onProgress The callback when the load progresses
  16739. * @param fileName Defines the name of the file to load
  16740. * @returns The loaded asset container
  16741. */
  16742. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  16743. }
  16744. /**
  16745. * Class used to load scene from various file formats using registered plugins
  16746. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  16747. */
  16748. class SceneLoader {
  16749. private static _ForceFullSceneLoadingForIncremental;
  16750. private static _ShowLoadingScreen;
  16751. private static _CleanBoneMatrixWeights;
  16752. /**
  16753. * No logging while loading
  16754. */
  16755. static readonly NO_LOGGING: number;
  16756. /**
  16757. * Minimal logging while loading
  16758. */
  16759. static readonly MINIMAL_LOGGING: number;
  16760. /**
  16761. * Summary logging while loading
  16762. */
  16763. static readonly SUMMARY_LOGGING: number;
  16764. /**
  16765. * Detailled logging while loading
  16766. */
  16767. static readonly DETAILED_LOGGING: number;
  16768. private static _loggingLevel;
  16769. /**
  16770. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  16771. */
  16772. static ForceFullSceneLoadingForIncremental: boolean;
  16773. /**
  16774. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  16775. */
  16776. static ShowLoadingScreen: boolean;
  16777. /**
  16778. * Defines the current logging level (while loading the scene)
  16779. * @ignorenaming
  16780. */
  16781. static loggingLevel: number;
  16782. /**
  16783. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  16784. */
  16785. static CleanBoneMatrixWeights: boolean;
  16786. /**
  16787. * Event raised when a plugin is used to load a scene
  16788. */
  16789. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  16790. private static _registeredPlugins;
  16791. private static _getDefaultPlugin;
  16792. private static _getPluginForExtension;
  16793. private static _getPluginForDirectLoad;
  16794. private static _getPluginForFilename;
  16795. private static _getDirectLoad;
  16796. private static _loadData;
  16797. private static _getFileInfo;
  16798. /**
  16799. * Gets a plugin that can load the given extension
  16800. * @param extension defines the extension to load
  16801. * @returns a plugin or null if none works
  16802. */
  16803. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  16804. /**
  16805. * Gets a boolean indicating that the given extension can be loaded
  16806. * @param extension defines the extension to load
  16807. * @returns true if the extension is supported
  16808. */
  16809. static IsPluginForExtensionAvailable(extension: string): boolean;
  16810. /**
  16811. * Adds a new plugin to the list of registered plugins
  16812. * @param plugin defines the plugin to add
  16813. */
  16814. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  16815. /**
  16816. * Import meshes into a scene
  16817. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  16818. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  16819. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  16820. * @param scene the instance of BABYLON.Scene to append to
  16821. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  16822. * @param onProgress a callback with a progress event for each file being loaded
  16823. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  16824. * @param pluginExtension the extension used to determine the plugin
  16825. * @returns The loaded plugin
  16826. */
  16827. 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>;
  16828. /**
  16829. * Import meshes into a scene
  16830. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  16831. * @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)
  16832. * @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)
  16833. * @param scene the instance of BABYLON.Scene to append to
  16834. * @param onProgress a callback with a progress event for each file being loaded
  16835. * @param pluginExtension the extension used to determine the plugin
  16836. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  16837. */
  16838. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  16839. meshes: AbstractMesh[];
  16840. particleSystems: IParticleSystem[];
  16841. skeletons: Skeleton[];
  16842. animationGroups: AnimationGroup[];
  16843. }>;
  16844. /**
  16845. * Load a scene
  16846. * @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)
  16847. * @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)
  16848. * @param engine is the instance of BABYLON.Engine to use to create the scene
  16849. * @param onSuccess a callback with the scene when import succeeds
  16850. * @param onProgress a callback with a progress event for each file being loaded
  16851. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  16852. * @param pluginExtension the extension used to determine the plugin
  16853. * @returns The loaded plugin
  16854. */
  16855. 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>;
  16856. /**
  16857. * Load a scene
  16858. * @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)
  16859. * @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)
  16860. * @param engine is the instance of BABYLON.Engine to use to create the scene
  16861. * @param onProgress a callback with a progress event for each file being loaded
  16862. * @param pluginExtension the extension used to determine the plugin
  16863. * @returns The loaded scene
  16864. */
  16865. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  16866. /**
  16867. * Append a scene
  16868. * @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)
  16869. * @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)
  16870. * @param scene is the instance of BABYLON.Scene to append to
  16871. * @param onSuccess a callback with the scene when import succeeds
  16872. * @param onProgress a callback with a progress event for each file being loaded
  16873. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  16874. * @param pluginExtension the extension used to determine the plugin
  16875. * @returns The loaded plugin
  16876. */
  16877. 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>;
  16878. /**
  16879. * Append a scene
  16880. * @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)
  16881. * @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)
  16882. * @param scene is the instance of BABYLON.Scene to append to
  16883. * @param onProgress a callback with a progress event for each file being loaded
  16884. * @param pluginExtension the extension used to determine the plugin
  16885. * @returns The given scene
  16886. */
  16887. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  16888. /**
  16889. * Load a scene into an asset container
  16890. * @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)
  16891. * @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)
  16892. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  16893. * @param onSuccess a callback with the scene when import succeeds
  16894. * @param onProgress a callback with a progress event for each file being loaded
  16895. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  16896. * @param pluginExtension the extension used to determine the plugin
  16897. * @returns The loaded plugin
  16898. */
  16899. 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>;
  16900. /**
  16901. * Load a scene into an asset container
  16902. * @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)
  16903. * @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)
  16904. * @param scene is the instance of BABYLON.Scene to append to
  16905. * @param onProgress a callback with a progress event for each file being loaded
  16906. * @param pluginExtension the extension used to determine the plugin
  16907. * @returns The loaded asset container
  16908. */
  16909. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  16910. }
  16911. }
  16912. declare module BABYLON {
  16913. /**
  16914. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  16915. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  16916. * 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;
  16917. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  16918. */
  16919. class ColorCurves {
  16920. private _dirty;
  16921. private _tempColor;
  16922. private _globalCurve;
  16923. private _highlightsCurve;
  16924. private _midtonesCurve;
  16925. private _shadowsCurve;
  16926. private _positiveCurve;
  16927. private _negativeCurve;
  16928. private _globalHue;
  16929. private _globalDensity;
  16930. private _globalSaturation;
  16931. private _globalExposure;
  16932. /**
  16933. * Gets the global Hue value.
  16934. * 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).
  16935. */
  16936. /**
  16937. * Sets the global Hue value.
  16938. * 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).
  16939. */
  16940. globalHue: number;
  16941. /**
  16942. * Gets the global Density value.
  16943. * 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.
  16944. * Values less than zero provide a filter of opposite hue.
  16945. */
  16946. /**
  16947. * Sets the global Density value.
  16948. * 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.
  16949. * Values less than zero provide a filter of opposite hue.
  16950. */
  16951. globalDensity: number;
  16952. /**
  16953. * Gets the global Saturation value.
  16954. * 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.
  16955. */
  16956. /**
  16957. * Sets the global Saturation value.
  16958. * 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.
  16959. */
  16960. globalSaturation: number;
  16961. /**
  16962. * Gets the global Exposure value.
  16963. * 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.
  16964. */
  16965. /**
  16966. * Sets the global Exposure value.
  16967. * 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.
  16968. */
  16969. globalExposure: number;
  16970. private _highlightsHue;
  16971. private _highlightsDensity;
  16972. private _highlightsSaturation;
  16973. private _highlightsExposure;
  16974. /**
  16975. * Gets the highlights Hue value.
  16976. * 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).
  16977. */
  16978. /**
  16979. * Sets the highlights Hue value.
  16980. * 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).
  16981. */
  16982. highlightsHue: number;
  16983. /**
  16984. * Gets the highlights Density value.
  16985. * 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.
  16986. * Values less than zero provide a filter of opposite hue.
  16987. */
  16988. /**
  16989. * Sets the highlights Density value.
  16990. * 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.
  16991. * Values less than zero provide a filter of opposite hue.
  16992. */
  16993. highlightsDensity: number;
  16994. /**
  16995. * Gets the highlights Saturation value.
  16996. * 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.
  16997. */
  16998. /**
  16999. * Sets the highlights Saturation value.
  17000. * 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.
  17001. */
  17002. highlightsSaturation: number;
  17003. /**
  17004. * Gets the highlights Exposure value.
  17005. * 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.
  17006. */
  17007. /**
  17008. * Sets the highlights Exposure value.
  17009. * 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.
  17010. */
  17011. highlightsExposure: number;
  17012. private _midtonesHue;
  17013. private _midtonesDensity;
  17014. private _midtonesSaturation;
  17015. private _midtonesExposure;
  17016. /**
  17017. * Gets the midtones Hue value.
  17018. * 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).
  17019. */
  17020. /**
  17021. * Sets the midtones Hue value.
  17022. * 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).
  17023. */
  17024. midtonesHue: number;
  17025. /**
  17026. * Gets the midtones Density value.
  17027. * 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.
  17028. * Values less than zero provide a filter of opposite hue.
  17029. */
  17030. /**
  17031. * Sets the midtones Density value.
  17032. * 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.
  17033. * Values less than zero provide a filter of opposite hue.
  17034. */
  17035. midtonesDensity: number;
  17036. /**
  17037. * Gets the midtones Saturation value.
  17038. * 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.
  17039. */
  17040. /**
  17041. * Sets the midtones Saturation value.
  17042. * 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.
  17043. */
  17044. midtonesSaturation: number;
  17045. /**
  17046. * Gets the midtones Exposure value.
  17047. * 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.
  17048. */
  17049. /**
  17050. * Sets the midtones Exposure value.
  17051. * 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.
  17052. */
  17053. midtonesExposure: number;
  17054. private _shadowsHue;
  17055. private _shadowsDensity;
  17056. private _shadowsSaturation;
  17057. private _shadowsExposure;
  17058. /**
  17059. * Gets the shadows Hue value.
  17060. * 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).
  17061. */
  17062. /**
  17063. * Sets the shadows Hue value.
  17064. * 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).
  17065. */
  17066. shadowsHue: number;
  17067. /**
  17068. * Gets the shadows Density value.
  17069. * 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.
  17070. * Values less than zero provide a filter of opposite hue.
  17071. */
  17072. /**
  17073. * Sets the shadows Density value.
  17074. * 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.
  17075. * Values less than zero provide a filter of opposite hue.
  17076. */
  17077. shadowsDensity: number;
  17078. /**
  17079. * Gets the shadows Saturation value.
  17080. * 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.
  17081. */
  17082. /**
  17083. * Sets the shadows Saturation value.
  17084. * 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.
  17085. */
  17086. shadowsSaturation: number;
  17087. /**
  17088. * Gets the shadows Exposure value.
  17089. * 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.
  17090. */
  17091. /**
  17092. * Sets the shadows Exposure value.
  17093. * 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.
  17094. */
  17095. shadowsExposure: number;
  17096. /**
  17097. * Returns the class name
  17098. * @returns The class name
  17099. */
  17100. getClassName(): string;
  17101. /**
  17102. * Binds the color curves to the shader.
  17103. * @param colorCurves The color curve to bind
  17104. * @param effect The effect to bind to
  17105. * @param positiveUniform The positive uniform shader parameter
  17106. * @param neutralUniform The neutral uniform shader parameter
  17107. * @param negativeUniform The negative uniform shader parameter
  17108. */
  17109. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  17110. /**
  17111. * Prepare the list of uniforms associated with the ColorCurves effects.
  17112. * @param uniformsList The list of uniforms used in the effect
  17113. */
  17114. static PrepareUniforms(uniformsList: string[]): void;
  17115. /**
  17116. * Returns color grading data based on a hue, density, saturation and exposure value.
  17117. * @param filterHue The hue of the color filter.
  17118. * @param filterDensity The density of the color filter.
  17119. * @param saturation The saturation.
  17120. * @param exposure The exposure.
  17121. * @param result The result data container.
  17122. */
  17123. private getColorGradingDataToRef;
  17124. /**
  17125. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  17126. * @param value The input slider value in range [-100,100].
  17127. * @returns Adjusted value.
  17128. */
  17129. private static applyColorGradingSliderNonlinear;
  17130. /**
  17131. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  17132. * @param hue The hue (H) input.
  17133. * @param saturation The saturation (S) input.
  17134. * @param brightness The brightness (B) input.
  17135. * @result An RGBA color represented as Vector4.
  17136. */
  17137. private static fromHSBToRef;
  17138. /**
  17139. * Returns a value clamped between min and max
  17140. * @param value The value to clamp
  17141. * @param min The minimum of value
  17142. * @param max The maximum of value
  17143. * @returns The clamped value.
  17144. */
  17145. private static clamp;
  17146. /**
  17147. * Clones the current color curve instance.
  17148. * @return The cloned curves
  17149. */
  17150. clone(): ColorCurves;
  17151. /**
  17152. * Serializes the current color curve instance to a json representation.
  17153. * @return a JSON representation
  17154. */
  17155. serialize(): any;
  17156. /**
  17157. * Parses the color curve from a json representation.
  17158. * @param source the JSON source to parse
  17159. * @return The parsed curves
  17160. */
  17161. static Parse(source: any): ColorCurves;
  17162. }
  17163. }
  17164. declare module BABYLON {
  17165. /**
  17166. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  17167. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  17168. */
  17169. class EffectFallbacks {
  17170. private _defines;
  17171. private _currentRank;
  17172. private _maxRank;
  17173. private _mesh;
  17174. /**
  17175. * Removes the fallback from the bound mesh.
  17176. */
  17177. unBindMesh(): void;
  17178. /**
  17179. * Adds a fallback on the specified property.
  17180. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  17181. * @param define The name of the define in the shader
  17182. */
  17183. addFallback(rank: number, define: string): void;
  17184. /**
  17185. * Sets the mesh to use CPU skinning when needing to fallback.
  17186. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  17187. * @param mesh The mesh to use the fallbacks.
  17188. */
  17189. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  17190. /**
  17191. * Checks to see if more fallbacks are still availible.
  17192. */
  17193. readonly isMoreFallbacks: boolean;
  17194. /**
  17195. * Removes the defines that shoould be removed when falling back.
  17196. * @param currentDefines defines the current define statements for the shader.
  17197. * @param effect defines the current effect we try to compile
  17198. * @returns The resulting defines with defines of the current rank removed.
  17199. */
  17200. reduce(currentDefines: string, effect: Effect): string;
  17201. }
  17202. /**
  17203. * Options to be used when creating an effect.
  17204. */
  17205. class EffectCreationOptions {
  17206. /**
  17207. * Atrributes that will be used in the shader.
  17208. */
  17209. attributes: string[];
  17210. /**
  17211. * Uniform varible names that will be set in the shader.
  17212. */
  17213. uniformsNames: string[];
  17214. /**
  17215. * Uniform buffer varible names that will be set in the shader.
  17216. */
  17217. uniformBuffersNames: string[];
  17218. /**
  17219. * Sampler texture variable names that will be set in the shader.
  17220. */
  17221. samplers: string[];
  17222. /**
  17223. * Define statements that will be set in the shader.
  17224. */
  17225. defines: any;
  17226. /**
  17227. * Possible fallbacks for this effect to improve performance when needed.
  17228. */
  17229. fallbacks: Nullable<EffectFallbacks>;
  17230. /**
  17231. * Callback that will be called when the shader is compiled.
  17232. */
  17233. onCompiled: Nullable<(effect: Effect) => void>;
  17234. /**
  17235. * Callback that will be called if an error occurs during shader compilation.
  17236. */
  17237. onError: Nullable<(effect: Effect, errors: string) => void>;
  17238. /**
  17239. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  17240. */
  17241. indexParameters: any;
  17242. /**
  17243. * Max number of lights that can be used in the shader.
  17244. */
  17245. maxSimultaneousLights: number;
  17246. /**
  17247. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  17248. */
  17249. transformFeedbackVaryings: Nullable<string[]>;
  17250. }
  17251. /**
  17252. * Effect containing vertex and fragment shader that can be executed on an object.
  17253. */
  17254. class Effect {
  17255. /**
  17256. * Name of the effect.
  17257. */
  17258. name: any;
  17259. /**
  17260. * String container all the define statements that should be set on the shader.
  17261. */
  17262. defines: string;
  17263. /**
  17264. * Callback that will be called when the shader is compiled.
  17265. */
  17266. onCompiled: Nullable<(effect: Effect) => void>;
  17267. /**
  17268. * Callback that will be called if an error occurs during shader compilation.
  17269. */
  17270. onError: Nullable<(effect: Effect, errors: string) => void>;
  17271. /**
  17272. * Callback that will be called when effect is bound.
  17273. */
  17274. onBind: Nullable<(effect: Effect) => void>;
  17275. /**
  17276. * Unique ID of the effect.
  17277. */
  17278. uniqueId: number;
  17279. /**
  17280. * Observable that will be called when the shader is compiled.
  17281. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  17282. */
  17283. onCompileObservable: Observable<Effect>;
  17284. /**
  17285. * Observable that will be called if an error occurs during shader compilation.
  17286. */
  17287. onErrorObservable: Observable<Effect>;
  17288. /** @hidden */
  17289. _onBindObservable: Nullable<Observable<Effect>>;
  17290. /**
  17291. * Observable that will be called when effect is bound.
  17292. */
  17293. readonly onBindObservable: Observable<Effect>;
  17294. /** @hidden */
  17295. _bonesComputationForcedToCPU: boolean;
  17296. private static _uniqueIdSeed;
  17297. private _engine;
  17298. private _uniformBuffersNames;
  17299. private _uniformsNames;
  17300. private _samplers;
  17301. private _isReady;
  17302. private _compilationError;
  17303. private _attributesNames;
  17304. private _attributes;
  17305. private _uniforms;
  17306. /**
  17307. * Key for the effect.
  17308. * @hidden
  17309. */
  17310. _key: string;
  17311. private _indexParameters;
  17312. private _fallbacks;
  17313. private _vertexSourceCode;
  17314. private _fragmentSourceCode;
  17315. private _vertexSourceCodeOverride;
  17316. private _fragmentSourceCodeOverride;
  17317. private _transformFeedbackVaryings;
  17318. /**
  17319. * Compiled shader to webGL program.
  17320. * @hidden
  17321. */
  17322. _program: WebGLProgram;
  17323. private _valueCache;
  17324. private static _baseCache;
  17325. /**
  17326. * Instantiates an effect.
  17327. * An effect can be used to create/manage/execute vertex and fragment shaders.
  17328. * @param baseName Name of the effect.
  17329. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  17330. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  17331. * @param samplers List of sampler variables that will be passed to the shader.
  17332. * @param engine Engine to be used to render the effect
  17333. * @param defines Define statements to be added to the shader.
  17334. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  17335. * @param onCompiled Callback that will be called when the shader is compiled.
  17336. * @param onError Callback that will be called if an error occurs during shader compilation.
  17337. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  17338. */
  17339. 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);
  17340. /**
  17341. * Unique key for this effect
  17342. */
  17343. readonly key: string;
  17344. /**
  17345. * If the effect has been compiled and prepared.
  17346. * @returns if the effect is compiled and prepared.
  17347. */
  17348. isReady(): boolean;
  17349. /**
  17350. * The engine the effect was initialized with.
  17351. * @returns the engine.
  17352. */
  17353. getEngine(): Engine;
  17354. /**
  17355. * The compiled webGL program for the effect
  17356. * @returns the webGL program.
  17357. */
  17358. getProgram(): WebGLProgram;
  17359. /**
  17360. * The set of names of attribute variables for the shader.
  17361. * @returns An array of attribute names.
  17362. */
  17363. getAttributesNames(): string[];
  17364. /**
  17365. * Returns the attribute at the given index.
  17366. * @param index The index of the attribute.
  17367. * @returns The location of the attribute.
  17368. */
  17369. getAttributeLocation(index: number): number;
  17370. /**
  17371. * Returns the attribute based on the name of the variable.
  17372. * @param name of the attribute to look up.
  17373. * @returns the attribute location.
  17374. */
  17375. getAttributeLocationByName(name: string): number;
  17376. /**
  17377. * The number of attributes.
  17378. * @returns the numnber of attributes.
  17379. */
  17380. getAttributesCount(): number;
  17381. /**
  17382. * Gets the index of a uniform variable.
  17383. * @param uniformName of the uniform to look up.
  17384. * @returns the index.
  17385. */
  17386. getUniformIndex(uniformName: string): number;
  17387. /**
  17388. * Returns the attribute based on the name of the variable.
  17389. * @param uniformName of the uniform to look up.
  17390. * @returns the location of the uniform.
  17391. */
  17392. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  17393. /**
  17394. * Returns an array of sampler variable names
  17395. * @returns The array of sampler variable neames.
  17396. */
  17397. getSamplers(): string[];
  17398. /**
  17399. * The error from the last compilation.
  17400. * @returns the error string.
  17401. */
  17402. getCompilationError(): string;
  17403. /**
  17404. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  17405. * @param func The callback to be used.
  17406. */
  17407. executeWhenCompiled(func: (effect: Effect) => void): void;
  17408. private _checkIsReady;
  17409. /** @hidden */
  17410. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  17411. /** @hidden */
  17412. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  17413. /** @hidden */
  17414. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  17415. private _processShaderConversion;
  17416. private _processIncludes;
  17417. private _processPrecision;
  17418. /**
  17419. * Recompiles the webGL program
  17420. * @param vertexSourceCode The source code for the vertex shader.
  17421. * @param fragmentSourceCode The source code for the fragment shader.
  17422. * @param onCompiled Callback called when completed.
  17423. * @param onError Callback called on error.
  17424. * @hidden
  17425. */
  17426. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  17427. /**
  17428. * Gets the uniform locations of the the specified variable names
  17429. * @param names THe names of the variables to lookup.
  17430. * @returns Array of locations in the same order as variable names.
  17431. */
  17432. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  17433. /**
  17434. * Prepares the effect
  17435. * @hidden
  17436. */
  17437. _prepareEffect(): void;
  17438. /**
  17439. * Checks if the effect is supported. (Must be called after compilation)
  17440. */
  17441. readonly isSupported: boolean;
  17442. /**
  17443. * Binds a texture to the engine to be used as output of the shader.
  17444. * @param channel Name of the output variable.
  17445. * @param texture Texture to bind.
  17446. * @hidden
  17447. */
  17448. _bindTexture(channel: string, texture: InternalTexture): void;
  17449. /**
  17450. * Sets a texture on the engine to be used in the shader.
  17451. * @param channel Name of the sampler variable.
  17452. * @param texture Texture to set.
  17453. */
  17454. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  17455. /**
  17456. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  17457. * @param channel Name of the sampler variable.
  17458. * @param texture Texture to set.
  17459. */
  17460. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  17461. /**
  17462. * Sets an array of textures on the engine to be used in the shader.
  17463. * @param channel Name of the variable.
  17464. * @param textures Textures to set.
  17465. */
  17466. setTextureArray(channel: string, textures: BaseTexture[]): void;
  17467. /**
  17468. * 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)
  17469. * @param channel Name of the sampler variable.
  17470. * @param postProcess Post process to get the input texture from.
  17471. */
  17472. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  17473. /**
  17474. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  17475. * 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)
  17476. * @param channel Name of the sampler variable.
  17477. * @param postProcess Post process to get the output texture from.
  17478. */
  17479. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  17480. /** @hidden */
  17481. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  17482. /** @hidden */
  17483. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  17484. /** @hidden */
  17485. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  17486. /** @hidden */
  17487. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  17488. /**
  17489. * Binds a buffer to a uniform.
  17490. * @param buffer Buffer to bind.
  17491. * @param name Name of the uniform variable to bind to.
  17492. */
  17493. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  17494. /**
  17495. * Binds block to a uniform.
  17496. * @param blockName Name of the block to bind.
  17497. * @param index Index to bind.
  17498. */
  17499. bindUniformBlock(blockName: string, index: number): void;
  17500. /**
  17501. * Sets an interger value on a uniform variable.
  17502. * @param uniformName Name of the variable.
  17503. * @param value Value to be set.
  17504. * @returns this effect.
  17505. */
  17506. setInt(uniformName: string, value: number): Effect;
  17507. /**
  17508. * Sets an int array on a uniform variable.
  17509. * @param uniformName Name of the variable.
  17510. * @param array array to be set.
  17511. * @returns this effect.
  17512. */
  17513. setIntArray(uniformName: string, array: Int32Array): Effect;
  17514. /**
  17515. * 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)
  17516. * @param uniformName Name of the variable.
  17517. * @param array array to be set.
  17518. * @returns this effect.
  17519. */
  17520. setIntArray2(uniformName: string, array: Int32Array): Effect;
  17521. /**
  17522. * 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)
  17523. * @param uniformName Name of the variable.
  17524. * @param array array to be set.
  17525. * @returns this effect.
  17526. */
  17527. setIntArray3(uniformName: string, array: Int32Array): Effect;
  17528. /**
  17529. * 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)
  17530. * @param uniformName Name of the variable.
  17531. * @param array array to be set.
  17532. * @returns this effect.
  17533. */
  17534. setIntArray4(uniformName: string, array: Int32Array): Effect;
  17535. /**
  17536. * Sets an float array on a uniform variable.
  17537. * @param uniformName Name of the variable.
  17538. * @param array array to be set.
  17539. * @returns this effect.
  17540. */
  17541. setFloatArray(uniformName: string, array: Float32Array): Effect;
  17542. /**
  17543. * 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)
  17544. * @param uniformName Name of the variable.
  17545. * @param array array to be set.
  17546. * @returns this effect.
  17547. */
  17548. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  17549. /**
  17550. * 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)
  17551. * @param uniformName Name of the variable.
  17552. * @param array array to be set.
  17553. * @returns this effect.
  17554. */
  17555. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  17556. /**
  17557. * 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)
  17558. * @param uniformName Name of the variable.
  17559. * @param array array to be set.
  17560. * @returns this effect.
  17561. */
  17562. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  17563. /**
  17564. * Sets an array on a uniform variable.
  17565. * @param uniformName Name of the variable.
  17566. * @param array array to be set.
  17567. * @returns this effect.
  17568. */
  17569. setArray(uniformName: string, array: number[]): Effect;
  17570. /**
  17571. * 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)
  17572. * @param uniformName Name of the variable.
  17573. * @param array array to be set.
  17574. * @returns this effect.
  17575. */
  17576. setArray2(uniformName: string, array: number[]): Effect;
  17577. /**
  17578. * 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)
  17579. * @param uniformName Name of the variable.
  17580. * @param array array to be set.
  17581. * @returns this effect.
  17582. */
  17583. setArray3(uniformName: string, array: number[]): Effect;
  17584. /**
  17585. * 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)
  17586. * @param uniformName Name of the variable.
  17587. * @param array array to be set.
  17588. * @returns this effect.
  17589. */
  17590. setArray4(uniformName: string, array: number[]): Effect;
  17591. /**
  17592. * Sets matrices on a uniform variable.
  17593. * @param uniformName Name of the variable.
  17594. * @param matrices matrices to be set.
  17595. * @returns this effect.
  17596. */
  17597. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  17598. /**
  17599. * Sets matrix on a uniform variable.
  17600. * @param uniformName Name of the variable.
  17601. * @param matrix matrix to be set.
  17602. * @returns this effect.
  17603. */
  17604. setMatrix(uniformName: string, matrix: Matrix): Effect;
  17605. /**
  17606. * 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)
  17607. * @param uniformName Name of the variable.
  17608. * @param matrix matrix to be set.
  17609. * @returns this effect.
  17610. */
  17611. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  17612. /**
  17613. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  17614. * @param uniformName Name of the variable.
  17615. * @param matrix matrix to be set.
  17616. * @returns this effect.
  17617. */
  17618. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  17619. /**
  17620. * Sets a float on a uniform variable.
  17621. * @param uniformName Name of the variable.
  17622. * @param value value to be set.
  17623. * @returns this effect.
  17624. */
  17625. setFloat(uniformName: string, value: number): Effect;
  17626. /**
  17627. * Sets a boolean on a uniform variable.
  17628. * @param uniformName Name of the variable.
  17629. * @param bool value to be set.
  17630. * @returns this effect.
  17631. */
  17632. setBool(uniformName: string, bool: boolean): Effect;
  17633. /**
  17634. * Sets a Vector2 on a uniform variable.
  17635. * @param uniformName Name of the variable.
  17636. * @param vector2 vector2 to be set.
  17637. * @returns this effect.
  17638. */
  17639. setVector2(uniformName: string, vector2: Vector2): Effect;
  17640. /**
  17641. * Sets a float2 on a uniform variable.
  17642. * @param uniformName Name of the variable.
  17643. * @param x First float in float2.
  17644. * @param y Second float in float2.
  17645. * @returns this effect.
  17646. */
  17647. setFloat2(uniformName: string, x: number, y: number): Effect;
  17648. /**
  17649. * Sets a Vector3 on a uniform variable.
  17650. * @param uniformName Name of the variable.
  17651. * @param vector3 Value to be set.
  17652. * @returns this effect.
  17653. */
  17654. setVector3(uniformName: string, vector3: Vector3): Effect;
  17655. /**
  17656. * Sets a float3 on a uniform variable.
  17657. * @param uniformName Name of the variable.
  17658. * @param x First float in float3.
  17659. * @param y Second float in float3.
  17660. * @param z Third float in float3.
  17661. * @returns this effect.
  17662. */
  17663. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  17664. /**
  17665. * Sets a Vector4 on a uniform variable.
  17666. * @param uniformName Name of the variable.
  17667. * @param vector4 Value to be set.
  17668. * @returns this effect.
  17669. */
  17670. setVector4(uniformName: string, vector4: Vector4): Effect;
  17671. /**
  17672. * Sets a float4 on a uniform variable.
  17673. * @param uniformName Name of the variable.
  17674. * @param x First float in float4.
  17675. * @param y Second float in float4.
  17676. * @param z Third float in float4.
  17677. * @param w Fourth float in float4.
  17678. * @returns this effect.
  17679. */
  17680. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  17681. /**
  17682. * Sets a Color3 on a uniform variable.
  17683. * @param uniformName Name of the variable.
  17684. * @param color3 Value to be set.
  17685. * @returns this effect.
  17686. */
  17687. setColor3(uniformName: string, color3: Color3): Effect;
  17688. /**
  17689. * Sets a Color4 on a uniform variable.
  17690. * @param uniformName Name of the variable.
  17691. * @param color3 Value to be set.
  17692. * @param alpha Alpha value to be set.
  17693. * @returns this effect.
  17694. */
  17695. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  17696. /**
  17697. * Sets a Color4 on a uniform variable
  17698. * @param uniformName defines the name of the variable
  17699. * @param color4 defines the value to be set
  17700. * @returns this effect.
  17701. */
  17702. setDirectColor4(uniformName: string, color4: Color4): Effect;
  17703. /**
  17704. * This function will add a new shader to the shader store
  17705. * @param name the name of the shader
  17706. * @param pixelShader optional pixel shader content
  17707. * @param vertexShader optional vertex shader content
  17708. */
  17709. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  17710. /**
  17711. * Store of each shader (The can be looked up using effect.key)
  17712. */
  17713. static ShadersStore: {
  17714. [key: string]: string;
  17715. };
  17716. /**
  17717. * Store of each included file for a shader (The can be looked up using effect.key)
  17718. */
  17719. static IncludesShadersStore: {
  17720. [key: string]: string;
  17721. };
  17722. /**
  17723. * Resets the cache of effects.
  17724. */
  17725. static ResetCache(): void;
  17726. }
  17727. }
  17728. declare module BABYLON {
  17729. /**
  17730. * This represents all the required information to add a fresnel effect on a material:
  17731. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  17732. */
  17733. class FresnelParameters {
  17734. private _isEnabled;
  17735. /**
  17736. * Define if the fresnel effect is enable or not.
  17737. */
  17738. isEnabled: boolean;
  17739. /**
  17740. * Define the color used on edges (grazing angle)
  17741. */
  17742. leftColor: Color3;
  17743. /**
  17744. * Define the color used on center
  17745. */
  17746. rightColor: Color3;
  17747. /**
  17748. * Define bias applied to computed fresnel term
  17749. */
  17750. bias: number;
  17751. /**
  17752. * Defined the power exponent applied to fresnel term
  17753. */
  17754. power: number;
  17755. /**
  17756. * Clones the current fresnel and its valuues
  17757. * @returns a clone fresnel configuration
  17758. */
  17759. clone(): FresnelParameters;
  17760. /**
  17761. * Serializes the current fresnel parameters to a JSON representation.
  17762. * @return the JSON serialization
  17763. */
  17764. serialize(): any;
  17765. /**
  17766. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  17767. * @param parsedFresnelParameters Define the JSON representation
  17768. * @returns the parsed parameters
  17769. */
  17770. static Parse(parsedFresnelParameters: any): FresnelParameters;
  17771. }
  17772. }
  17773. declare module BABYLON {
  17774. /**
  17775. * Interface to follow in your material defines to integrate easily the
  17776. * Image proccessing functions.
  17777. * @hidden
  17778. */
  17779. interface IImageProcessingConfigurationDefines {
  17780. IMAGEPROCESSING: boolean;
  17781. VIGNETTE: boolean;
  17782. VIGNETTEBLENDMODEMULTIPLY: boolean;
  17783. VIGNETTEBLENDMODEOPAQUE: boolean;
  17784. TONEMAPPING: boolean;
  17785. TONEMAPPING_ACES: boolean;
  17786. CONTRAST: boolean;
  17787. EXPOSURE: boolean;
  17788. COLORCURVES: boolean;
  17789. COLORGRADING: boolean;
  17790. COLORGRADING3D: boolean;
  17791. SAMPLER3DGREENDEPTH: boolean;
  17792. SAMPLER3DBGRMAP: boolean;
  17793. IMAGEPROCESSINGPOSTPROCESS: boolean;
  17794. }
  17795. /**
  17796. * @hidden
  17797. */
  17798. class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  17799. IMAGEPROCESSING: boolean;
  17800. VIGNETTE: boolean;
  17801. VIGNETTEBLENDMODEMULTIPLY: boolean;
  17802. VIGNETTEBLENDMODEOPAQUE: boolean;
  17803. TONEMAPPING: boolean;
  17804. TONEMAPPING_ACES: boolean;
  17805. CONTRAST: boolean;
  17806. COLORCURVES: boolean;
  17807. COLORGRADING: boolean;
  17808. COLORGRADING3D: boolean;
  17809. SAMPLER3DGREENDEPTH: boolean;
  17810. SAMPLER3DBGRMAP: boolean;
  17811. IMAGEPROCESSINGPOSTPROCESS: boolean;
  17812. EXPOSURE: boolean;
  17813. constructor();
  17814. }
  17815. /**
  17816. * This groups together the common properties used for image processing either in direct forward pass
  17817. * or through post processing effect depending on the use of the image processing pipeline in your scene
  17818. * or not.
  17819. */
  17820. class ImageProcessingConfiguration {
  17821. /**
  17822. * Default tone mapping applied in BabylonJS.
  17823. */
  17824. static readonly TONEMAPPING_STANDARD: number;
  17825. /**
  17826. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  17827. * to other engines rendering to increase portability.
  17828. */
  17829. static readonly TONEMAPPING_ACES: number;
  17830. /**
  17831. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  17832. */
  17833. colorCurves: Nullable<ColorCurves>;
  17834. private _colorCurvesEnabled;
  17835. /**
  17836. * Gets wether the color curves effect is enabled.
  17837. */
  17838. /**
  17839. * Sets wether the color curves effect is enabled.
  17840. */
  17841. colorCurvesEnabled: boolean;
  17842. private _colorGradingTexture;
  17843. /**
  17844. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  17845. */
  17846. /**
  17847. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  17848. */
  17849. colorGradingTexture: Nullable<BaseTexture>;
  17850. private _colorGradingEnabled;
  17851. /**
  17852. * Gets wether the color grading effect is enabled.
  17853. */
  17854. /**
  17855. * Sets wether the color grading effect is enabled.
  17856. */
  17857. colorGradingEnabled: boolean;
  17858. private _colorGradingWithGreenDepth;
  17859. /**
  17860. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  17861. */
  17862. /**
  17863. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  17864. */
  17865. colorGradingWithGreenDepth: boolean;
  17866. private _colorGradingBGR;
  17867. /**
  17868. * Gets wether the color grading texture contains BGR values.
  17869. */
  17870. /**
  17871. * Sets wether the color grading texture contains BGR values.
  17872. */
  17873. colorGradingBGR: boolean;
  17874. /** @hidden */
  17875. _exposure: number;
  17876. /**
  17877. * Gets the Exposure used in the effect.
  17878. */
  17879. /**
  17880. * Sets the Exposure used in the effect.
  17881. */
  17882. exposure: number;
  17883. private _toneMappingEnabled;
  17884. /**
  17885. * Gets wether the tone mapping effect is enabled.
  17886. */
  17887. /**
  17888. * Sets wether the tone mapping effect is enabled.
  17889. */
  17890. toneMappingEnabled: boolean;
  17891. private _toneMappingType;
  17892. /**
  17893. * Gets the type of tone mapping effect.
  17894. */
  17895. /**
  17896. * Sets the type of tone mapping effect used in BabylonJS.
  17897. */
  17898. toneMappingType: number;
  17899. protected _contrast: number;
  17900. /**
  17901. * Gets the contrast used in the effect.
  17902. */
  17903. /**
  17904. * Sets the contrast used in the effect.
  17905. */
  17906. contrast: number;
  17907. /**
  17908. * Vignette stretch size.
  17909. */
  17910. vignetteStretch: number;
  17911. /**
  17912. * Vignette centre X Offset.
  17913. */
  17914. vignetteCentreX: number;
  17915. /**
  17916. * Vignette centre Y Offset.
  17917. */
  17918. vignetteCentreY: number;
  17919. /**
  17920. * Vignette weight or intensity of the vignette effect.
  17921. */
  17922. vignetteWeight: number;
  17923. /**
  17924. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  17925. * if vignetteEnabled is set to true.
  17926. */
  17927. vignetteColor: Color4;
  17928. /**
  17929. * Camera field of view used by the Vignette effect.
  17930. */
  17931. vignetteCameraFov: number;
  17932. private _vignetteBlendMode;
  17933. /**
  17934. * Gets the vignette blend mode allowing different kind of effect.
  17935. */
  17936. /**
  17937. * Sets the vignette blend mode allowing different kind of effect.
  17938. */
  17939. vignetteBlendMode: number;
  17940. private _vignetteEnabled;
  17941. /**
  17942. * Gets wether the vignette effect is enabled.
  17943. */
  17944. /**
  17945. * Sets wether the vignette effect is enabled.
  17946. */
  17947. vignetteEnabled: boolean;
  17948. private _applyByPostProcess;
  17949. /**
  17950. * Gets wether the image processing is applied through a post process or not.
  17951. */
  17952. /**
  17953. * Sets wether the image processing is applied through a post process or not.
  17954. */
  17955. applyByPostProcess: boolean;
  17956. private _isEnabled;
  17957. /**
  17958. * Gets wether the image processing is enabled or not.
  17959. */
  17960. /**
  17961. * Sets wether the image processing is enabled or not.
  17962. */
  17963. isEnabled: boolean;
  17964. /**
  17965. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  17966. */
  17967. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  17968. /**
  17969. * Method called each time the image processing information changes requires to recompile the effect.
  17970. */
  17971. protected _updateParameters(): void;
  17972. /**
  17973. * Gets the current class name.
  17974. * @return "ImageProcessingConfiguration"
  17975. */
  17976. getClassName(): string;
  17977. /**
  17978. * Prepare the list of uniforms associated with the Image Processing effects.
  17979. * @param uniforms The list of uniforms used in the effect
  17980. * @param defines the list of defines currently in use
  17981. */
  17982. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  17983. /**
  17984. * Prepare the list of samplers associated with the Image Processing effects.
  17985. * @param samplersList The list of uniforms used in the effect
  17986. * @param defines the list of defines currently in use
  17987. */
  17988. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  17989. /**
  17990. * Prepare the list of defines associated to the shader.
  17991. * @param defines the list of defines to complete
  17992. * @param forPostProcess Define if we are currently in post process mode or not
  17993. */
  17994. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  17995. /**
  17996. * Returns true if all the image processing information are ready.
  17997. * @returns True if ready, otherwise, false
  17998. */
  17999. isReady(): boolean;
  18000. /**
  18001. * Binds the image processing to the shader.
  18002. * @param effect The effect to bind to
  18003. * @param aspectRatio Define the current aspect ratio of the effect
  18004. */
  18005. bind(effect: Effect, aspectRatio?: number): void;
  18006. /**
  18007. * Clones the current image processing instance.
  18008. * @return The cloned image processing
  18009. */
  18010. clone(): ImageProcessingConfiguration;
  18011. /**
  18012. * Serializes the current image processing instance to a json representation.
  18013. * @return a JSON representation
  18014. */
  18015. serialize(): any;
  18016. /**
  18017. * Parses the image processing from a json representation.
  18018. * @param source the JSON source to parse
  18019. * @return The parsed image processing
  18020. */
  18021. static Parse(source: any): ImageProcessingConfiguration;
  18022. private static _VIGNETTEMODE_MULTIPLY;
  18023. private static _VIGNETTEMODE_OPAQUE;
  18024. /**
  18025. * Used to apply the vignette as a mix with the pixel color.
  18026. */
  18027. static readonly VIGNETTEMODE_MULTIPLY: number;
  18028. /**
  18029. * Used to apply the vignette as a replacement of the pixel color.
  18030. */
  18031. static readonly VIGNETTEMODE_OPAQUE: number;
  18032. }
  18033. }
  18034. declare module BABYLON {
  18035. /**
  18036. * Manages the defines for the Material
  18037. */
  18038. class MaterialDefines {
  18039. private _keys;
  18040. private _isDirty;
  18041. /** @hidden */
  18042. _renderId: number;
  18043. /** @hidden */
  18044. _areLightsDirty: boolean;
  18045. /** @hidden */
  18046. _areAttributesDirty: boolean;
  18047. /** @hidden */
  18048. _areTexturesDirty: boolean;
  18049. /** @hidden */
  18050. _areFresnelDirty: boolean;
  18051. /** @hidden */
  18052. _areMiscDirty: boolean;
  18053. /** @hidden */
  18054. _areImageProcessingDirty: boolean;
  18055. /** @hidden */
  18056. _normals: boolean;
  18057. /** @hidden */
  18058. _uvs: boolean;
  18059. /** @hidden */
  18060. _needNormals: boolean;
  18061. /** @hidden */
  18062. _needUVs: boolean;
  18063. /**
  18064. * Specifies if the material needs to be re-calculated
  18065. */
  18066. readonly isDirty: boolean;
  18067. /**
  18068. * Marks the material to indicate that it has been re-calculated
  18069. */
  18070. markAsProcessed(): void;
  18071. /**
  18072. * Marks the material to indicate that it needs to be re-calculated
  18073. */
  18074. markAsUnprocessed(): void;
  18075. /**
  18076. * Marks the material to indicate all of its defines need to be re-calculated
  18077. */
  18078. markAllAsDirty(): void;
  18079. /**
  18080. * Marks the material to indicate that image processing needs to be re-calculated
  18081. */
  18082. markAsImageProcessingDirty(): void;
  18083. /**
  18084. * Marks the material to indicate the lights need to be re-calculated
  18085. */
  18086. markAsLightDirty(): void;
  18087. /**
  18088. * Marks the attribute state as changed
  18089. */
  18090. markAsAttributesDirty(): void;
  18091. /**
  18092. * Marks the texture state as changed
  18093. */
  18094. markAsTexturesDirty(): void;
  18095. /**
  18096. * Marks the fresnel state as changed
  18097. */
  18098. markAsFresnelDirty(): void;
  18099. /**
  18100. * Marks the misc state as changed
  18101. */
  18102. markAsMiscDirty(): void;
  18103. /**
  18104. * Rebuilds the material defines
  18105. */
  18106. rebuild(): void;
  18107. /**
  18108. * Specifies if two material defines are equal
  18109. * @param other - A material define instance to compare to
  18110. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  18111. */
  18112. isEqual(other: MaterialDefines): boolean;
  18113. /**
  18114. * Clones this instance's defines to another instance
  18115. * @param other - material defines to clone values to
  18116. */
  18117. cloneTo(other: MaterialDefines): void;
  18118. /**
  18119. * Resets the material define values
  18120. */
  18121. reset(): void;
  18122. /**
  18123. * Converts the material define values to a string
  18124. * @returns - String of material define information
  18125. */
  18126. toString(): string;
  18127. }
  18128. /**
  18129. * Base class for the main features of a material in Babylon.js
  18130. */
  18131. class Material implements IAnimatable {
  18132. private static _TriangleFillMode;
  18133. private static _WireFrameFillMode;
  18134. private static _PointFillMode;
  18135. private static _PointListDrawMode;
  18136. private static _LineListDrawMode;
  18137. private static _LineLoopDrawMode;
  18138. private static _LineStripDrawMode;
  18139. private static _TriangleStripDrawMode;
  18140. private static _TriangleFanDrawMode;
  18141. /**
  18142. * Returns the triangle fill mode
  18143. */
  18144. static readonly TriangleFillMode: number;
  18145. /**
  18146. * Returns the wireframe mode
  18147. */
  18148. static readonly WireFrameFillMode: number;
  18149. /**
  18150. * Returns the point fill mode
  18151. */
  18152. static readonly PointFillMode: number;
  18153. /**
  18154. * Returns the point list draw mode
  18155. */
  18156. static readonly PointListDrawMode: number;
  18157. /**
  18158. * Returns the line list draw mode
  18159. */
  18160. static readonly LineListDrawMode: number;
  18161. /**
  18162. * Returns the line loop draw mode
  18163. */
  18164. static readonly LineLoopDrawMode: number;
  18165. /**
  18166. * Returns the line strip draw mode
  18167. */
  18168. static readonly LineStripDrawMode: number;
  18169. /**
  18170. * Returns the triangle strip draw mode
  18171. */
  18172. static readonly TriangleStripDrawMode: number;
  18173. /**
  18174. * Returns the triangle fan draw mode
  18175. */
  18176. static readonly TriangleFanDrawMode: number;
  18177. /**
  18178. * Stores the clock-wise side orientation
  18179. */
  18180. private static _ClockWiseSideOrientation;
  18181. /**
  18182. * Stores the counter clock-wise side orientation
  18183. */
  18184. private static _CounterClockWiseSideOrientation;
  18185. /**
  18186. * Returns the clock-wise side orientation
  18187. */
  18188. static readonly ClockWiseSideOrientation: number;
  18189. /**
  18190. * Returns the counter clock-wise side orientation
  18191. */
  18192. static readonly CounterClockWiseSideOrientation: number;
  18193. /**
  18194. * The dirty texture flag value
  18195. */
  18196. static readonly TextureDirtyFlag: number;
  18197. /**
  18198. * The dirty light flag value
  18199. */
  18200. static readonly LightDirtyFlag: number;
  18201. /**
  18202. * The dirty fresnel flag value
  18203. */
  18204. static readonly FresnelDirtyFlag: number;
  18205. /**
  18206. * The dirty attribute flag value
  18207. */
  18208. static readonly AttributesDirtyFlag: number;
  18209. /**
  18210. * The dirty misc flag value
  18211. */
  18212. static readonly MiscDirtyFlag: number;
  18213. /**
  18214. * The all dirty flag value
  18215. */
  18216. static readonly AllDirtyFlag: number;
  18217. /**
  18218. * The ID of the material
  18219. */
  18220. id: string;
  18221. /**
  18222. * Gets or sets the unique id of the material
  18223. */
  18224. uniqueId: number;
  18225. /**
  18226. * The name of the material
  18227. */
  18228. name: string;
  18229. /**
  18230. * Gets or sets user defined metadata
  18231. */
  18232. metadata: any;
  18233. /**
  18234. * For internal use only. Please do not use.
  18235. */
  18236. reservedDataStore: any;
  18237. /**
  18238. * Specifies if the ready state should be checked on each call
  18239. */
  18240. checkReadyOnEveryCall: boolean;
  18241. /**
  18242. * Specifies if the ready state should be checked once
  18243. */
  18244. checkReadyOnlyOnce: boolean;
  18245. /**
  18246. * The state of the material
  18247. */
  18248. state: string;
  18249. /**
  18250. * The alpha value of the material
  18251. */
  18252. protected _alpha: number;
  18253. /**
  18254. * Sets the alpha value of the material
  18255. */
  18256. /**
  18257. * Gets the alpha value of the material
  18258. */
  18259. alpha: number;
  18260. /**
  18261. * Specifies if back face culling is enabled
  18262. */
  18263. protected _backFaceCulling: boolean;
  18264. /**
  18265. * Sets the back-face culling state
  18266. */
  18267. /**
  18268. * Gets the back-face culling state
  18269. */
  18270. backFaceCulling: boolean;
  18271. /**
  18272. * Stores the value for side orientation
  18273. */
  18274. sideOrientation: number;
  18275. /**
  18276. * Callback triggered when the material is compiled
  18277. */
  18278. onCompiled: (effect: Effect) => void;
  18279. /**
  18280. * Callback triggered when an error occurs
  18281. */
  18282. onError: (effect: Effect, errors: string) => void;
  18283. /**
  18284. * Callback triggered to get the render target textures
  18285. */
  18286. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  18287. /**
  18288. * Gets a boolean indicating that current material needs to register RTT
  18289. */
  18290. readonly hasRenderTargetTextures: boolean;
  18291. /**
  18292. * Specifies if the material should be serialized
  18293. */
  18294. doNotSerialize: boolean;
  18295. /**
  18296. * @hidden
  18297. */
  18298. _storeEffectOnSubMeshes: boolean;
  18299. /**
  18300. * Stores the animations for the material
  18301. */
  18302. animations: Array<Animation>;
  18303. /**
  18304. * An event triggered when the material is disposed
  18305. */
  18306. onDisposeObservable: Observable<Material>;
  18307. /**
  18308. * An observer which watches for dispose events
  18309. */
  18310. private _onDisposeObserver;
  18311. private _onUnBindObservable;
  18312. /**
  18313. * Called during a dispose event
  18314. */
  18315. onDispose: () => void;
  18316. private _onBindObservable;
  18317. /**
  18318. * An event triggered when the material is bound
  18319. */
  18320. readonly onBindObservable: Observable<AbstractMesh>;
  18321. /**
  18322. * An observer which watches for bind events
  18323. */
  18324. private _onBindObserver;
  18325. /**
  18326. * Called during a bind event
  18327. */
  18328. onBind: (Mesh: AbstractMesh) => void;
  18329. /**
  18330. * An event triggered when the material is unbound
  18331. */
  18332. readonly onUnBindObservable: Observable<Material>;
  18333. /**
  18334. * Stores the value of the alpha mode
  18335. */
  18336. private _alphaMode;
  18337. /**
  18338. * Sets the value of the alpha mode.
  18339. *
  18340. * | Value | Type | Description |
  18341. * | --- | --- | --- |
  18342. * | 0 | ALPHA_DISABLE | |
  18343. * | 1 | ALPHA_ADD | |
  18344. * | 2 | ALPHA_COMBINE | |
  18345. * | 3 | ALPHA_SUBTRACT | |
  18346. * | 4 | ALPHA_MULTIPLY | |
  18347. * | 5 | ALPHA_MAXIMIZED | |
  18348. * | 6 | ALPHA_ONEONE | |
  18349. * | 7 | ALPHA_PREMULTIPLIED | |
  18350. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  18351. * | 9 | ALPHA_INTERPOLATE | |
  18352. * | 10 | ALPHA_SCREENMODE | |
  18353. *
  18354. */
  18355. /**
  18356. * Gets the value of the alpha mode
  18357. */
  18358. alphaMode: number;
  18359. /**
  18360. * Stores the state of the need depth pre-pass value
  18361. */
  18362. private _needDepthPrePass;
  18363. /**
  18364. * Sets the need depth pre-pass value
  18365. */
  18366. /**
  18367. * Gets the depth pre-pass value
  18368. */
  18369. needDepthPrePass: boolean;
  18370. /**
  18371. * Specifies if depth writing should be disabled
  18372. */
  18373. disableDepthWrite: boolean;
  18374. /**
  18375. * Specifies if depth writing should be forced
  18376. */
  18377. forceDepthWrite: boolean;
  18378. /**
  18379. * Specifies if there should be a separate pass for culling
  18380. */
  18381. separateCullingPass: boolean;
  18382. /**
  18383. * Stores the state specifing if fog should be enabled
  18384. */
  18385. private _fogEnabled;
  18386. /**
  18387. * Sets the state for enabling fog
  18388. */
  18389. /**
  18390. * Gets the value of the fog enabled state
  18391. */
  18392. fogEnabled: boolean;
  18393. /**
  18394. * Stores the size of points
  18395. */
  18396. pointSize: number;
  18397. /**
  18398. * Stores the z offset value
  18399. */
  18400. zOffset: number;
  18401. /**
  18402. * Gets a value specifying if wireframe mode is enabled
  18403. */
  18404. /**
  18405. * Sets the state of wireframe mode
  18406. */
  18407. wireframe: boolean;
  18408. /**
  18409. * Gets the value specifying if point clouds are enabled
  18410. */
  18411. /**
  18412. * Sets the state of point cloud mode
  18413. */
  18414. pointsCloud: boolean;
  18415. /**
  18416. * Gets the material fill mode
  18417. */
  18418. /**
  18419. * Sets the material fill mode
  18420. */
  18421. fillMode: number;
  18422. /**
  18423. * @hidden
  18424. * Stores the effects for the material
  18425. */
  18426. _effect: Nullable<Effect>;
  18427. /**
  18428. * @hidden
  18429. * Specifies if the material was previously ready
  18430. */
  18431. _wasPreviouslyReady: boolean;
  18432. /**
  18433. * Specifies if uniform buffers should be used
  18434. */
  18435. private _useUBO;
  18436. /**
  18437. * Stores a reference to the scene
  18438. */
  18439. private _scene;
  18440. /**
  18441. * Stores the fill mode state
  18442. */
  18443. private _fillMode;
  18444. /**
  18445. * Specifies if the depth write state should be cached
  18446. */
  18447. private _cachedDepthWriteState;
  18448. /**
  18449. * Stores the uniform buffer
  18450. */
  18451. protected _uniformBuffer: UniformBuffer;
  18452. /** @hidden */
  18453. _indexInSceneMaterialArray: number;
  18454. /** @hidden */
  18455. meshMap: Nullable<{
  18456. [id: string]: AbstractMesh | undefined;
  18457. }>;
  18458. /**
  18459. * Creates a material instance
  18460. * @param name defines the name of the material
  18461. * @param scene defines the scene to reference
  18462. * @param doNotAdd specifies if the material should be added to the scene
  18463. */
  18464. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  18465. /**
  18466. * Returns a string representation of the current material
  18467. * @param fullDetails defines a boolean indicating which levels of logging is desired
  18468. * @returns a string with material information
  18469. */
  18470. toString(fullDetails?: boolean): string;
  18471. /**
  18472. * Gets the class name of the material
  18473. * @returns a string with the class name of the material
  18474. */
  18475. getClassName(): string;
  18476. /**
  18477. * Specifies if updates for the material been locked
  18478. */
  18479. readonly isFrozen: boolean;
  18480. /**
  18481. * Locks updates for the material
  18482. */
  18483. freeze(): void;
  18484. /**
  18485. * Unlocks updates for the material
  18486. */
  18487. unfreeze(): void;
  18488. /**
  18489. * Specifies if the material is ready to be used
  18490. * @param mesh defines the mesh to check
  18491. * @param useInstances specifies if instances should be used
  18492. * @returns a boolean indicating if the material is ready to be used
  18493. */
  18494. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  18495. /**
  18496. * Specifies that the submesh is ready to be used
  18497. * @param mesh defines the mesh to check
  18498. * @param subMesh defines which submesh to check
  18499. * @param useInstances specifies that instances should be used
  18500. * @returns a boolean indicating that the submesh is ready or not
  18501. */
  18502. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  18503. /**
  18504. * Returns the material effect
  18505. * @returns the effect associated with the material
  18506. */
  18507. getEffect(): Nullable<Effect>;
  18508. /**
  18509. * Returns the current scene
  18510. * @returns a Scene
  18511. */
  18512. getScene(): Scene;
  18513. /**
  18514. * Specifies if the material will require alpha blending
  18515. * @returns a boolean specifying if alpha blending is needed
  18516. */
  18517. needAlphaBlending(): boolean;
  18518. /**
  18519. * Specifies if the mesh will require alpha blending
  18520. * @param mesh defines the mesh to check
  18521. * @returns a boolean specifying if alpha blending is needed for the mesh
  18522. */
  18523. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  18524. /**
  18525. * Specifies if this material should be rendered in alpha test mode
  18526. * @returns a boolean specifying if an alpha test is needed.
  18527. */
  18528. needAlphaTesting(): boolean;
  18529. /**
  18530. * Gets the texture used for the alpha test
  18531. * @returns the texture to use for alpha testing
  18532. */
  18533. getAlphaTestTexture(): Nullable<BaseTexture>;
  18534. /**
  18535. * Marks the material to indicate that it needs to be re-calculated
  18536. */
  18537. markDirty(): void;
  18538. /** @hidden */
  18539. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  18540. /**
  18541. * Binds the material to the mesh
  18542. * @param world defines the world transformation matrix
  18543. * @param mesh defines the mesh to bind the material to
  18544. */
  18545. bind(world: Matrix, mesh?: Mesh): void;
  18546. /**
  18547. * Binds the submesh to the material
  18548. * @param world defines the world transformation matrix
  18549. * @param mesh defines the mesh containing the submesh
  18550. * @param subMesh defines the submesh to bind the material to
  18551. */
  18552. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  18553. /**
  18554. * Binds the world matrix to the material
  18555. * @param world defines the world transformation matrix
  18556. */
  18557. bindOnlyWorldMatrix(world: Matrix): void;
  18558. /**
  18559. * Binds the scene's uniform buffer to the effect.
  18560. * @param effect defines the effect to bind to the scene uniform buffer
  18561. * @param sceneUbo defines the uniform buffer storing scene data
  18562. */
  18563. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  18564. /**
  18565. * Binds the view matrix to the effect
  18566. * @param effect defines the effect to bind the view matrix to
  18567. */
  18568. bindView(effect: Effect): void;
  18569. /**
  18570. * Binds the view projection matrix to the effect
  18571. * @param effect defines the effect to bind the view projection matrix to
  18572. */
  18573. bindViewProjection(effect: Effect): void;
  18574. /**
  18575. * Specifies if material alpha testing should be turned on for the mesh
  18576. * @param mesh defines the mesh to check
  18577. */
  18578. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  18579. /**
  18580. * Processes to execute after binding the material to a mesh
  18581. * @param mesh defines the rendered mesh
  18582. */
  18583. protected _afterBind(mesh?: Mesh): void;
  18584. /**
  18585. * Unbinds the material from the mesh
  18586. */
  18587. unbind(): void;
  18588. /**
  18589. * Gets the active textures from the material
  18590. * @returns an array of textures
  18591. */
  18592. getActiveTextures(): BaseTexture[];
  18593. /**
  18594. * Specifies if the material uses a texture
  18595. * @param texture defines the texture to check against the material
  18596. * @returns a boolean specifying if the material uses the texture
  18597. */
  18598. hasTexture(texture: BaseTexture): boolean;
  18599. /**
  18600. * Makes a duplicate of the material, and gives it a new name
  18601. * @param name defines the new name for the duplicated material
  18602. * @returns the cloned material
  18603. */
  18604. clone(name: string): Nullable<Material>;
  18605. /**
  18606. * Gets the meshes bound to the material
  18607. * @returns an array of meshes bound to the material
  18608. */
  18609. getBindedMeshes(): AbstractMesh[];
  18610. /**
  18611. * Force shader compilation
  18612. * @param mesh defines the mesh associated with this material
  18613. * @param onCompiled defines a function to execute once the material is compiled
  18614. * @param options defines the options to configure the compilation
  18615. */
  18616. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  18617. clipPlane: boolean;
  18618. }>): void;
  18619. /**
  18620. * Force shader compilation
  18621. * @param mesh defines the mesh that will use this material
  18622. * @param options defines additional options for compiling the shaders
  18623. * @returns a promise that resolves when the compilation completes
  18624. */
  18625. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  18626. clipPlane: boolean;
  18627. }>): Promise<void>;
  18628. private static readonly _ImageProcessingDirtyCallBack;
  18629. private static readonly _TextureDirtyCallBack;
  18630. private static readonly _FresnelDirtyCallBack;
  18631. private static readonly _MiscDirtyCallBack;
  18632. private static readonly _LightsDirtyCallBack;
  18633. private static readonly _AttributeDirtyCallBack;
  18634. private static _FresnelAndMiscDirtyCallBack;
  18635. private static _TextureAndMiscDirtyCallBack;
  18636. private static readonly _DirtyCallbackArray;
  18637. private static readonly _RunDirtyCallBacks;
  18638. /**
  18639. * Marks a define in the material to indicate that it needs to be re-computed
  18640. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  18641. */
  18642. markAsDirty(flag: number): void;
  18643. /**
  18644. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  18645. * @param func defines a function which checks material defines against the submeshes
  18646. */
  18647. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  18648. /**
  18649. * Indicates that image processing needs to be re-calculated for all submeshes
  18650. */
  18651. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  18652. /**
  18653. * Indicates that textures need to be re-calculated for all submeshes
  18654. */
  18655. protected _markAllSubMeshesAsTexturesDirty(): void;
  18656. /**
  18657. * Indicates that fresnel needs to be re-calculated for all submeshes
  18658. */
  18659. protected _markAllSubMeshesAsFresnelDirty(): void;
  18660. /**
  18661. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  18662. */
  18663. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  18664. /**
  18665. * Indicates that lights need to be re-calculated for all submeshes
  18666. */
  18667. protected _markAllSubMeshesAsLightsDirty(): void;
  18668. /**
  18669. * Indicates that attributes need to be re-calculated for all submeshes
  18670. */
  18671. protected _markAllSubMeshesAsAttributesDirty(): void;
  18672. /**
  18673. * Indicates that misc needs to be re-calculated for all submeshes
  18674. */
  18675. protected _markAllSubMeshesAsMiscDirty(): void;
  18676. /**
  18677. * Indicates that textures and misc need to be re-calculated for all submeshes
  18678. */
  18679. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  18680. /**
  18681. * Disposes the material
  18682. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  18683. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  18684. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  18685. */
  18686. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  18687. /** @hidden */
  18688. private releaseVertexArrayObject;
  18689. /**
  18690. * Serializes this material
  18691. * @returns the serialized material object
  18692. */
  18693. serialize(): any;
  18694. /**
  18695. * Creates a MultiMaterial from parsed MultiMaterial data.
  18696. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  18697. * @param scene defines the hosting scene
  18698. * @returns a new MultiMaterial
  18699. */
  18700. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  18701. /**
  18702. * Creates a material from parsed material data
  18703. * @param parsedMaterial defines parsed material data
  18704. * @param scene defines the hosting scene
  18705. * @param rootUrl defines the root URL to use to load textures
  18706. * @returns a new material
  18707. */
  18708. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  18709. }
  18710. }
  18711. declare module BABYLON {
  18712. /**
  18713. * "Static Class" containing the most commonly used helper while dealing with material for
  18714. * rendering purpose.
  18715. *
  18716. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  18717. *
  18718. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  18719. */
  18720. class MaterialHelper {
  18721. /**
  18722. * Bind the current view position to an effect.
  18723. * @param effect The effect to be bound
  18724. * @param scene The scene the eyes position is used from
  18725. */
  18726. static BindEyePosition(effect: Effect, scene: Scene): void;
  18727. /**
  18728. * Helps preparing the defines values about the UVs in used in the effect.
  18729. * UVs are shared as much as we can accross channels in the shaders.
  18730. * @param texture The texture we are preparing the UVs for
  18731. * @param defines The defines to update
  18732. * @param key The channel key "diffuse", "specular"... used in the shader
  18733. */
  18734. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  18735. /**
  18736. * Binds a texture matrix value to its corrsponding uniform
  18737. * @param texture The texture to bind the matrix for
  18738. * @param uniformBuffer The uniform buffer receivin the data
  18739. * @param key The channel key "diffuse", "specular"... used in the shader
  18740. */
  18741. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  18742. /**
  18743. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  18744. * @param mesh defines the current mesh
  18745. * @param scene defines the current scene
  18746. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  18747. * @param pointsCloud defines if point cloud rendering has to be turned on
  18748. * @param fogEnabled defines if fog has to be turned on
  18749. * @param alphaTest defines if alpha testing has to be turned on
  18750. * @param defines defines the current list of defines
  18751. */
  18752. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  18753. /**
  18754. * Helper used to prepare the list of defines associated with frame values for shader compilation
  18755. * @param scene defines the current scene
  18756. * @param engine defines the current engine
  18757. * @param defines specifies the list of active defines
  18758. * @param useInstances defines if instances have to be turned on
  18759. * @param useClipPlane defines if clip plane have to be turned on
  18760. */
  18761. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  18762. /**
  18763. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  18764. * @param mesh The mesh containing the geometry data we will draw
  18765. * @param defines The defines to update
  18766. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  18767. * @param useBones Precise whether bones should be used or not (override mesh info)
  18768. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  18769. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  18770. * @returns false if defines are considered not dirty and have not been checked
  18771. */
  18772. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  18773. /**
  18774. * Prepares the defines related to the light information passed in parameter
  18775. * @param scene The scene we are intending to draw
  18776. * @param mesh The mesh the effect is compiling for
  18777. * @param defines The defines to update
  18778. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  18779. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  18780. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  18781. * @returns true if normals will be required for the rest of the effect
  18782. */
  18783. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  18784. /**
  18785. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  18786. * that won t be acctive due to defines being turned off.
  18787. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  18788. * @param samplersList The samplers list
  18789. * @param defines The defines helping in the list generation
  18790. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  18791. */
  18792. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  18793. /**
  18794. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  18795. * @param defines The defines to update while falling back
  18796. * @param fallbacks The authorized effect fallbacks
  18797. * @param maxSimultaneousLights The maximum number of lights allowed
  18798. * @param rank the current rank of the Effect
  18799. * @returns The newly affected rank
  18800. */
  18801. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  18802. /**
  18803. * Prepares the list of attributes required for morph targets according to the effect defines.
  18804. * @param attribs The current list of supported attribs
  18805. * @param mesh The mesh to prepare the morph targets attributes for
  18806. * @param defines The current Defines of the effect
  18807. */
  18808. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  18809. /**
  18810. * Prepares the list of attributes required for bones according to the effect defines.
  18811. * @param attribs The current list of supported attribs
  18812. * @param mesh The mesh to prepare the bones attributes for
  18813. * @param defines The current Defines of the effect
  18814. * @param fallbacks The current efffect fallback strategy
  18815. */
  18816. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  18817. /**
  18818. * Prepares the list of attributes required for instances according to the effect defines.
  18819. * @param attribs The current list of supported attribs
  18820. * @param defines The current Defines of the effect
  18821. */
  18822. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  18823. /**
  18824. * Binds the light shadow information to the effect for the given mesh.
  18825. * @param light The light containing the generator
  18826. * @param scene The scene the lights belongs to
  18827. * @param mesh The mesh we are binding the information to render
  18828. * @param lightIndex The light index in the effect used to render the mesh
  18829. * @param effect The effect we are binding the data to
  18830. */
  18831. static BindLightShadow(light: Light, scene: Scene, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  18832. /**
  18833. * Binds the light information to the effect.
  18834. * @param light The light containing the generator
  18835. * @param effect The effect we are binding the data to
  18836. * @param lightIndex The light index in the effect used to render
  18837. */
  18838. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  18839. /**
  18840. * Binds the lights information from the scene to the effect for the given mesh.
  18841. * @param scene The scene the lights belongs to
  18842. * @param mesh The mesh we are binding the information to render
  18843. * @param effect The effect we are binding the data to
  18844. * @param defines The generated defines for the effect
  18845. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  18846. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  18847. */
  18848. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  18849. private static _tempFogColor;
  18850. /**
  18851. * Binds the fog information from the scene to the effect for the given mesh.
  18852. * @param scene The scene the lights belongs to
  18853. * @param mesh The mesh we are binding the information to render
  18854. * @param effect The effect we are binding the data to
  18855. * @param linearSpace Defines if the fog effect is applied in linear space
  18856. */
  18857. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  18858. /**
  18859. * Binds the bones information from the mesh to the effect.
  18860. * @param mesh The mesh we are binding the information to render
  18861. * @param effect The effect we are binding the data to
  18862. */
  18863. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  18864. /**
  18865. * Binds the morph targets information from the mesh to the effect.
  18866. * @param abstractMesh The mesh we are binding the information to render
  18867. * @param effect The effect we are binding the data to
  18868. */
  18869. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  18870. /**
  18871. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  18872. * @param defines The generated defines used in the effect
  18873. * @param effect The effect we are binding the data to
  18874. * @param scene The scene we are willing to render with logarithmic scale for
  18875. */
  18876. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  18877. /**
  18878. * Binds the clip plane information from the scene to the effect.
  18879. * @param scene The scene the clip plane information are extracted from
  18880. * @param effect The effect we are binding the data to
  18881. */
  18882. static BindClipPlane(effect: Effect, scene: Scene): void;
  18883. }
  18884. }
  18885. declare module BABYLON {
  18886. /**
  18887. * A multi-material is used to apply different materials to different parts of the same object without the need of
  18888. * separate meshes. This can be use to improve performances.
  18889. * @see http://doc.babylonjs.com/how_to/multi_materials
  18890. */
  18891. class MultiMaterial extends Material {
  18892. private _subMaterials;
  18893. /**
  18894. * Gets or Sets the list of Materials used within the multi material.
  18895. * They need to be ordered according to the submeshes order in the associated mesh
  18896. */
  18897. subMaterials: Nullable<Material>[];
  18898. /**
  18899. * Function used to align with Node.getChildren()
  18900. * @returns the list of Materials used within the multi material
  18901. */
  18902. getChildren(): Nullable<Material>[];
  18903. /**
  18904. * Instantiates a new Multi Material
  18905. * A multi-material is used to apply different materials to different parts of the same object without the need of
  18906. * separate meshes. This can be use to improve performances.
  18907. * @see http://doc.babylonjs.com/how_to/multi_materials
  18908. * @param name Define the name in the scene
  18909. * @param scene Define the scene the material belongs to
  18910. */
  18911. constructor(name: string, scene: Scene);
  18912. private _hookArray;
  18913. /**
  18914. * Get one of the submaterial by its index in the submaterials array
  18915. * @param index The index to look the sub material at
  18916. * @returns The Material if the index has been defined
  18917. */
  18918. getSubMaterial(index: number): Nullable<Material>;
  18919. /**
  18920. * Get the list of active textures for the whole sub materials list.
  18921. * @returns All the textures that will be used during the rendering
  18922. */
  18923. getActiveTextures(): BaseTexture[];
  18924. /**
  18925. * Gets the current class name of the material e.g. "MultiMaterial"
  18926. * Mainly use in serialization.
  18927. * @returns the class name
  18928. */
  18929. getClassName(): string;
  18930. /**
  18931. * Checks if the material is ready to render the requested sub mesh
  18932. * @param mesh Define the mesh the submesh belongs to
  18933. * @param subMesh Define the sub mesh to look readyness for
  18934. * @param useInstances Define whether or not the material is used with instances
  18935. * @returns true if ready, otherwise false
  18936. */
  18937. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  18938. /**
  18939. * Clones the current material and its related sub materials
  18940. * @param name Define the name of the newly cloned material
  18941. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  18942. * @returns the cloned material
  18943. */
  18944. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  18945. /**
  18946. * Serializes the materials into a JSON representation.
  18947. * @returns the JSON representation
  18948. */
  18949. serialize(): any;
  18950. /**
  18951. * Dispose the material and release its associated resources
  18952. * @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)
  18953. * @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)
  18954. */
  18955. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  18956. }
  18957. }
  18958. declare module BABYLON {
  18959. /**
  18960. * Base class of materials working in push mode in babylon JS
  18961. * @hidden
  18962. */
  18963. class PushMaterial extends Material {
  18964. protected _activeEffect: Effect;
  18965. protected _normalMatrix: Matrix;
  18966. /**
  18967. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  18968. * This means that the material can keep using a previous shader while a new one is being compiled.
  18969. * This is mostly used when shader parallel compilation is supported (true by default)
  18970. */
  18971. allowShaderHotSwapping: boolean;
  18972. constructor(name: string, scene: Scene);
  18973. getEffect(): Effect;
  18974. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  18975. /**
  18976. * Binds the given world matrix to the active effect
  18977. *
  18978. * @param world the matrix to bind
  18979. */
  18980. bindOnlyWorldMatrix(world: Matrix): void;
  18981. /**
  18982. * Binds the given normal matrix to the active effect
  18983. *
  18984. * @param normalMatrix the matrix to bind
  18985. */
  18986. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  18987. bind(world: Matrix, mesh?: Mesh): void;
  18988. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  18989. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  18990. }
  18991. }
  18992. declare module BABYLON {
  18993. /**
  18994. * Defines the options associated with the creation of a shader material.
  18995. */
  18996. interface IShaderMaterialOptions {
  18997. /**
  18998. * Does the material work in alpha blend mode
  18999. */
  19000. needAlphaBlending: boolean;
  19001. /**
  19002. * Does the material work in alpha test mode
  19003. */
  19004. needAlphaTesting: boolean;
  19005. /**
  19006. * The list of attribute names used in the shader
  19007. */
  19008. attributes: string[];
  19009. /**
  19010. * The list of unifrom names used in the shader
  19011. */
  19012. uniforms: string[];
  19013. /**
  19014. * The list of UBO names used in the shader
  19015. */
  19016. uniformBuffers: string[];
  19017. /**
  19018. * The list of sampler names used in the shader
  19019. */
  19020. samplers: string[];
  19021. /**
  19022. * The list of defines used in the shader
  19023. */
  19024. defines: string[];
  19025. }
  19026. /**
  19027. * 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.
  19028. *
  19029. * This returned material effects how the mesh will look based on the code in the shaders.
  19030. *
  19031. * @see http://doc.babylonjs.com/how_to/shader_material
  19032. */
  19033. class ShaderMaterial extends Material {
  19034. private _shaderPath;
  19035. private _options;
  19036. private _textures;
  19037. private _textureArrays;
  19038. private _floats;
  19039. private _ints;
  19040. private _floatsArrays;
  19041. private _colors3;
  19042. private _colors3Arrays;
  19043. private _colors4;
  19044. private _vectors2;
  19045. private _vectors3;
  19046. private _vectors4;
  19047. private _matrices;
  19048. private _matrices3x3;
  19049. private _matrices2x2;
  19050. private _vectors2Arrays;
  19051. private _vectors3Arrays;
  19052. private _cachedWorldViewMatrix;
  19053. private _renderId;
  19054. /**
  19055. * Instantiate a new shader material.
  19056. * 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.
  19057. * This returned material effects how the mesh will look based on the code in the shaders.
  19058. * @see http://doc.babylonjs.com/how_to/shader_material
  19059. * @param name Define the name of the material in the scene
  19060. * @param scene Define the scene the material belongs to
  19061. * @param shaderPath Defines the route to the shader code in one of three ways:
  19062. * - object - { vertex: "custom", fragment: "custom" }, used with BABYLON.Effect.ShadersStore["customVertexShader"] and BABYLON.Effect.ShadersStore["customFragmentShader"]
  19063. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  19064. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19065. * @param options Define the options used to create the shader
  19066. */
  19067. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19068. /**
  19069. * Gets the current class name of the material e.g. "ShaderMaterial"
  19070. * Mainly use in serialization.
  19071. * @returns the class name
  19072. */
  19073. getClassName(): string;
  19074. /**
  19075. * Specifies if the material will require alpha blending
  19076. * @returns a boolean specifying if alpha blending is needed
  19077. */
  19078. needAlphaBlending(): boolean;
  19079. /**
  19080. * Specifies if this material should be rendered in alpha test mode
  19081. * @returns a boolean specifying if an alpha test is needed.
  19082. */
  19083. needAlphaTesting(): boolean;
  19084. private _checkUniform;
  19085. /**
  19086. * Set a texture in the shader.
  19087. * @param name Define the name of the uniform samplers as defined in the shader
  19088. * @param texture Define the texture to bind to this sampler
  19089. * @return the material itself allowing "fluent" like uniform updates
  19090. */
  19091. setTexture(name: string, texture: Texture): ShaderMaterial;
  19092. /**
  19093. * Set a texture array in the shader.
  19094. * @param name Define the name of the uniform sampler array as defined in the shader
  19095. * @param textures Define the list of textures to bind to this sampler
  19096. * @return the material itself allowing "fluent" like uniform updates
  19097. */
  19098. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19099. /**
  19100. * Set a float in the shader.
  19101. * @param name Define the name of the uniform as defined in the shader
  19102. * @param value Define the value to give to the uniform
  19103. * @return the material itself allowing "fluent" like uniform updates
  19104. */
  19105. setFloat(name: string, value: number): ShaderMaterial;
  19106. /**
  19107. * Set a int in the shader.
  19108. * @param name Define the name of the uniform as defined in the shader
  19109. * @param value Define the value to give to the uniform
  19110. * @return the material itself allowing "fluent" like uniform updates
  19111. */
  19112. setInt(name: string, value: number): ShaderMaterial;
  19113. /**
  19114. * Set an array of floats in the shader.
  19115. * @param name Define the name of the uniform as defined in the shader
  19116. * @param value Define the value to give to the uniform
  19117. * @return the material itself allowing "fluent" like uniform updates
  19118. */
  19119. setFloats(name: string, value: number[]): ShaderMaterial;
  19120. /**
  19121. * Set a vec3 in the shader from a Color3.
  19122. * @param name Define the name of the uniform as defined in the shader
  19123. * @param value Define the value to give to the uniform
  19124. * @return the material itself allowing "fluent" like uniform updates
  19125. */
  19126. setColor3(name: string, value: Color3): ShaderMaterial;
  19127. /**
  19128. * Set a vec3 array in the shader from a Color3 array.
  19129. * @param name Define the name of the uniform as defined in the shader
  19130. * @param value Define the value to give to the uniform
  19131. * @return the material itself allowing "fluent" like uniform updates
  19132. */
  19133. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19134. /**
  19135. * Set a vec4 in the shader from a Color4.
  19136. * @param name Define the name of the uniform as defined in the shader
  19137. * @param value Define the value to give to the uniform
  19138. * @return the material itself allowing "fluent" like uniform updates
  19139. */
  19140. setColor4(name: string, value: Color4): ShaderMaterial;
  19141. /**
  19142. * Set a vec2 in the shader from a Vector2.
  19143. * @param name Define the name of the uniform as defined in the shader
  19144. * @param value Define the value to give to the uniform
  19145. * @return the material itself allowing "fluent" like uniform updates
  19146. */
  19147. setVector2(name: string, value: Vector2): ShaderMaterial;
  19148. /**
  19149. * Set a vec3 in the shader from a Vector3.
  19150. * @param name Define the name of the uniform as defined in the shader
  19151. * @param value Define the value to give to the uniform
  19152. * @return the material itself allowing "fluent" like uniform updates
  19153. */
  19154. setVector3(name: string, value: Vector3): ShaderMaterial;
  19155. /**
  19156. * Set a vec4 in the shader from a Vector4.
  19157. * @param name Define the name of the uniform as defined in the shader
  19158. * @param value Define the value to give to the uniform
  19159. * @return the material itself allowing "fluent" like uniform updates
  19160. */
  19161. setVector4(name: string, value: Vector4): ShaderMaterial;
  19162. /**
  19163. * Set a mat4 in the shader from a Matrix.
  19164. * @param name Define the name of the uniform as defined in the shader
  19165. * @param value Define the value to give to the uniform
  19166. * @return the material itself allowing "fluent" like uniform updates
  19167. */
  19168. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19169. /**
  19170. * Set a mat3 in the shader from a Float32Array.
  19171. * @param name Define the name of the uniform as defined in the shader
  19172. * @param value Define the value to give to the uniform
  19173. * @return the material itself allowing "fluent" like uniform updates
  19174. */
  19175. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19176. /**
  19177. * Set a mat2 in the shader from a Float32Array.
  19178. * @param name Define the name of the uniform as defined in the shader
  19179. * @param value Define the value to give to the uniform
  19180. * @return the material itself allowing "fluent" like uniform updates
  19181. */
  19182. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19183. /**
  19184. * Set a vec2 array in the shader from a number array.
  19185. * @param name Define the name of the uniform as defined in the shader
  19186. * @param value Define the value to give to the uniform
  19187. * @return the material itself allowing "fluent" like uniform updates
  19188. */
  19189. setArray2(name: string, value: number[]): ShaderMaterial;
  19190. /**
  19191. * Set a vec3 array in the shader from a number array.
  19192. * @param name Define the name of the uniform as defined in the shader
  19193. * @param value Define the value to give to the uniform
  19194. * @return the material itself allowing "fluent" like uniform updates
  19195. */
  19196. setArray3(name: string, value: number[]): ShaderMaterial;
  19197. private _checkCache;
  19198. /**
  19199. * Checks if the material is ready to render the requested mesh
  19200. * @param mesh Define the mesh to render
  19201. * @param useInstances Define whether or not the material is used with instances
  19202. * @returns true if ready, otherwise false
  19203. */
  19204. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19205. /**
  19206. * Binds the world matrix to the material
  19207. * @param world defines the world transformation matrix
  19208. */
  19209. bindOnlyWorldMatrix(world: Matrix): void;
  19210. /**
  19211. * Binds the material to the mesh
  19212. * @param world defines the world transformation matrix
  19213. * @param mesh defines the mesh to bind the material to
  19214. */
  19215. bind(world: Matrix, mesh?: Mesh): void;
  19216. /**
  19217. * Gets the active textures from the material
  19218. * @returns an array of textures
  19219. */
  19220. getActiveTextures(): BaseTexture[];
  19221. /**
  19222. * Specifies if the material uses a texture
  19223. * @param texture defines the texture to check against the material
  19224. * @returns a boolean specifying if the material uses the texture
  19225. */
  19226. hasTexture(texture: BaseTexture): boolean;
  19227. /**
  19228. * Makes a duplicate of the material, and gives it a new name
  19229. * @param name defines the new name for the duplicated material
  19230. * @returns the cloned material
  19231. */
  19232. clone(name: string): ShaderMaterial;
  19233. /**
  19234. * Disposes the material
  19235. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19236. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19237. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19238. */
  19239. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19240. /**
  19241. * Serializes this material in a JSON representation
  19242. * @returns the serialized material object
  19243. */
  19244. serialize(): any;
  19245. /**
  19246. * Creates a shader material from parsed shader material data
  19247. * @param source defines the JSON represnetation of the material
  19248. * @param scene defines the hosting scene
  19249. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19250. * @returns a new material
  19251. */
  19252. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19253. }
  19254. }
  19255. declare module BABYLON {
  19256. /** @hidden */
  19257. class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  19258. MAINUV1: boolean;
  19259. MAINUV2: boolean;
  19260. DIFFUSE: boolean;
  19261. DIFFUSEDIRECTUV: number;
  19262. AMBIENT: boolean;
  19263. AMBIENTDIRECTUV: number;
  19264. OPACITY: boolean;
  19265. OPACITYDIRECTUV: number;
  19266. OPACITYRGB: boolean;
  19267. REFLECTION: boolean;
  19268. EMISSIVE: boolean;
  19269. EMISSIVEDIRECTUV: number;
  19270. SPECULAR: boolean;
  19271. SPECULARDIRECTUV: number;
  19272. BUMP: boolean;
  19273. BUMPDIRECTUV: number;
  19274. PARALLAX: boolean;
  19275. PARALLAXOCCLUSION: boolean;
  19276. SPECULAROVERALPHA: boolean;
  19277. CLIPPLANE: boolean;
  19278. CLIPPLANE2: boolean;
  19279. CLIPPLANE3: boolean;
  19280. CLIPPLANE4: boolean;
  19281. ALPHATEST: boolean;
  19282. DEPTHPREPASS: boolean;
  19283. ALPHAFROMDIFFUSE: boolean;
  19284. POINTSIZE: boolean;
  19285. FOG: boolean;
  19286. SPECULARTERM: boolean;
  19287. DIFFUSEFRESNEL: boolean;
  19288. OPACITYFRESNEL: boolean;
  19289. REFLECTIONFRESNEL: boolean;
  19290. REFRACTIONFRESNEL: boolean;
  19291. EMISSIVEFRESNEL: boolean;
  19292. FRESNEL: boolean;
  19293. NORMAL: boolean;
  19294. UV1: boolean;
  19295. UV2: boolean;
  19296. VERTEXCOLOR: boolean;
  19297. VERTEXALPHA: boolean;
  19298. NUM_BONE_INFLUENCERS: number;
  19299. BonesPerMesh: number;
  19300. BONETEXTURE: boolean;
  19301. INSTANCES: boolean;
  19302. GLOSSINESS: boolean;
  19303. ROUGHNESS: boolean;
  19304. EMISSIVEASILLUMINATION: boolean;
  19305. LINKEMISSIVEWITHDIFFUSE: boolean;
  19306. REFLECTIONFRESNELFROMSPECULAR: boolean;
  19307. LIGHTMAP: boolean;
  19308. LIGHTMAPDIRECTUV: number;
  19309. OBJECTSPACE_NORMALMAP: boolean;
  19310. USELIGHTMAPASSHADOWMAP: boolean;
  19311. REFLECTIONMAP_3D: boolean;
  19312. REFLECTIONMAP_SPHERICAL: boolean;
  19313. REFLECTIONMAP_PLANAR: boolean;
  19314. REFLECTIONMAP_CUBIC: boolean;
  19315. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  19316. REFLECTIONMAP_PROJECTION: boolean;
  19317. REFLECTIONMAP_SKYBOX: boolean;
  19318. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  19319. REFLECTIONMAP_EXPLICIT: boolean;
  19320. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  19321. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  19322. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  19323. INVERTCUBICMAP: boolean;
  19324. LOGARITHMICDEPTH: boolean;
  19325. REFRACTION: boolean;
  19326. REFRACTIONMAP_3D: boolean;
  19327. REFLECTIONOVERALPHA: boolean;
  19328. TWOSIDEDLIGHTING: boolean;
  19329. SHADOWFLOAT: boolean;
  19330. MORPHTARGETS: boolean;
  19331. MORPHTARGETS_NORMAL: boolean;
  19332. MORPHTARGETS_TANGENT: boolean;
  19333. NUM_MORPH_INFLUENCERS: number;
  19334. NONUNIFORMSCALING: boolean;
  19335. PREMULTIPLYALPHA: boolean;
  19336. IMAGEPROCESSING: boolean;
  19337. VIGNETTE: boolean;
  19338. VIGNETTEBLENDMODEMULTIPLY: boolean;
  19339. VIGNETTEBLENDMODEOPAQUE: boolean;
  19340. TONEMAPPING: boolean;
  19341. TONEMAPPING_ACES: boolean;
  19342. CONTRAST: boolean;
  19343. COLORCURVES: boolean;
  19344. COLORGRADING: boolean;
  19345. COLORGRADING3D: boolean;
  19346. SAMPLER3DGREENDEPTH: boolean;
  19347. SAMPLER3DBGRMAP: boolean;
  19348. IMAGEPROCESSINGPOSTPROCESS: boolean;
  19349. /**
  19350. * If the reflection texture on this material is in linear color space
  19351. * @hidden
  19352. */
  19353. IS_REFLECTION_LINEAR: boolean;
  19354. /**
  19355. * If the refraction texture on this material is in linear color space
  19356. * @hidden
  19357. */
  19358. IS_REFRACTION_LINEAR: boolean;
  19359. EXPOSURE: boolean;
  19360. constructor();
  19361. setReflectionMode(modeToEnable: string): void;
  19362. }
  19363. /**
  19364. * This is the default material used in Babylon. It is the best trade off between quality
  19365. * and performances.
  19366. * @see http://doc.babylonjs.com/babylon101/materials
  19367. */
  19368. class StandardMaterial extends PushMaterial {
  19369. private _diffuseTexture;
  19370. /**
  19371. * The basic texture of the material as viewed under a light.
  19372. */
  19373. diffuseTexture: Nullable<BaseTexture>;
  19374. private _ambientTexture;
  19375. /**
  19376. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  19377. */
  19378. ambientTexture: Nullable<BaseTexture>;
  19379. private _opacityTexture;
  19380. /**
  19381. * Define the transparency of the material from a texture.
  19382. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  19383. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  19384. */
  19385. opacityTexture: Nullable<BaseTexture>;
  19386. private _reflectionTexture;
  19387. /**
  19388. * Define the texture used to display the reflection.
  19389. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19390. */
  19391. reflectionTexture: Nullable<BaseTexture>;
  19392. private _emissiveTexture;
  19393. /**
  19394. * Define texture of the material as if self lit.
  19395. * This will be mixed in the final result even in the absence of light.
  19396. */
  19397. emissiveTexture: Nullable<BaseTexture>;
  19398. private _specularTexture;
  19399. /**
  19400. * Define how the color and intensity of the highlight given by the light in the material.
  19401. */
  19402. specularTexture: Nullable<BaseTexture>;
  19403. private _bumpTexture;
  19404. /**
  19405. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  19406. * 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.
  19407. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  19408. */
  19409. bumpTexture: Nullable<BaseTexture>;
  19410. private _lightmapTexture;
  19411. /**
  19412. * Complex lighting can be computationally expensive to compute at runtime.
  19413. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  19414. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  19415. */
  19416. lightmapTexture: Nullable<BaseTexture>;
  19417. private _refractionTexture;
  19418. /**
  19419. * Define the texture used to display the refraction.
  19420. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19421. */
  19422. refractionTexture: Nullable<BaseTexture>;
  19423. /**
  19424. * The color of the material lit by the environmental background lighting.
  19425. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  19426. */
  19427. ambientColor: Color3;
  19428. /**
  19429. * The basic color of the material as viewed under a light.
  19430. */
  19431. diffuseColor: Color3;
  19432. /**
  19433. * Define how the color and intensity of the highlight given by the light in the material.
  19434. */
  19435. specularColor: Color3;
  19436. /**
  19437. * Define the color of the material as if self lit.
  19438. * This will be mixed in the final result even in the absence of light.
  19439. */
  19440. emissiveColor: Color3;
  19441. /**
  19442. * Defines how sharp are the highlights in the material.
  19443. * The bigger the value the sharper giving a more glossy feeling to the result.
  19444. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  19445. */
  19446. specularPower: number;
  19447. private _useAlphaFromDiffuseTexture;
  19448. /**
  19449. * Does the transparency come from the diffuse texture alpha channel.
  19450. */
  19451. useAlphaFromDiffuseTexture: boolean;
  19452. private _useEmissiveAsIllumination;
  19453. /**
  19454. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  19455. */
  19456. useEmissiveAsIllumination: boolean;
  19457. private _linkEmissiveWithDiffuse;
  19458. /**
  19459. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  19460. * the emissive level when the final color is close to one.
  19461. */
  19462. linkEmissiveWithDiffuse: boolean;
  19463. private _useSpecularOverAlpha;
  19464. /**
  19465. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  19466. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  19467. */
  19468. useSpecularOverAlpha: boolean;
  19469. private _useReflectionOverAlpha;
  19470. /**
  19471. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  19472. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  19473. */
  19474. useReflectionOverAlpha: boolean;
  19475. private _disableLighting;
  19476. /**
  19477. * Does lights from the scene impacts this material.
  19478. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  19479. */
  19480. disableLighting: boolean;
  19481. private _useObjectSpaceNormalMap;
  19482. /**
  19483. * Allows using an object space normal map (instead of tangent space).
  19484. */
  19485. useObjectSpaceNormalMap: boolean;
  19486. private _useParallax;
  19487. /**
  19488. * Is parallax enabled or not.
  19489. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  19490. */
  19491. useParallax: boolean;
  19492. private _useParallaxOcclusion;
  19493. /**
  19494. * Is parallax occlusion enabled or not.
  19495. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  19496. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  19497. */
  19498. useParallaxOcclusion: boolean;
  19499. /**
  19500. * 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.
  19501. */
  19502. parallaxScaleBias: number;
  19503. private _roughness;
  19504. /**
  19505. * Helps to define how blurry the reflections should appears in the material.
  19506. */
  19507. roughness: number;
  19508. /**
  19509. * In case of refraction, define the value of the indice of refraction.
  19510. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19511. */
  19512. indexOfRefraction: number;
  19513. /**
  19514. * Invert the refraction texture alongside the y axis.
  19515. * It can be useful with procedural textures or probe for instance.
  19516. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19517. */
  19518. invertRefractionY: boolean;
  19519. /**
  19520. * Defines the alpha limits in alpha test mode.
  19521. */
  19522. alphaCutOff: number;
  19523. private _useLightmapAsShadowmap;
  19524. /**
  19525. * In case of light mapping, define whether the map contains light or shadow informations.
  19526. */
  19527. useLightmapAsShadowmap: boolean;
  19528. private _diffuseFresnelParameters;
  19529. /**
  19530. * Define the diffuse fresnel parameters of the material.
  19531. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19532. */
  19533. diffuseFresnelParameters: FresnelParameters;
  19534. private _opacityFresnelParameters;
  19535. /**
  19536. * Define the opacity fresnel parameters of the material.
  19537. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19538. */
  19539. opacityFresnelParameters: FresnelParameters;
  19540. private _reflectionFresnelParameters;
  19541. /**
  19542. * Define the reflection fresnel parameters of the material.
  19543. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19544. */
  19545. reflectionFresnelParameters: FresnelParameters;
  19546. private _refractionFresnelParameters;
  19547. /**
  19548. * Define the refraction fresnel parameters of the material.
  19549. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19550. */
  19551. refractionFresnelParameters: FresnelParameters;
  19552. private _emissiveFresnelParameters;
  19553. /**
  19554. * Define the emissive fresnel parameters of the material.
  19555. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19556. */
  19557. emissiveFresnelParameters: FresnelParameters;
  19558. private _useReflectionFresnelFromSpecular;
  19559. /**
  19560. * If true automatically deducts the fresnels values from the material specularity.
  19561. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19562. */
  19563. useReflectionFresnelFromSpecular: boolean;
  19564. private _useGlossinessFromSpecularMapAlpha;
  19565. /**
  19566. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  19567. */
  19568. useGlossinessFromSpecularMapAlpha: boolean;
  19569. private _maxSimultaneousLights;
  19570. /**
  19571. * Defines the maximum number of lights that can be used in the material
  19572. */
  19573. maxSimultaneousLights: number;
  19574. private _invertNormalMapX;
  19575. /**
  19576. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  19577. */
  19578. invertNormalMapX: boolean;
  19579. private _invertNormalMapY;
  19580. /**
  19581. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  19582. */
  19583. invertNormalMapY: boolean;
  19584. private _twoSidedLighting;
  19585. /**
  19586. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  19587. */
  19588. twoSidedLighting: boolean;
  19589. /**
  19590. * Default configuration related to image processing available in the standard Material.
  19591. */
  19592. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  19593. /**
  19594. * Gets the image processing configuration used either in this material.
  19595. */
  19596. /**
  19597. * Sets the Default image processing configuration used either in the this material.
  19598. *
  19599. * If sets to null, the scene one is in use.
  19600. */
  19601. imageProcessingConfiguration: ImageProcessingConfiguration;
  19602. /**
  19603. * Keep track of the image processing observer to allow dispose and replace.
  19604. */
  19605. private _imageProcessingObserver;
  19606. /**
  19607. * Attaches a new image processing configuration to the Standard Material.
  19608. * @param configuration
  19609. */
  19610. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  19611. /**
  19612. * Gets wether the color curves effect is enabled.
  19613. */
  19614. /**
  19615. * Sets wether the color curves effect is enabled.
  19616. */
  19617. cameraColorCurvesEnabled: boolean;
  19618. /**
  19619. * Gets wether the color grading effect is enabled.
  19620. */
  19621. /**
  19622. * Gets wether the color grading effect is enabled.
  19623. */
  19624. cameraColorGradingEnabled: boolean;
  19625. /**
  19626. * Gets wether tonemapping is enabled or not.
  19627. */
  19628. /**
  19629. * Sets wether tonemapping is enabled or not
  19630. */
  19631. cameraToneMappingEnabled: boolean;
  19632. /**
  19633. * The camera exposure used on this material.
  19634. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  19635. * This corresponds to a photographic exposure.
  19636. */
  19637. /**
  19638. * The camera exposure used on this material.
  19639. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  19640. * This corresponds to a photographic exposure.
  19641. */
  19642. cameraExposure: number;
  19643. /**
  19644. * Gets The camera contrast used on this material.
  19645. */
  19646. /**
  19647. * Sets The camera contrast used on this material.
  19648. */
  19649. cameraContrast: number;
  19650. /**
  19651. * Gets the Color Grading 2D Lookup Texture.
  19652. */
  19653. /**
  19654. * Sets the Color Grading 2D Lookup Texture.
  19655. */
  19656. cameraColorGradingTexture: Nullable<BaseTexture>;
  19657. /**
  19658. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  19659. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  19660. * 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;
  19661. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  19662. */
  19663. /**
  19664. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  19665. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  19666. * 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;
  19667. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  19668. */
  19669. cameraColorCurves: Nullable<ColorCurves>;
  19670. /**
  19671. * Custom callback helping to override the default shader used in the material.
  19672. */
  19673. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  19674. protected _renderTargets: SmartArray<RenderTargetTexture>;
  19675. protected _worldViewProjectionMatrix: Matrix;
  19676. protected _globalAmbientColor: Color3;
  19677. protected _useLogarithmicDepth: boolean;
  19678. /**
  19679. * Instantiates a new standard material.
  19680. * This is the default material used in Babylon. It is the best trade off between quality
  19681. * and performances.
  19682. * @see http://doc.babylonjs.com/babylon101/materials
  19683. * @param name Define the name of the material in the scene
  19684. * @param scene Define the scene the material belong to
  19685. */
  19686. constructor(name: string, scene: Scene);
  19687. /**
  19688. * Gets a boolean indicating that current material needs to register RTT
  19689. */
  19690. readonly hasRenderTargetTextures: boolean;
  19691. /**
  19692. * Gets the current class name of the material e.g. "StandardMaterial"
  19693. * Mainly use in serialization.
  19694. * @returns the class name
  19695. */
  19696. getClassName(): string;
  19697. /**
  19698. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  19699. * You can try switching to logarithmic depth.
  19700. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  19701. */
  19702. useLogarithmicDepth: boolean;
  19703. /**
  19704. * Specifies if the material will require alpha blending
  19705. * @returns a boolean specifying if alpha blending is needed
  19706. */
  19707. needAlphaBlending(): boolean;
  19708. /**
  19709. * Specifies if this material should be rendered in alpha test mode
  19710. * @returns a boolean specifying if an alpha test is needed.
  19711. */
  19712. needAlphaTesting(): boolean;
  19713. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  19714. /**
  19715. * Get the texture used for alpha test purpose.
  19716. * @returns the diffuse texture in case of the standard material.
  19717. */
  19718. getAlphaTestTexture(): Nullable<BaseTexture>;
  19719. /**
  19720. * Get if the submesh is ready to be used and all its information available.
  19721. * Child classes can use it to update shaders
  19722. * @param mesh defines the mesh to check
  19723. * @param subMesh defines which submesh to check
  19724. * @param useInstances specifies that instances should be used
  19725. * @returns a boolean indicating that the submesh is ready or not
  19726. */
  19727. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  19728. /**
  19729. * Builds the material UBO layouts.
  19730. * Used internally during the effect preparation.
  19731. */
  19732. buildUniformLayout(): void;
  19733. /**
  19734. * Unbinds the material from the mesh
  19735. */
  19736. unbind(): void;
  19737. /**
  19738. * Binds the submesh to this material by preparing the effect and shader to draw
  19739. * @param world defines the world transformation matrix
  19740. * @param mesh defines the mesh containing the submesh
  19741. * @param subMesh defines the submesh to bind the material to
  19742. */
  19743. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  19744. /**
  19745. * Get the list of animatables in the material.
  19746. * @returns the list of animatables object used in the material
  19747. */
  19748. getAnimatables(): IAnimatable[];
  19749. /**
  19750. * Gets the active textures from the material
  19751. * @returns an array of textures
  19752. */
  19753. getActiveTextures(): BaseTexture[];
  19754. /**
  19755. * Specifies if the material uses a texture
  19756. * @param texture defines the texture to check against the material
  19757. * @returns a boolean specifying if the material uses the texture
  19758. */
  19759. hasTexture(texture: BaseTexture): boolean;
  19760. /**
  19761. * Disposes the material
  19762. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19763. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19764. */
  19765. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  19766. /**
  19767. * Makes a duplicate of the material, and gives it a new name
  19768. * @param name defines the new name for the duplicated material
  19769. * @returns the cloned material
  19770. */
  19771. clone(name: string): StandardMaterial;
  19772. /**
  19773. * Serializes this material in a JSON representation
  19774. * @returns the serialized material object
  19775. */
  19776. serialize(): any;
  19777. /**
  19778. * Creates a standard material from parsed material data
  19779. * @param source defines the JSON represnetation of the material
  19780. * @param scene defines the hosting scene
  19781. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19782. * @returns a new material
  19783. */
  19784. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  19785. private static _DiffuseTextureEnabled;
  19786. /**
  19787. * Are diffuse textures enabled in the application.
  19788. */
  19789. static DiffuseTextureEnabled: boolean;
  19790. private static _AmbientTextureEnabled;
  19791. /**
  19792. * Are ambient textures enabled in the application.
  19793. */
  19794. static AmbientTextureEnabled: boolean;
  19795. private static _OpacityTextureEnabled;
  19796. /**
  19797. * Are opacity textures enabled in the application.
  19798. */
  19799. static OpacityTextureEnabled: boolean;
  19800. private static _ReflectionTextureEnabled;
  19801. /**
  19802. * Are reflection textures enabled in the application.
  19803. */
  19804. static ReflectionTextureEnabled: boolean;
  19805. private static _EmissiveTextureEnabled;
  19806. /**
  19807. * Are emissive textures enabled in the application.
  19808. */
  19809. static EmissiveTextureEnabled: boolean;
  19810. private static _SpecularTextureEnabled;
  19811. /**
  19812. * Are specular textures enabled in the application.
  19813. */
  19814. static SpecularTextureEnabled: boolean;
  19815. private static _BumpTextureEnabled;
  19816. /**
  19817. * Are bump textures enabled in the application.
  19818. */
  19819. static BumpTextureEnabled: boolean;
  19820. private static _LightmapTextureEnabled;
  19821. /**
  19822. * Are lightmap textures enabled in the application.
  19823. */
  19824. static LightmapTextureEnabled: boolean;
  19825. private static _RefractionTextureEnabled;
  19826. /**
  19827. * Are refraction textures enabled in the application.
  19828. */
  19829. static RefractionTextureEnabled: boolean;
  19830. private static _ColorGradingTextureEnabled;
  19831. /**
  19832. * Are color grading textures enabled in the application.
  19833. */
  19834. static ColorGradingTextureEnabled: boolean;
  19835. private static _FresnelEnabled;
  19836. /**
  19837. * Are fresnels enabled in the application.
  19838. */
  19839. static FresnelEnabled: boolean;
  19840. }
  19841. }
  19842. declare module BABYLON {
  19843. /**
  19844. * Uniform buffer objects.
  19845. *
  19846. * Handles blocks of uniform on the GPU.
  19847. *
  19848. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  19849. *
  19850. * For more information, please refer to :
  19851. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  19852. */
  19853. class UniformBuffer {
  19854. private _engine;
  19855. private _buffer;
  19856. private _data;
  19857. private _bufferData;
  19858. private _dynamic?;
  19859. private _uniformLocations;
  19860. private _uniformSizes;
  19861. private _uniformLocationPointer;
  19862. private _needSync;
  19863. private _noUBO;
  19864. private _currentEffect;
  19865. private static _MAX_UNIFORM_SIZE;
  19866. private static _tempBuffer;
  19867. /**
  19868. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  19869. * This is dynamic to allow compat with webgl 1 and 2.
  19870. * You will need to pass the name of the uniform as well as the value.
  19871. */
  19872. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  19873. /**
  19874. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  19875. * This is dynamic to allow compat with webgl 1 and 2.
  19876. * You will need to pass the name of the uniform as well as the value.
  19877. */
  19878. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  19879. /**
  19880. * Lambda to Update a single float in a uniform buffer.
  19881. * This is dynamic to allow compat with webgl 1 and 2.
  19882. * You will need to pass the name of the uniform as well as the value.
  19883. */
  19884. updateFloat: (name: string, x: number) => void;
  19885. /**
  19886. * Lambda to Update a vec2 of float in a uniform buffer.
  19887. * This is dynamic to allow compat with webgl 1 and 2.
  19888. * You will need to pass the name of the uniform as well as the value.
  19889. */
  19890. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  19891. /**
  19892. * Lambda to Update a vec3 of float in a uniform buffer.
  19893. * This is dynamic to allow compat with webgl 1 and 2.
  19894. * You will need to pass the name of the uniform as well as the value.
  19895. */
  19896. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  19897. /**
  19898. * Lambda to Update a vec4 of float in a uniform buffer.
  19899. * This is dynamic to allow compat with webgl 1 and 2.
  19900. * You will need to pass the name of the uniform as well as the value.
  19901. */
  19902. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  19903. /**
  19904. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  19905. * This is dynamic to allow compat with webgl 1 and 2.
  19906. * You will need to pass the name of the uniform as well as the value.
  19907. */
  19908. updateMatrix: (name: string, mat: Matrix) => void;
  19909. /**
  19910. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  19911. * This is dynamic to allow compat with webgl 1 and 2.
  19912. * You will need to pass the name of the uniform as well as the value.
  19913. */
  19914. updateVector3: (name: string, vector: Vector3) => void;
  19915. /**
  19916. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  19917. * This is dynamic to allow compat with webgl 1 and 2.
  19918. * You will need to pass the name of the uniform as well as the value.
  19919. */
  19920. updateVector4: (name: string, vector: Vector4) => void;
  19921. /**
  19922. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  19923. * This is dynamic to allow compat with webgl 1 and 2.
  19924. * You will need to pass the name of the uniform as well as the value.
  19925. */
  19926. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  19927. /**
  19928. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  19929. * This is dynamic to allow compat with webgl 1 and 2.
  19930. * You will need to pass the name of the uniform as well as the value.
  19931. */
  19932. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  19933. /**
  19934. * Instantiates a new Uniform buffer objects.
  19935. *
  19936. * Handles blocks of uniform on the GPU.
  19937. *
  19938. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  19939. *
  19940. * For more information, please refer to :
  19941. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  19942. * @param engine Define the engine the buffer is associated with
  19943. * @param data Define the data contained in the buffer
  19944. * @param dynamic Define if the buffer is updatable
  19945. */
  19946. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  19947. /**
  19948. * Indicates if the buffer is using the WebGL2 UBO implementation,
  19949. * or just falling back on setUniformXXX calls.
  19950. */
  19951. readonly useUbo: boolean;
  19952. /**
  19953. * Indicates if the WebGL underlying uniform buffer is in sync
  19954. * with the javascript cache data.
  19955. */
  19956. readonly isSync: boolean;
  19957. /**
  19958. * Indicates if the WebGL underlying uniform buffer is dynamic.
  19959. * Also, a dynamic UniformBuffer will disable cache verification and always
  19960. * update the underlying WebGL uniform buffer to the GPU.
  19961. * @returns if Dynamic, otherwise false
  19962. */
  19963. isDynamic(): boolean;
  19964. /**
  19965. * The data cache on JS side.
  19966. * @returns the underlying data as a float array
  19967. */
  19968. getData(): Float32Array;
  19969. /**
  19970. * The underlying WebGL Uniform buffer.
  19971. * @returns the webgl buffer
  19972. */
  19973. getBuffer(): Nullable<WebGLBuffer>;
  19974. /**
  19975. * std140 layout specifies how to align data within an UBO structure.
  19976. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  19977. * for specs.
  19978. */
  19979. private _fillAlignment;
  19980. /**
  19981. * Adds an uniform in the buffer.
  19982. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  19983. * for the layout to be correct !
  19984. * @param name Name of the uniform, as used in the uniform block in the shader.
  19985. * @param size Data size, or data directly.
  19986. */
  19987. addUniform(name: string, size: number | number[]): void;
  19988. /**
  19989. * Adds a Matrix 4x4 to the uniform buffer.
  19990. * @param name Name of the uniform, as used in the uniform block in the shader.
  19991. * @param mat A 4x4 matrix.
  19992. */
  19993. addMatrix(name: string, mat: Matrix): void;
  19994. /**
  19995. * Adds a vec2 to the uniform buffer.
  19996. * @param name Name of the uniform, as used in the uniform block in the shader.
  19997. * @param x Define the x component value of the vec2
  19998. * @param y Define the y component value of the vec2
  19999. */
  20000. addFloat2(name: string, x: number, y: number): void;
  20001. /**
  20002. * Adds a vec3 to the uniform buffer.
  20003. * @param name Name of the uniform, as used in the uniform block in the shader.
  20004. * @param x Define the x component value of the vec3
  20005. * @param y Define the y component value of the vec3
  20006. * @param z Define the z component value of the vec3
  20007. */
  20008. addFloat3(name: string, x: number, y: number, z: number): void;
  20009. /**
  20010. * Adds a vec3 to the uniform buffer.
  20011. * @param name Name of the uniform, as used in the uniform block in the shader.
  20012. * @param color Define the vec3 from a Color
  20013. */
  20014. addColor3(name: string, color: Color3): void;
  20015. /**
  20016. * Adds a vec4 to the uniform buffer.
  20017. * @param name Name of the uniform, as used in the uniform block in the shader.
  20018. * @param color Define the rgb components from a Color
  20019. * @param alpha Define the a component of the vec4
  20020. */
  20021. addColor4(name: string, color: Color3, alpha: number): void;
  20022. /**
  20023. * Adds a vec3 to the uniform buffer.
  20024. * @param name Name of the uniform, as used in the uniform block in the shader.
  20025. * @param vector Define the vec3 components from a Vector
  20026. */
  20027. addVector3(name: string, vector: Vector3): void;
  20028. /**
  20029. * Adds a Matrix 3x3 to the uniform buffer.
  20030. * @param name Name of the uniform, as used in the uniform block in the shader.
  20031. */
  20032. addMatrix3x3(name: string): void;
  20033. /**
  20034. * Adds a Matrix 2x2 to the uniform buffer.
  20035. * @param name Name of the uniform, as used in the uniform block in the shader.
  20036. */
  20037. addMatrix2x2(name: string): void;
  20038. /**
  20039. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  20040. */
  20041. create(): void;
  20042. /** @hidden */
  20043. _rebuild(): void;
  20044. /**
  20045. * Updates the WebGL Uniform Buffer on the GPU.
  20046. * If the `dynamic` flag is set to true, no cache comparison is done.
  20047. * Otherwise, the buffer will be updated only if the cache differs.
  20048. */
  20049. update(): void;
  20050. /**
  20051. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  20052. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  20053. * @param data Define the flattened data
  20054. * @param size Define the size of the data.
  20055. */
  20056. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  20057. private _updateMatrix3x3ForUniform;
  20058. private _updateMatrix3x3ForEffect;
  20059. private _updateMatrix2x2ForEffect;
  20060. private _updateMatrix2x2ForUniform;
  20061. private _updateFloatForEffect;
  20062. private _updateFloatForUniform;
  20063. private _updateFloat2ForEffect;
  20064. private _updateFloat2ForUniform;
  20065. private _updateFloat3ForEffect;
  20066. private _updateFloat3ForUniform;
  20067. private _updateFloat4ForEffect;
  20068. private _updateFloat4ForUniform;
  20069. private _updateMatrixForEffect;
  20070. private _updateMatrixForUniform;
  20071. private _updateVector3ForEffect;
  20072. private _updateVector3ForUniform;
  20073. private _updateVector4ForEffect;
  20074. private _updateVector4ForUniform;
  20075. private _updateColor3ForEffect;
  20076. private _updateColor3ForUniform;
  20077. private _updateColor4ForEffect;
  20078. private _updateColor4ForUniform;
  20079. /**
  20080. * Sets a sampler uniform on the effect.
  20081. * @param name Define the name of the sampler.
  20082. * @param texture Define the texture to set in the sampler
  20083. */
  20084. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  20085. /**
  20086. * Directly updates the value of the uniform in the cache AND on the GPU.
  20087. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  20088. * @param data Define the flattened data
  20089. */
  20090. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  20091. /**
  20092. * Binds this uniform buffer to an effect.
  20093. * @param effect Define the effect to bind the buffer to
  20094. * @param name Name of the uniform block in the shader.
  20095. */
  20096. bindToEffect(effect: Effect, name: string): void;
  20097. /**
  20098. * Disposes the uniform buffer.
  20099. */
  20100. dispose(): void;
  20101. }
  20102. }
  20103. declare module BABYLON {
  20104. /**
  20105. * Scalar computation library
  20106. */
  20107. class Scalar {
  20108. /**
  20109. * Two pi constants convenient for computation.
  20110. */
  20111. static TwoPi: number;
  20112. /**
  20113. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  20114. * @param a number
  20115. * @param b number
  20116. * @param epsilon (default = 1.401298E-45)
  20117. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  20118. */
  20119. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  20120. /**
  20121. * Returns a string : the upper case translation of the number i to hexadecimal.
  20122. * @param i number
  20123. * @returns the upper case translation of the number i to hexadecimal.
  20124. */
  20125. static ToHex(i: number): string;
  20126. /**
  20127. * Returns -1 if value is negative and +1 is value is positive.
  20128. * @param value the value
  20129. * @returns the value itself if it's equal to zero.
  20130. */
  20131. static Sign(value: number): number;
  20132. /**
  20133. * Returns the value itself if it's between min and max.
  20134. * Returns min if the value is lower than min.
  20135. * Returns max if the value is greater than max.
  20136. * @param value the value to clmap
  20137. * @param min the min value to clamp to (default: 0)
  20138. * @param max the max value to clamp to (default: 1)
  20139. * @returns the clamped value
  20140. */
  20141. static Clamp(value: number, min?: number, max?: number): number;
  20142. /**
  20143. * the log2 of value.
  20144. * @param value the value to compute log2 of
  20145. * @returns the log2 of value.
  20146. */
  20147. static Log2(value: number): number;
  20148. /**
  20149. * Loops the value, so that it is never larger than length and never smaller than 0.
  20150. *
  20151. * This is similar to the modulo operator but it works with floating point numbers.
  20152. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  20153. * With t = 5 and length = 2.5, the result would be 0.0.
  20154. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  20155. * @param value the value
  20156. * @param length the length
  20157. * @returns the looped value
  20158. */
  20159. static Repeat(value: number, length: number): number;
  20160. /**
  20161. * Normalize the value between 0.0 and 1.0 using min and max values
  20162. * @param value value to normalize
  20163. * @param min max to normalize between
  20164. * @param max min to normalize between
  20165. * @returns the normalized value
  20166. */
  20167. static Normalize(value: number, min: number, max: number): number;
  20168. /**
  20169. * Denormalize the value from 0.0 and 1.0 using min and max values
  20170. * @param normalized value to denormalize
  20171. * @param min max to denormalize between
  20172. * @param max min to denormalize between
  20173. * @returns the denormalized value
  20174. */
  20175. static Denormalize(normalized: number, min: number, max: number): number;
  20176. /**
  20177. * Calculates the shortest difference between two given angles given in degrees.
  20178. * @param current current angle in degrees
  20179. * @param target target angle in degrees
  20180. * @returns the delta
  20181. */
  20182. static DeltaAngle(current: number, target: number): number;
  20183. /**
  20184. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  20185. * @param tx value
  20186. * @param length length
  20187. * @returns The returned value will move back and forth between 0 and length
  20188. */
  20189. static PingPong(tx: number, length: number): number;
  20190. /**
  20191. * Interpolates between min and max with smoothing at the limits.
  20192. *
  20193. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  20194. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  20195. * @param from from
  20196. * @param to to
  20197. * @param tx value
  20198. * @returns the smooth stepped value
  20199. */
  20200. static SmoothStep(from: number, to: number, tx: number): number;
  20201. /**
  20202. * Moves a value current towards target.
  20203. *
  20204. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  20205. * Negative values of maxDelta pushes the value away from target.
  20206. * @param current current value
  20207. * @param target target value
  20208. * @param maxDelta max distance to move
  20209. * @returns resulting value
  20210. */
  20211. static MoveTowards(current: number, target: number, maxDelta: number): number;
  20212. /**
  20213. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  20214. *
  20215. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  20216. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  20217. * @param current current value
  20218. * @param target target value
  20219. * @param maxDelta max distance to move
  20220. * @returns resulting angle
  20221. */
  20222. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  20223. /**
  20224. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  20225. * @param start start value
  20226. * @param end target value
  20227. * @param amount amount to lerp between
  20228. * @returns the lerped value
  20229. */
  20230. static Lerp(start: number, end: number, amount: number): number;
  20231. /**
  20232. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  20233. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  20234. * @param start start value
  20235. * @param end target value
  20236. * @param amount amount to lerp between
  20237. * @returns the lerped value
  20238. */
  20239. static LerpAngle(start: number, end: number, amount: number): number;
  20240. /**
  20241. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  20242. * @param a start value
  20243. * @param b target value
  20244. * @param value value between a and b
  20245. * @returns the inverseLerp value
  20246. */
  20247. static InverseLerp(a: number, b: number, value: number): number;
  20248. /**
  20249. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  20250. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  20251. * @param value1 spline value
  20252. * @param tangent1 spline value
  20253. * @param value2 spline value
  20254. * @param tangent2 spline value
  20255. * @param amount input value
  20256. * @returns hermite result
  20257. */
  20258. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  20259. /**
  20260. * Returns a random float number between and min and max values
  20261. * @param min min value of random
  20262. * @param max max value of random
  20263. * @returns random value
  20264. */
  20265. static RandomRange(min: number, max: number): number;
  20266. /**
  20267. * This function returns percentage of a number in a given range.
  20268. *
  20269. * RangeToPercent(40,20,60) will return 0.5 (50%)
  20270. * RangeToPercent(34,0,100) will return 0.34 (34%)
  20271. * @param number to convert to percentage
  20272. * @param min min range
  20273. * @param max max range
  20274. * @returns the percentage
  20275. */
  20276. static RangeToPercent(number: number, min: number, max: number): number;
  20277. /**
  20278. * This function returns number that corresponds to the percentage in a given range.
  20279. *
  20280. * PercentToRange(0.34,0,100) will return 34.
  20281. * @param percent to convert to number
  20282. * @param min min range
  20283. * @param max max range
  20284. * @returns the number
  20285. */
  20286. static PercentToRange(percent: number, min: number, max: number): number;
  20287. /**
  20288. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  20289. * @param angle The angle to normalize in radian.
  20290. * @return The converted angle.
  20291. */
  20292. static NormalizeRadians(angle: number): number;
  20293. }
  20294. }
  20295. declare module BABYLON {
  20296. /**
  20297. * Constant used to convert a value to gamma space
  20298. * @ignorenaming
  20299. */
  20300. const ToGammaSpace: number;
  20301. /**
  20302. * Constant used to convert a value to linear space
  20303. * @ignorenaming
  20304. */
  20305. const ToLinearSpace = 2.2;
  20306. /**
  20307. * Constant used to define the minimal number value in Babylon.js
  20308. * @ignorenaming
  20309. */
  20310. const Epsilon = 0.001;
  20311. /**
  20312. * Class used to hold a RBG color
  20313. */
  20314. class Color3 {
  20315. /**
  20316. * Defines the red component (between 0 and 1, default is 0)
  20317. */
  20318. r: number;
  20319. /**
  20320. * Defines the green component (between 0 and 1, default is 0)
  20321. */
  20322. g: number;
  20323. /**
  20324. * Defines the blue component (between 0 and 1, default is 0)
  20325. */
  20326. b: number;
  20327. /**
  20328. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  20329. * @param r defines the red component (between 0 and 1, default is 0)
  20330. * @param g defines the green component (between 0 and 1, default is 0)
  20331. * @param b defines the blue component (between 0 and 1, default is 0)
  20332. */
  20333. constructor(
  20334. /**
  20335. * Defines the red component (between 0 and 1, default is 0)
  20336. */
  20337. r?: number,
  20338. /**
  20339. * Defines the green component (between 0 and 1, default is 0)
  20340. */
  20341. g?: number,
  20342. /**
  20343. * Defines the blue component (between 0 and 1, default is 0)
  20344. */
  20345. b?: number);
  20346. /**
  20347. * Creates a string with the Color3 current values
  20348. * @returns the string representation of the Color3 object
  20349. */
  20350. toString(): string;
  20351. /**
  20352. * Returns the string "Color3"
  20353. * @returns "Color3"
  20354. */
  20355. getClassName(): string;
  20356. /**
  20357. * Compute the Color3 hash code
  20358. * @returns an unique number that can be used to hash Color3 objects
  20359. */
  20360. getHashCode(): number;
  20361. /**
  20362. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  20363. * @param array defines the array where to store the r,g,b components
  20364. * @param index defines an optional index in the target array to define where to start storing values
  20365. * @returns the current Color3 object
  20366. */
  20367. toArray(array: FloatArray, index?: number): Color3;
  20368. /**
  20369. * Returns a new Color4 object from the current Color3 and the given alpha
  20370. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  20371. * @returns a new Color4 object
  20372. */
  20373. toColor4(alpha?: number): Color4;
  20374. /**
  20375. * Returns a new array populated with 3 numeric elements : red, green and blue values
  20376. * @returns the new array
  20377. */
  20378. asArray(): number[];
  20379. /**
  20380. * Returns the luminance value
  20381. * @returns a float value
  20382. */
  20383. toLuminance(): number;
  20384. /**
  20385. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  20386. * @param otherColor defines the second operand
  20387. * @returns the new Color3 object
  20388. */
  20389. multiply(otherColor: DeepImmutable<Color3>): Color3;
  20390. /**
  20391. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  20392. * @param otherColor defines the second operand
  20393. * @param result defines the Color3 object where to store the result
  20394. * @returns the current Color3
  20395. */
  20396. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  20397. /**
  20398. * Determines equality between Color3 objects
  20399. * @param otherColor defines the second operand
  20400. * @returns true if the rgb values are equal to the given ones
  20401. */
  20402. equals(otherColor: DeepImmutable<Color3>): boolean;
  20403. /**
  20404. * Determines equality between the current Color3 object and a set of r,b,g values
  20405. * @param r defines the red component to check
  20406. * @param g defines the green component to check
  20407. * @param b defines the blue component to check
  20408. * @returns true if the rgb values are equal to the given ones
  20409. */
  20410. equalsFloats(r: number, g: number, b: number): boolean;
  20411. /**
  20412. * Multiplies in place each rgb value by scale
  20413. * @param scale defines the scaling factor
  20414. * @returns the updated Color3
  20415. */
  20416. scale(scale: number): Color3;
  20417. /**
  20418. * Multiplies the rgb values by scale and stores the result into "result"
  20419. * @param scale defines the scaling factor
  20420. * @param result defines the Color3 object where to store the result
  20421. * @returns the unmodified current Color3
  20422. */
  20423. scaleToRef(scale: number, result: Color3): Color3;
  20424. /**
  20425. * Scale the current Color3 values by a factor and add the result to a given Color3
  20426. * @param scale defines the scale factor
  20427. * @param result defines color to store the result into
  20428. * @returns the unmodified current Color3
  20429. */
  20430. scaleAndAddToRef(scale: number, result: Color3): Color3;
  20431. /**
  20432. * Clamps the rgb values by the min and max values and stores the result into "result"
  20433. * @param min defines minimum clamping value (default is 0)
  20434. * @param max defines maximum clamping value (default is 1)
  20435. * @param result defines color to store the result into
  20436. * @returns the original Color3
  20437. */
  20438. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  20439. /**
  20440. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  20441. * @param otherColor defines the second operand
  20442. * @returns the new Color3
  20443. */
  20444. add(otherColor: DeepImmutable<Color3>): Color3;
  20445. /**
  20446. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  20447. * @param otherColor defines the second operand
  20448. * @param result defines Color3 object to store the result into
  20449. * @returns the unmodified current Color3
  20450. */
  20451. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  20452. /**
  20453. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  20454. * @param otherColor defines the second operand
  20455. * @returns the new Color3
  20456. */
  20457. subtract(otherColor: DeepImmutable<Color3>): Color3;
  20458. /**
  20459. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  20460. * @param otherColor defines the second operand
  20461. * @param result defines Color3 object to store the result into
  20462. * @returns the unmodified current Color3
  20463. */
  20464. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  20465. /**
  20466. * Copy the current object
  20467. * @returns a new Color3 copied the current one
  20468. */
  20469. clone(): Color3;
  20470. /**
  20471. * Copies the rgb values from the source in the current Color3
  20472. * @param source defines the source Color3 object
  20473. * @returns the updated Color3 object
  20474. */
  20475. copyFrom(source: DeepImmutable<Color3>): Color3;
  20476. /**
  20477. * Updates the Color3 rgb values from the given floats
  20478. * @param r defines the red component to read from
  20479. * @param g defines the green component to read from
  20480. * @param b defines the blue component to read from
  20481. * @returns the current Color3 object
  20482. */
  20483. copyFromFloats(r: number, g: number, b: number): Color3;
  20484. /**
  20485. * Updates the Color3 rgb values from the given floats
  20486. * @param r defines the red component to read from
  20487. * @param g defines the green component to read from
  20488. * @param b defines the blue component to read from
  20489. * @returns the current Color3 object
  20490. */
  20491. set(r: number, g: number, b: number): Color3;
  20492. /**
  20493. * Compute the Color3 hexadecimal code as a string
  20494. * @returns a string containing the hexadecimal representation of the Color3 object
  20495. */
  20496. toHexString(): string;
  20497. /**
  20498. * Computes a new Color3 converted from the current one to linear space
  20499. * @returns a new Color3 object
  20500. */
  20501. toLinearSpace(): Color3;
  20502. /**
  20503. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  20504. * @param convertedColor defines the Color3 object where to store the linear space version
  20505. * @returns the unmodified Color3
  20506. */
  20507. toLinearSpaceToRef(convertedColor: Color3): Color3;
  20508. /**
  20509. * Computes a new Color3 converted from the current one to gamma space
  20510. * @returns a new Color3 object
  20511. */
  20512. toGammaSpace(): Color3;
  20513. /**
  20514. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  20515. * @param convertedColor defines the Color3 object where to store the gamma space version
  20516. * @returns the unmodified Color3
  20517. */
  20518. toGammaSpaceToRef(convertedColor: Color3): Color3;
  20519. /**
  20520. * Creates a new Color3 from the string containing valid hexadecimal values
  20521. * @param hex defines a string containing valid hexadecimal values
  20522. * @returns a new Color3 object
  20523. */
  20524. static FromHexString(hex: string): Color3;
  20525. /**
  20526. * Creates a new Vector3 from the starting index of the given array
  20527. * @param array defines the source array
  20528. * @param offset defines an offset in the source array
  20529. * @returns a new Color3 object
  20530. */
  20531. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  20532. /**
  20533. * Creates a new Color3 from integer values (< 256)
  20534. * @param r defines the red component to read from (value between 0 and 255)
  20535. * @param g defines the green component to read from (value between 0 and 255)
  20536. * @param b defines the blue component to read from (value between 0 and 255)
  20537. * @returns a new Color3 object
  20538. */
  20539. static FromInts(r: number, g: number, b: number): Color3;
  20540. /**
  20541. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  20542. * @param start defines the start Color3 value
  20543. * @param end defines the end Color3 value
  20544. * @param amount defines the gradient value between start and end
  20545. * @returns a new Color3 object
  20546. */
  20547. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  20548. /**
  20549. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  20550. * @param left defines the start value
  20551. * @param right defines the end value
  20552. * @param amount defines the gradient factor
  20553. * @param result defines the Color3 object where to store the result
  20554. */
  20555. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  20556. /**
  20557. * Returns a Color3 value containing a red color
  20558. * @returns a new Color3 object
  20559. */
  20560. static Red(): Color3;
  20561. /**
  20562. * Returns a Color3 value containing a green color
  20563. * @returns a new Color3 object
  20564. */
  20565. static Green(): Color3;
  20566. /**
  20567. * Returns a Color3 value containing a blue color
  20568. * @returns a new Color3 object
  20569. */
  20570. static Blue(): Color3;
  20571. /**
  20572. * Returns a Color3 value containing a black color
  20573. * @returns a new Color3 object
  20574. */
  20575. static Black(): Color3;
  20576. /**
  20577. * Returns a Color3 value containing a white color
  20578. * @returns a new Color3 object
  20579. */
  20580. static White(): Color3;
  20581. /**
  20582. * Returns a Color3 value containing a purple color
  20583. * @returns a new Color3 object
  20584. */
  20585. static Purple(): Color3;
  20586. /**
  20587. * Returns a Color3 value containing a magenta color
  20588. * @returns a new Color3 object
  20589. */
  20590. static Magenta(): Color3;
  20591. /**
  20592. * Returns a Color3 value containing a yellow color
  20593. * @returns a new Color3 object
  20594. */
  20595. static Yellow(): Color3;
  20596. /**
  20597. * Returns a Color3 value containing a gray color
  20598. * @returns a new Color3 object
  20599. */
  20600. static Gray(): Color3;
  20601. /**
  20602. * Returns a Color3 value containing a teal color
  20603. * @returns a new Color3 object
  20604. */
  20605. static Teal(): Color3;
  20606. /**
  20607. * Returns a Color3 value containing a random color
  20608. * @returns a new Color3 object
  20609. */
  20610. static Random(): Color3;
  20611. }
  20612. /**
  20613. * Class used to hold a RBGA color
  20614. */
  20615. class Color4 {
  20616. /**
  20617. * Defines the red component (between 0 and 1, default is 0)
  20618. */
  20619. r: number;
  20620. /**
  20621. * Defines the green component (between 0 and 1, default is 0)
  20622. */
  20623. g: number;
  20624. /**
  20625. * Defines the blue component (between 0 and 1, default is 0)
  20626. */
  20627. b: number;
  20628. /**
  20629. * Defines the alpha component (between 0 and 1, default is 1)
  20630. */
  20631. a: number;
  20632. /**
  20633. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  20634. * @param r defines the red component (between 0 and 1, default is 0)
  20635. * @param g defines the green component (between 0 and 1, default is 0)
  20636. * @param b defines the blue component (between 0 and 1, default is 0)
  20637. * @param a defines the alpha component (between 0 and 1, default is 1)
  20638. */
  20639. constructor(
  20640. /**
  20641. * Defines the red component (between 0 and 1, default is 0)
  20642. */
  20643. r?: number,
  20644. /**
  20645. * Defines the green component (between 0 and 1, default is 0)
  20646. */
  20647. g?: number,
  20648. /**
  20649. * Defines the blue component (between 0 and 1, default is 0)
  20650. */
  20651. b?: number,
  20652. /**
  20653. * Defines the alpha component (between 0 and 1, default is 1)
  20654. */
  20655. a?: number);
  20656. /**
  20657. * Adds in place the given Color4 values to the current Color4 object
  20658. * @param right defines the second operand
  20659. * @returns the current updated Color4 object
  20660. */
  20661. addInPlace(right: DeepImmutable<Color4>): Color4;
  20662. /**
  20663. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  20664. * @returns the new array
  20665. */
  20666. asArray(): number[];
  20667. /**
  20668. * Stores from the starting index in the given array the Color4 successive values
  20669. * @param array defines the array where to store the r,g,b components
  20670. * @param index defines an optional index in the target array to define where to start storing values
  20671. * @returns the current Color4 object
  20672. */
  20673. toArray(array: number[], index?: number): Color4;
  20674. /**
  20675. * Determines equality between Color4 objects
  20676. * @param otherColor defines the second operand
  20677. * @returns true if the rgba values are equal to the given ones
  20678. */
  20679. equals(otherColor: DeepImmutable<Color4>): boolean;
  20680. /**
  20681. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  20682. * @param right defines the second operand
  20683. * @returns a new Color4 object
  20684. */
  20685. add(right: DeepImmutable<Color4>): Color4;
  20686. /**
  20687. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  20688. * @param right defines the second operand
  20689. * @returns a new Color4 object
  20690. */
  20691. subtract(right: DeepImmutable<Color4>): Color4;
  20692. /**
  20693. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  20694. * @param right defines the second operand
  20695. * @param result defines the Color4 object where to store the result
  20696. * @returns the current Color4 object
  20697. */
  20698. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  20699. /**
  20700. * Creates a new Color4 with the current Color4 values multiplied by scale
  20701. * @param scale defines the scaling factor to apply
  20702. * @returns a new Color4 object
  20703. */
  20704. scale(scale: number): Color4;
  20705. /**
  20706. * Multiplies the current Color4 values by scale and stores the result in "result"
  20707. * @param scale defines the scaling factor to apply
  20708. * @param result defines the Color4 object where to store the result
  20709. * @returns the current unmodified Color4
  20710. */
  20711. scaleToRef(scale: number, result: Color4): Color4;
  20712. /**
  20713. * Scale the current Color4 values by a factor and add the result to a given Color4
  20714. * @param scale defines the scale factor
  20715. * @param result defines the Color4 object where to store the result
  20716. * @returns the unmodified current Color4
  20717. */
  20718. scaleAndAddToRef(scale: number, result: Color4): Color4;
  20719. /**
  20720. * Clamps the rgb values by the min and max values and stores the result into "result"
  20721. * @param min defines minimum clamping value (default is 0)
  20722. * @param max defines maximum clamping value (default is 1)
  20723. * @param result defines color to store the result into.
  20724. * @returns the cuurent Color4
  20725. */
  20726. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  20727. /**
  20728. * Multipy an Color4 value by another and return a new Color4 object
  20729. * @param color defines the Color4 value to multiply by
  20730. * @returns a new Color4 object
  20731. */
  20732. multiply(color: Color4): Color4;
  20733. /**
  20734. * Multipy a Color4 value by another and push the result in a reference value
  20735. * @param color defines the Color4 value to multiply by
  20736. * @param result defines the Color4 to fill the result in
  20737. * @returns the result Color4
  20738. */
  20739. multiplyToRef(color: Color4, result: Color4): Color4;
  20740. /**
  20741. * Creates a string with the Color4 current values
  20742. * @returns the string representation of the Color4 object
  20743. */
  20744. toString(): string;
  20745. /**
  20746. * Returns the string "Color4"
  20747. * @returns "Color4"
  20748. */
  20749. getClassName(): string;
  20750. /**
  20751. * Compute the Color4 hash code
  20752. * @returns an unique number that can be used to hash Color4 objects
  20753. */
  20754. getHashCode(): number;
  20755. /**
  20756. * Creates a new Color4 copied from the current one
  20757. * @returns a new Color4 object
  20758. */
  20759. clone(): Color4;
  20760. /**
  20761. * Copies the given Color4 values into the current one
  20762. * @param source defines the source Color4 object
  20763. * @returns the current updated Color4 object
  20764. */
  20765. copyFrom(source: Color4): Color4;
  20766. /**
  20767. * Copies the given float values into the current one
  20768. * @param r defines the red component to read from
  20769. * @param g defines the green component to read from
  20770. * @param b defines the blue component to read from
  20771. * @param a defines the alpha component to read from
  20772. * @returns the current updated Color4 object
  20773. */
  20774. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  20775. /**
  20776. * Copies the given float values into the current one
  20777. * @param r defines the red component to read from
  20778. * @param g defines the green component to read from
  20779. * @param b defines the blue component to read from
  20780. * @param a defines the alpha component to read from
  20781. * @returns the current updated Color4 object
  20782. */
  20783. set(r: number, g: number, b: number, a: number): Color4;
  20784. /**
  20785. * Compute the Color4 hexadecimal code as a string
  20786. * @returns a string containing the hexadecimal representation of the Color4 object
  20787. */
  20788. toHexString(): string;
  20789. /**
  20790. * Computes a new Color4 converted from the current one to linear space
  20791. * @returns a new Color4 object
  20792. */
  20793. toLinearSpace(): Color4;
  20794. /**
  20795. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  20796. * @param convertedColor defines the Color4 object where to store the linear space version
  20797. * @returns the unmodified Color4
  20798. */
  20799. toLinearSpaceToRef(convertedColor: Color4): Color4;
  20800. /**
  20801. * Computes a new Color4 converted from the current one to gamma space
  20802. * @returns a new Color4 object
  20803. */
  20804. toGammaSpace(): Color4;
  20805. /**
  20806. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  20807. * @param convertedColor defines the Color4 object where to store the gamma space version
  20808. * @returns the unmodified Color4
  20809. */
  20810. toGammaSpaceToRef(convertedColor: Color4): Color4;
  20811. /**
  20812. * Creates a new Color4 from the string containing valid hexadecimal values
  20813. * @param hex defines a string containing valid hexadecimal values
  20814. * @returns a new Color4 object
  20815. */
  20816. static FromHexString(hex: string): Color4;
  20817. /**
  20818. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  20819. * @param left defines the start value
  20820. * @param right defines the end value
  20821. * @param amount defines the gradient factor
  20822. * @returns a new Color4 object
  20823. */
  20824. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  20825. /**
  20826. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  20827. * @param left defines the start value
  20828. * @param right defines the end value
  20829. * @param amount defines the gradient factor
  20830. * @param result defines the Color4 object where to store data
  20831. */
  20832. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  20833. /**
  20834. * Creates a new Color4 from a Color3 and an alpha value
  20835. * @param color3 defines the source Color3 to read from
  20836. * @param alpha defines the alpha component (1.0 by default)
  20837. * @returns a new Color4 object
  20838. */
  20839. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  20840. /**
  20841. * Creates a new Color4 from the starting index element of the given array
  20842. * @param array defines the source array to read from
  20843. * @param offset defines the offset in the source array
  20844. * @returns a new Color4 object
  20845. */
  20846. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  20847. /**
  20848. * Creates a new Color3 from integer values (< 256)
  20849. * @param r defines the red component to read from (value between 0 and 255)
  20850. * @param g defines the green component to read from (value between 0 and 255)
  20851. * @param b defines the blue component to read from (value between 0 and 255)
  20852. * @param a defines the alpha component to read from (value between 0 and 255)
  20853. * @returns a new Color3 object
  20854. */
  20855. static FromInts(r: number, g: number, b: number, a: number): Color4;
  20856. /**
  20857. * Check the content of a given array and convert it to an array containing RGBA data
  20858. * If the original array was already containing count * 4 values then it is returned directly
  20859. * @param colors defines the array to check
  20860. * @param count defines the number of RGBA data to expect
  20861. * @returns an array containing count * 4 values (RGBA)
  20862. */
  20863. static CheckColors4(colors: number[], count: number): number[];
  20864. }
  20865. /**
  20866. * Class representing a vector containing 2 coordinates
  20867. */
  20868. class Vector2 {
  20869. /** defines the first coordinate */
  20870. x: number;
  20871. /** defines the second coordinate */
  20872. y: number;
  20873. /**
  20874. * Creates a new Vector2 from the given x and y coordinates
  20875. * @param x defines the first coordinate
  20876. * @param y defines the second coordinate
  20877. */
  20878. constructor(
  20879. /** defines the first coordinate */
  20880. x?: number,
  20881. /** defines the second coordinate */
  20882. y?: number);
  20883. /**
  20884. * Gets a string with the Vector2 coordinates
  20885. * @returns a string with the Vector2 coordinates
  20886. */
  20887. toString(): string;
  20888. /**
  20889. * Gets class name
  20890. * @returns the string "Vector2"
  20891. */
  20892. getClassName(): string;
  20893. /**
  20894. * Gets current vector hash code
  20895. * @returns the Vector2 hash code as a number
  20896. */
  20897. getHashCode(): number;
  20898. /**
  20899. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  20900. * @param array defines the source array
  20901. * @param index defines the offset in source array
  20902. * @returns the current Vector2
  20903. */
  20904. toArray(array: FloatArray, index?: number): Vector2;
  20905. /**
  20906. * Copy the current vector to an array
  20907. * @returns a new array with 2 elements: the Vector2 coordinates.
  20908. */
  20909. asArray(): number[];
  20910. /**
  20911. * Sets the Vector2 coordinates with the given Vector2 coordinates
  20912. * @param source defines the source Vector2
  20913. * @returns the current updated Vector2
  20914. */
  20915. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  20916. /**
  20917. * Sets the Vector2 coordinates with the given floats
  20918. * @param x defines the first coordinate
  20919. * @param y defines the second coordinate
  20920. * @returns the current updated Vector2
  20921. */
  20922. copyFromFloats(x: number, y: number): Vector2;
  20923. /**
  20924. * Sets the Vector2 coordinates with the given floats
  20925. * @param x defines the first coordinate
  20926. * @param y defines the second coordinate
  20927. * @returns the current updated Vector2
  20928. */
  20929. set(x: number, y: number): Vector2;
  20930. /**
  20931. * Add another vector with the current one
  20932. * @param otherVector defines the other vector
  20933. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  20934. */
  20935. add(otherVector: DeepImmutable<Vector2>): Vector2;
  20936. /**
  20937. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  20938. * @param otherVector defines the other vector
  20939. * @param result defines the target vector
  20940. * @returns the unmodified current Vector2
  20941. */
  20942. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  20943. /**
  20944. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  20945. * @param otherVector defines the other vector
  20946. * @returns the current updated Vector2
  20947. */
  20948. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  20949. /**
  20950. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  20951. * @param otherVector defines the other vector
  20952. * @returns a new Vector2
  20953. */
  20954. addVector3(otherVector: Vector3): Vector2;
  20955. /**
  20956. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  20957. * @param otherVector defines the other vector
  20958. * @returns a new Vector2
  20959. */
  20960. subtract(otherVector: Vector2): Vector2;
  20961. /**
  20962. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  20963. * @param otherVector defines the other vector
  20964. * @param result defines the target vector
  20965. * @returns the unmodified current Vector2
  20966. */
  20967. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  20968. /**
  20969. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  20970. * @param otherVector defines the other vector
  20971. * @returns the current updated Vector2
  20972. */
  20973. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  20974. /**
  20975. * Multiplies in place the current Vector2 coordinates by the given ones
  20976. * @param otherVector defines the other vector
  20977. * @returns the current updated Vector2
  20978. */
  20979. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  20980. /**
  20981. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  20982. * @param otherVector defines the other vector
  20983. * @returns a new Vector2
  20984. */
  20985. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  20986. /**
  20987. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  20988. * @param otherVector defines the other vector
  20989. * @param result defines the target vector
  20990. * @returns the unmodified current Vector2
  20991. */
  20992. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  20993. /**
  20994. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  20995. * @param x defines the first coordinate
  20996. * @param y defines the second coordinate
  20997. * @returns a new Vector2
  20998. */
  20999. multiplyByFloats(x: number, y: number): Vector2;
  21000. /**
  21001. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  21002. * @param otherVector defines the other vector
  21003. * @returns a new Vector2
  21004. */
  21005. divide(otherVector: Vector2): Vector2;
  21006. /**
  21007. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  21008. * @param otherVector defines the other vector
  21009. * @param result defines the target vector
  21010. * @returns the unmodified current Vector2
  21011. */
  21012. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  21013. /**
  21014. * Divides the current Vector2 coordinates by the given ones
  21015. * @param otherVector defines the other vector
  21016. * @returns the current updated Vector2
  21017. */
  21018. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  21019. /**
  21020. * Gets a new Vector2 with current Vector2 negated coordinates
  21021. * @returns a new Vector2
  21022. */
  21023. negate(): Vector2;
  21024. /**
  21025. * Multiply the Vector2 coordinates by scale
  21026. * @param scale defines the scaling factor
  21027. * @returns the current updated Vector2
  21028. */
  21029. scaleInPlace(scale: number): Vector2;
  21030. /**
  21031. * Returns a new Vector2 scaled by "scale" from the current Vector2
  21032. * @param scale defines the scaling factor
  21033. * @returns a new Vector2
  21034. */
  21035. scale(scale: number): Vector2;
  21036. /**
  21037. * Scale the current Vector2 values by a factor to a given Vector2
  21038. * @param scale defines the scale factor
  21039. * @param result defines the Vector2 object where to store the result
  21040. * @returns the unmodified current Vector2
  21041. */
  21042. scaleToRef(scale: number, result: Vector2): Vector2;
  21043. /**
  21044. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  21045. * @param scale defines the scale factor
  21046. * @param result defines the Vector2 object where to store the result
  21047. * @returns the unmodified current Vector2
  21048. */
  21049. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  21050. /**
  21051. * Gets a boolean if two vectors are equals
  21052. * @param otherVector defines the other vector
  21053. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  21054. */
  21055. equals(otherVector: DeepImmutable<Vector2>): boolean;
  21056. /**
  21057. * Gets a boolean if two vectors are equals (using an epsilon value)
  21058. * @param otherVector defines the other vector
  21059. * @param epsilon defines the minimal distance to consider equality
  21060. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  21061. */
  21062. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  21063. /**
  21064. * Gets a new Vector2 from current Vector2 floored values
  21065. * @returns a new Vector2
  21066. */
  21067. floor(): Vector2;
  21068. /**
  21069. * Gets a new Vector2 from current Vector2 floored values
  21070. * @returns a new Vector2
  21071. */
  21072. fract(): Vector2;
  21073. /**
  21074. * Gets the length of the vector
  21075. * @returns the vector length (float)
  21076. */
  21077. length(): number;
  21078. /**
  21079. * Gets the vector squared length
  21080. * @returns the vector squared length (float)
  21081. */
  21082. lengthSquared(): number;
  21083. /**
  21084. * Normalize the vector
  21085. * @returns the current updated Vector2
  21086. */
  21087. normalize(): Vector2;
  21088. /**
  21089. * Gets a new Vector2 copied from the Vector2
  21090. * @returns a new Vector2
  21091. */
  21092. clone(): Vector2;
  21093. /**
  21094. * Gets a new Vector2(0, 0)
  21095. * @returns a new Vector2
  21096. */
  21097. static Zero(): Vector2;
  21098. /**
  21099. * Gets a new Vector2(1, 1)
  21100. * @returns a new Vector2
  21101. */
  21102. static One(): Vector2;
  21103. /**
  21104. * Gets a new Vector2 set from the given index element of the given array
  21105. * @param array defines the data source
  21106. * @param offset defines the offset in the data source
  21107. * @returns a new Vector2
  21108. */
  21109. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  21110. /**
  21111. * Sets "result" from the given index element of the given array
  21112. * @param array defines the data source
  21113. * @param offset defines the offset in the data source
  21114. * @param result defines the target vector
  21115. */
  21116. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  21117. /**
  21118. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  21119. * @param value1 defines 1st point of control
  21120. * @param value2 defines 2nd point of control
  21121. * @param value3 defines 3rd point of control
  21122. * @param value4 defines 4th point of control
  21123. * @param amount defines the interpolation factor
  21124. * @returns a new Vector2
  21125. */
  21126. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  21127. /**
  21128. * 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".
  21129. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  21130. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  21131. * @param value defines the value to clamp
  21132. * @param min defines the lower limit
  21133. * @param max defines the upper limit
  21134. * @returns a new Vector2
  21135. */
  21136. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  21137. /**
  21138. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  21139. * @param value1 defines the 1st control point
  21140. * @param tangent1 defines the outgoing tangent
  21141. * @param value2 defines the 2nd control point
  21142. * @param tangent2 defines the incoming tangent
  21143. * @param amount defines the interpolation factor
  21144. * @returns a new Vector2
  21145. */
  21146. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  21147. /**
  21148. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  21149. * @param start defines the start vector
  21150. * @param end defines the end vector
  21151. * @param amount defines the interpolation factor
  21152. * @returns a new Vector2
  21153. */
  21154. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  21155. /**
  21156. * Gets the dot product of the vector "left" and the vector "right"
  21157. * @param left defines first vector
  21158. * @param right defines second vector
  21159. * @returns the dot product (float)
  21160. */
  21161. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  21162. /**
  21163. * Returns a new Vector2 equal to the normalized given vector
  21164. * @param vector defines the vector to normalize
  21165. * @returns a new Vector2
  21166. */
  21167. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  21168. /**
  21169. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  21170. * @param left defines 1st vector
  21171. * @param right defines 2nd vector
  21172. * @returns a new Vector2
  21173. */
  21174. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  21175. /**
  21176. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  21177. * @param left defines 1st vector
  21178. * @param right defines 2nd vector
  21179. * @returns a new Vector2
  21180. */
  21181. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  21182. /**
  21183. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  21184. * @param vector defines the vector to transform
  21185. * @param transformation defines the matrix to apply
  21186. * @returns a new Vector2
  21187. */
  21188. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  21189. /**
  21190. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  21191. * @param vector defines the vector to transform
  21192. * @param transformation defines the matrix to apply
  21193. * @param result defines the target vector
  21194. */
  21195. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  21196. /**
  21197. * Determines if a given vector is included in a triangle
  21198. * @param p defines the vector to test
  21199. * @param p0 defines 1st triangle point
  21200. * @param p1 defines 2nd triangle point
  21201. * @param p2 defines 3rd triangle point
  21202. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  21203. */
  21204. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  21205. /**
  21206. * Gets the distance between the vectors "value1" and "value2"
  21207. * @param value1 defines first vector
  21208. * @param value2 defines second vector
  21209. * @returns the distance between vectors
  21210. */
  21211. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  21212. /**
  21213. * Returns the squared distance between the vectors "value1" and "value2"
  21214. * @param value1 defines first vector
  21215. * @param value2 defines second vector
  21216. * @returns the squared distance between vectors
  21217. */
  21218. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  21219. /**
  21220. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  21221. * @param value1 defines first vector
  21222. * @param value2 defines second vector
  21223. * @returns a new Vector2
  21224. */
  21225. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  21226. /**
  21227. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  21228. * @param p defines the middle point
  21229. * @param segA defines one point of the segment
  21230. * @param segB defines the other point of the segment
  21231. * @returns the shortest distance
  21232. */
  21233. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  21234. }
  21235. /**
  21236. * Classed used to store (x,y,z) vector representation
  21237. * A Vector3 is the main object used in 3D geometry
  21238. * It can represent etiher the coordinates of a point the space, either a direction
  21239. * Reminder: Babylon.js uses a left handed forward facing system
  21240. */
  21241. class Vector3 {
  21242. /**
  21243. * Defines the first coordinates (on X axis)
  21244. */
  21245. x: number;
  21246. /**
  21247. * Defines the second coordinates (on Y axis)
  21248. */
  21249. y: number;
  21250. /**
  21251. * Defines the third coordinates (on Z axis)
  21252. */
  21253. z: number;
  21254. private static _UpReadOnly;
  21255. /**
  21256. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  21257. * @param x defines the first coordinates (on X axis)
  21258. * @param y defines the second coordinates (on Y axis)
  21259. * @param z defines the third coordinates (on Z axis)
  21260. */
  21261. constructor(
  21262. /**
  21263. * Defines the first coordinates (on X axis)
  21264. */
  21265. x?: number,
  21266. /**
  21267. * Defines the second coordinates (on Y axis)
  21268. */
  21269. y?: number,
  21270. /**
  21271. * Defines the third coordinates (on Z axis)
  21272. */
  21273. z?: number);
  21274. /**
  21275. * Creates a string representation of the Vector3
  21276. * @returns a string with the Vector3 coordinates.
  21277. */
  21278. toString(): string;
  21279. /**
  21280. * Gets the class name
  21281. * @returns the string "Vector3"
  21282. */
  21283. getClassName(): string;
  21284. /**
  21285. * Creates the Vector3 hash code
  21286. * @returns a number which tends to be unique between Vector3 instances
  21287. */
  21288. getHashCode(): number;
  21289. /**
  21290. * Creates an array containing three elements : the coordinates of the Vector3
  21291. * @returns a new array of numbers
  21292. */
  21293. asArray(): number[];
  21294. /**
  21295. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  21296. * @param array defines the destination array
  21297. * @param index defines the offset in the destination array
  21298. * @returns the current Vector3
  21299. */
  21300. toArray(array: FloatArray, index?: number): Vector3;
  21301. /**
  21302. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  21303. * @returns a new Quaternion object, computed from the Vector3 coordinates
  21304. */
  21305. toQuaternion(): Quaternion;
  21306. /**
  21307. * Adds the given vector to the current Vector3
  21308. * @param otherVector defines the second operand
  21309. * @returns the current updated Vector3
  21310. */
  21311. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  21312. /**
  21313. * Adds the given coordinates to the current Vector3
  21314. * @param x defines the x coordinate of the operand
  21315. * @param y defines the y coordinate of the operand
  21316. * @param z defines the z coordinate of the operand
  21317. * @returns the current updated Vector3
  21318. */
  21319. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  21320. /**
  21321. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  21322. * @param otherVector defines the second operand
  21323. * @returns the resulting Vector3
  21324. */
  21325. add(otherVector: DeepImmutable<Vector3>): Vector3;
  21326. /**
  21327. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  21328. * @param otherVector defines the second operand
  21329. * @param result defines the Vector3 object where to store the result
  21330. * @returns the current Vector3
  21331. */
  21332. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  21333. /**
  21334. * Subtract the given vector from the current Vector3
  21335. * @param otherVector defines the second operand
  21336. * @returns the current updated Vector3
  21337. */
  21338. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  21339. /**
  21340. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  21341. * @param otherVector defines the second operand
  21342. * @returns the resulting Vector3
  21343. */
  21344. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  21345. /**
  21346. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  21347. * @param otherVector defines the second operand
  21348. * @param result defines the Vector3 object where to store the result
  21349. * @returns the current Vector3
  21350. */
  21351. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  21352. /**
  21353. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  21354. * @param x defines the x coordinate of the operand
  21355. * @param y defines the y coordinate of the operand
  21356. * @param z defines the z coordinate of the operand
  21357. * @returns the resulting Vector3
  21358. */
  21359. subtractFromFloats(x: number, y: number, z: number): Vector3;
  21360. /**
  21361. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  21362. * @param x defines the x coordinate of the operand
  21363. * @param y defines the y coordinate of the operand
  21364. * @param z defines the z coordinate of the operand
  21365. * @param result defines the Vector3 object where to store the result
  21366. * @returns the current Vector3
  21367. */
  21368. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  21369. /**
  21370. * Gets a new Vector3 set with the current Vector3 negated coordinates
  21371. * @returns a new Vector3
  21372. */
  21373. negate(): Vector3;
  21374. /**
  21375. * Multiplies the Vector3 coordinates by the float "scale"
  21376. * @param scale defines the multiplier factor
  21377. * @returns the current updated Vector3
  21378. */
  21379. scaleInPlace(scale: number): Vector3;
  21380. /**
  21381. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  21382. * @param scale defines the multiplier factor
  21383. * @returns a new Vector3
  21384. */
  21385. scale(scale: number): Vector3;
  21386. /**
  21387. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  21388. * @param scale defines the multiplier factor
  21389. * @param result defines the Vector3 object where to store the result
  21390. * @returns the current Vector3
  21391. */
  21392. scaleToRef(scale: number, result: Vector3): Vector3;
  21393. /**
  21394. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  21395. * @param scale defines the scale factor
  21396. * @param result defines the Vector3 object where to store the result
  21397. * @returns the unmodified current Vector3
  21398. */
  21399. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  21400. /**
  21401. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  21402. * @param otherVector defines the second operand
  21403. * @returns true if both vectors are equals
  21404. */
  21405. equals(otherVector: DeepImmutable<Vector3>): boolean;
  21406. /**
  21407. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  21408. * @param otherVector defines the second operand
  21409. * @param epsilon defines the minimal distance to define values as equals
  21410. * @returns true if both vectors are distant less than epsilon
  21411. */
  21412. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  21413. /**
  21414. * Returns true if the current Vector3 coordinates equals the given floats
  21415. * @param x defines the x coordinate of the operand
  21416. * @param y defines the y coordinate of the operand
  21417. * @param z defines the z coordinate of the operand
  21418. * @returns true if both vectors are equals
  21419. */
  21420. equalsToFloats(x: number, y: number, z: number): boolean;
  21421. /**
  21422. * Multiplies the current Vector3 coordinates by the given ones
  21423. * @param otherVector defines the second operand
  21424. * @returns the current updated Vector3
  21425. */
  21426. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  21427. /**
  21428. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  21429. * @param otherVector defines the second operand
  21430. * @returns the new Vector3
  21431. */
  21432. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  21433. /**
  21434. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  21435. * @param otherVector defines the second operand
  21436. * @param result defines the Vector3 object where to store the result
  21437. * @returns the current Vector3
  21438. */
  21439. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  21440. /**
  21441. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  21442. * @param x defines the x coordinate of the operand
  21443. * @param y defines the y coordinate of the operand
  21444. * @param z defines the z coordinate of the operand
  21445. * @returns the new Vector3
  21446. */
  21447. multiplyByFloats(x: number, y: number, z: number): Vector3;
  21448. /**
  21449. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  21450. * @param otherVector defines the second operand
  21451. * @returns the new Vector3
  21452. */
  21453. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  21454. /**
  21455. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  21456. * @param otherVector defines the second operand
  21457. * @param result defines the Vector3 object where to store the result
  21458. * @returns the current Vector3
  21459. */
  21460. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  21461. /**
  21462. * Divides the current Vector3 coordinates by the given ones.
  21463. * @param otherVector defines the second operand
  21464. * @returns the current updated Vector3
  21465. */
  21466. divideInPlace(otherVector: Vector3): Vector3;
  21467. /**
  21468. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  21469. * @param other defines the second operand
  21470. * @returns the current updated Vector3
  21471. */
  21472. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  21473. /**
  21474. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  21475. * @param other defines the second operand
  21476. * @returns the current updated Vector3
  21477. */
  21478. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  21479. /**
  21480. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  21481. * @param x defines the x coordinate of the operand
  21482. * @param y defines the y coordinate of the operand
  21483. * @param z defines the z coordinate of the operand
  21484. * @returns the current updated Vector3
  21485. */
  21486. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  21487. /**
  21488. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  21489. * @param x defines the x coordinate of the operand
  21490. * @param y defines the y coordinate of the operand
  21491. * @param z defines the z coordinate of the operand
  21492. * @returns the current updated Vector3
  21493. */
  21494. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  21495. /**
  21496. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  21497. */
  21498. readonly isNonUniform: boolean;
  21499. /**
  21500. * Gets a new Vector3 from current Vector3 floored values
  21501. * @returns a new Vector3
  21502. */
  21503. floor(): Vector3;
  21504. /**
  21505. * Gets a new Vector3 from current Vector3 floored values
  21506. * @returns a new Vector3
  21507. */
  21508. fract(): Vector3;
  21509. /**
  21510. * Gets the length of the Vector3
  21511. * @returns the length of the Vecto3
  21512. */
  21513. length(): number;
  21514. /**
  21515. * Gets the squared length of the Vector3
  21516. * @returns squared length of the Vector3
  21517. */
  21518. lengthSquared(): number;
  21519. /**
  21520. * Normalize the current Vector3.
  21521. * Please note that this is an in place operation.
  21522. * @returns the current updated Vector3
  21523. */
  21524. normalize(): Vector3;
  21525. /**
  21526. * Reorders the x y z properties of the vector in place
  21527. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  21528. * @returns the current updated vector
  21529. */
  21530. reorderInPlace(order: string): this;
  21531. /**
  21532. * Rotates the vector around 0,0,0 by a quaternion
  21533. * @param quaternion the rotation quaternion
  21534. * @param result vector to store the result
  21535. * @returns the resulting vector
  21536. */
  21537. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  21538. /**
  21539. * Rotates a vector around a given point
  21540. * @param quaternion the rotation quaternion
  21541. * @param point the point to rotate around
  21542. * @param result vector to store the result
  21543. * @returns the resulting vector
  21544. */
  21545. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  21546. /**
  21547. * Normalize the current Vector3 with the given input length.
  21548. * Please note that this is an in place operation.
  21549. * @param len the length of the vector
  21550. * @returns the current updated Vector3
  21551. */
  21552. normalizeFromLength(len: number): Vector3;
  21553. /**
  21554. * Normalize the current Vector3 to a new vector
  21555. * @returns the new Vector3
  21556. */
  21557. normalizeToNew(): Vector3;
  21558. /**
  21559. * Normalize the current Vector3 to the reference
  21560. * @param reference define the Vector3 to update
  21561. * @returns the updated Vector3
  21562. */
  21563. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  21564. /**
  21565. * Creates a new Vector3 copied from the current Vector3
  21566. * @returns the new Vector3
  21567. */
  21568. clone(): Vector3;
  21569. /**
  21570. * Copies the given vector coordinates to the current Vector3 ones
  21571. * @param source defines the source Vector3
  21572. * @returns the current updated Vector3
  21573. */
  21574. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  21575. /**
  21576. * Copies the given floats to the current Vector3 coordinates
  21577. * @param x defines the x coordinate of the operand
  21578. * @param y defines the y coordinate of the operand
  21579. * @param z defines the z coordinate of the operand
  21580. * @returns the current updated Vector3
  21581. */
  21582. copyFromFloats(x: number, y: number, z: number): Vector3;
  21583. /**
  21584. * Copies the given floats to the current Vector3 coordinates
  21585. * @param x defines the x coordinate of the operand
  21586. * @param y defines the y coordinate of the operand
  21587. * @param z defines the z coordinate of the operand
  21588. * @returns the current updated Vector3
  21589. */
  21590. set(x: number, y: number, z: number): Vector3;
  21591. /**
  21592. * Copies the given float to the current Vector3 coordinates
  21593. * @param v defines the x, y and z coordinates of the operand
  21594. * @returns the current updated Vector3
  21595. */
  21596. setAll(v: number): Vector3;
  21597. /**
  21598. * Get the clip factor between two vectors
  21599. * @param vector0 defines the first operand
  21600. * @param vector1 defines the second operand
  21601. * @param axis defines the axis to use
  21602. * @param size defines the size along the axis
  21603. * @returns the clip factor
  21604. */
  21605. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  21606. /**
  21607. * Get angle between two vectors
  21608. * @param vector0 angle between vector0 and vector1
  21609. * @param vector1 angle between vector0 and vector1
  21610. * @param normal direction of the normal
  21611. * @return the angle between vector0 and vector1
  21612. */
  21613. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  21614. /**
  21615. * Returns a new Vector3 set from the index "offset" of the given array
  21616. * @param array defines the source array
  21617. * @param offset defines the offset in the source array
  21618. * @returns the new Vector3
  21619. */
  21620. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  21621. /**
  21622. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  21623. * This function is deprecated. Use FromArray instead
  21624. * @param array defines the source array
  21625. * @param offset defines the offset in the source array
  21626. * @returns the new Vector3
  21627. */
  21628. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  21629. /**
  21630. * Sets the given vector "result" with the element values from the index "offset" of the given array
  21631. * @param array defines the source array
  21632. * @param offset defines the offset in the source array
  21633. * @param result defines the Vector3 where to store the result
  21634. */
  21635. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  21636. /**
  21637. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  21638. * This function is deprecated. Use FromArrayToRef instead.
  21639. * @param array defines the source array
  21640. * @param offset defines the offset in the source array
  21641. * @param result defines the Vector3 where to store the result
  21642. */
  21643. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  21644. /**
  21645. * Sets the given vector "result" with the given floats.
  21646. * @param x defines the x coordinate of the source
  21647. * @param y defines the y coordinate of the source
  21648. * @param z defines the z coordinate of the source
  21649. * @param result defines the Vector3 where to store the result
  21650. */
  21651. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  21652. /**
  21653. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  21654. * @returns a new empty Vector3
  21655. */
  21656. static Zero(): Vector3;
  21657. /**
  21658. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  21659. * @returns a new unit Vector3
  21660. */
  21661. static One(): Vector3;
  21662. /**
  21663. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  21664. * @returns a new up Vector3
  21665. */
  21666. static Up(): Vector3;
  21667. /**
  21668. * Gets a up Vector3 that must not be updated
  21669. */
  21670. static readonly UpReadOnly: DeepImmutable<Vector3>;
  21671. /**
  21672. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  21673. * @returns a new down Vector3
  21674. */
  21675. static Down(): Vector3;
  21676. /**
  21677. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  21678. * @returns a new forward Vector3
  21679. */
  21680. static Forward(): Vector3;
  21681. /**
  21682. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  21683. * @returns a new forward Vector3
  21684. */
  21685. static Backward(): Vector3;
  21686. /**
  21687. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  21688. * @returns a new right Vector3
  21689. */
  21690. static Right(): Vector3;
  21691. /**
  21692. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  21693. * @returns a new left Vector3
  21694. */
  21695. static Left(): Vector3;
  21696. /**
  21697. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  21698. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  21699. * @param vector defines the Vector3 to transform
  21700. * @param transformation defines the transformation matrix
  21701. * @returns the transformed Vector3
  21702. */
  21703. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  21704. /**
  21705. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  21706. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  21707. * @param vector defines the Vector3 to transform
  21708. * @param transformation defines the transformation matrix
  21709. * @param result defines the Vector3 where to store the result
  21710. */
  21711. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  21712. /**
  21713. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  21714. * This method computes tranformed coordinates only, not transformed direction vectors
  21715. * @param x define the x coordinate of the source vector
  21716. * @param y define the y coordinate of the source vector
  21717. * @param z define the z coordinate of the source vector
  21718. * @param transformation defines the transformation matrix
  21719. * @param result defines the Vector3 where to store the result
  21720. */
  21721. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  21722. /**
  21723. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  21724. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  21725. * @param vector defines the Vector3 to transform
  21726. * @param transformation defines the transformation matrix
  21727. * @returns the new Vector3
  21728. */
  21729. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  21730. /**
  21731. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  21732. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  21733. * @param vector defines the Vector3 to transform
  21734. * @param transformation defines the transformation matrix
  21735. * @param result defines the Vector3 where to store the result
  21736. */
  21737. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  21738. /**
  21739. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  21740. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  21741. * @param x define the x coordinate of the source vector
  21742. * @param y define the y coordinate of the source vector
  21743. * @param z define the z coordinate of the source vector
  21744. * @param transformation defines the transformation matrix
  21745. * @param result defines the Vector3 where to store the result
  21746. */
  21747. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  21748. /**
  21749. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  21750. * @param value1 defines the first control point
  21751. * @param value2 defines the second control point
  21752. * @param value3 defines the third control point
  21753. * @param value4 defines the fourth control point
  21754. * @param amount defines the amount on the spline to use
  21755. * @returns the new Vector3
  21756. */
  21757. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  21758. /**
  21759. * 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"
  21760. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  21761. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  21762. * @param value defines the current value
  21763. * @param min defines the lower range value
  21764. * @param max defines the upper range value
  21765. * @returns the new Vector3
  21766. */
  21767. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  21768. /**
  21769. * 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"
  21770. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  21771. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  21772. * @param value defines the current value
  21773. * @param min defines the lower range value
  21774. * @param max defines the upper range value
  21775. * @param result defines the Vector3 where to store the result
  21776. */
  21777. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  21778. /**
  21779. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  21780. * @param value1 defines the first control point
  21781. * @param tangent1 defines the first tangent vector
  21782. * @param value2 defines the second control point
  21783. * @param tangent2 defines the second tangent vector
  21784. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  21785. * @returns the new Vector3
  21786. */
  21787. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  21788. /**
  21789. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  21790. * @param start defines the start value
  21791. * @param end defines the end value
  21792. * @param amount max defines amount between both (between 0 and 1)
  21793. * @returns the new Vector3
  21794. */
  21795. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  21796. /**
  21797. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  21798. * @param start defines the start value
  21799. * @param end defines the end value
  21800. * @param amount max defines amount between both (between 0 and 1)
  21801. * @param result defines the Vector3 where to store the result
  21802. */
  21803. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  21804. /**
  21805. * Returns the dot product (float) between the vectors "left" and "right"
  21806. * @param left defines the left operand
  21807. * @param right defines the right operand
  21808. * @returns the dot product
  21809. */
  21810. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  21811. /**
  21812. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  21813. * The cross product is then orthogonal to both "left" and "right"
  21814. * @param left defines the left operand
  21815. * @param right defines the right operand
  21816. * @returns the cross product
  21817. */
  21818. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  21819. /**
  21820. * Sets the given vector "result" with the cross product of "left" and "right"
  21821. * The cross product is then orthogonal to both "left" and "right"
  21822. * @param left defines the left operand
  21823. * @param right defines the right operand
  21824. * @param result defines the Vector3 where to store the result
  21825. */
  21826. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  21827. /**
  21828. * Returns a new Vector3 as the normalization of the given vector
  21829. * @param vector defines the Vector3 to normalize
  21830. * @returns the new Vector3
  21831. */
  21832. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  21833. /**
  21834. * Sets the given vector "result" with the normalization of the given first vector
  21835. * @param vector defines the Vector3 to normalize
  21836. * @param result defines the Vector3 where to store the result
  21837. */
  21838. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  21839. /**
  21840. * Project a Vector3 onto screen space
  21841. * @param vector defines the Vector3 to project
  21842. * @param world defines the world matrix to use
  21843. * @param transform defines the transform (view x projection) matrix to use
  21844. * @param viewport defines the screen viewport to use
  21845. * @returns the new Vector3
  21846. */
  21847. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  21848. /** @hidden */
  21849. private static UnprojectFromInvertedMatrixToRef;
  21850. /**
  21851. * Unproject from screen space to object space
  21852. * @param source defines the screen space Vector3 to use
  21853. * @param viewportWidth defines the current width of the viewport
  21854. * @param viewportHeight defines the current height of the viewport
  21855. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21856. * @param transform defines the transform (view x projection) matrix to use
  21857. * @returns the new Vector3
  21858. */
  21859. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  21860. /**
  21861. * Unproject from screen space to object space
  21862. * @param source defines the screen space Vector3 to use
  21863. * @param viewportWidth defines the current width of the viewport
  21864. * @param viewportHeight defines the current height of the viewport
  21865. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21866. * @param view defines the view matrix to use
  21867. * @param projection defines the projection matrix to use
  21868. * @returns the new Vector3
  21869. */
  21870. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  21871. /**
  21872. * Unproject from screen space to object space
  21873. * @param source defines the screen space Vector3 to use
  21874. * @param viewportWidth defines the current width of the viewport
  21875. * @param viewportHeight defines the current height of the viewport
  21876. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21877. * @param view defines the view matrix to use
  21878. * @param projection defines the projection matrix to use
  21879. * @param result defines the Vector3 where to store the result
  21880. */
  21881. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  21882. /**
  21883. * Unproject from screen space to object space
  21884. * @param sourceX defines the screen space x coordinate to use
  21885. * @param sourceY defines the screen space y coordinate to use
  21886. * @param sourceZ defines the screen space z coordinate to use
  21887. * @param viewportWidth defines the current width of the viewport
  21888. * @param viewportHeight defines the current height of the viewport
  21889. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21890. * @param view defines the view matrix to use
  21891. * @param projection defines the projection matrix to use
  21892. * @param result defines the Vector3 where to store the result
  21893. */
  21894. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  21895. /**
  21896. * Unproject a ray from screen space to object space
  21897. * @param sourceX defines the screen space x coordinate to use
  21898. * @param sourceY defines the screen space y coordinate to use
  21899. * @param viewportWidth defines the current width of the viewport
  21900. * @param viewportHeight defines the current height of the viewport
  21901. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21902. * @param view defines the view matrix to use
  21903. * @param projection defines the projection matrix to use
  21904. * @param ray defines the Ray where to store the result
  21905. */
  21906. static UnprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, ray: Ray): void;
  21907. /**
  21908. * Gets the minimal coordinate values between two Vector3
  21909. * @param left defines the first operand
  21910. * @param right defines the second operand
  21911. * @returns the new Vector3
  21912. */
  21913. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  21914. /**
  21915. * Gets the maximal coordinate values between two Vector3
  21916. * @param left defines the first operand
  21917. * @param right defines the second operand
  21918. * @returns the new Vector3
  21919. */
  21920. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  21921. /**
  21922. * Returns the distance between the vectors "value1" and "value2"
  21923. * @param value1 defines the first operand
  21924. * @param value2 defines the second operand
  21925. * @returns the distance
  21926. */
  21927. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  21928. /**
  21929. * Returns the squared distance between the vectors "value1" and "value2"
  21930. * @param value1 defines the first operand
  21931. * @param value2 defines the second operand
  21932. * @returns the squared distance
  21933. */
  21934. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  21935. /**
  21936. * Returns a new Vector3 located at the center between "value1" and "value2"
  21937. * @param value1 defines the first operand
  21938. * @param value2 defines the second operand
  21939. * @returns the new Vector3
  21940. */
  21941. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  21942. /**
  21943. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  21944. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  21945. * to something in order to rotate it from its local system to the given target system
  21946. * Note: axis1, axis2 and axis3 are normalized during this operation
  21947. * @param axis1 defines the first axis
  21948. * @param axis2 defines the second axis
  21949. * @param axis3 defines the third axis
  21950. * @returns a new Vector3
  21951. */
  21952. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  21953. /**
  21954. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  21955. * @param axis1 defines the first axis
  21956. * @param axis2 defines the second axis
  21957. * @param axis3 defines the third axis
  21958. * @param ref defines the Vector3 where to store the result
  21959. */
  21960. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  21961. }
  21962. /**
  21963. * Vector4 class created for EulerAngle class conversion to Quaternion
  21964. */
  21965. class Vector4 {
  21966. /** x value of the vector */
  21967. x: number;
  21968. /** y value of the vector */
  21969. y: number;
  21970. /** z value of the vector */
  21971. z: number;
  21972. /** w value of the vector */
  21973. w: number;
  21974. /**
  21975. * Creates a Vector4 object from the given floats.
  21976. * @param x x value of the vector
  21977. * @param y y value of the vector
  21978. * @param z z value of the vector
  21979. * @param w w value of the vector
  21980. */
  21981. constructor(
  21982. /** x value of the vector */
  21983. x: number,
  21984. /** y value of the vector */
  21985. y: number,
  21986. /** z value of the vector */
  21987. z: number,
  21988. /** w value of the vector */
  21989. w: number);
  21990. /**
  21991. * Returns the string with the Vector4 coordinates.
  21992. * @returns a string containing all the vector values
  21993. */
  21994. toString(): string;
  21995. /**
  21996. * Returns the string "Vector4".
  21997. * @returns "Vector4"
  21998. */
  21999. getClassName(): string;
  22000. /**
  22001. * Returns the Vector4 hash code.
  22002. * @returns a unique hash code
  22003. */
  22004. getHashCode(): number;
  22005. /**
  22006. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  22007. * @returns the resulting array
  22008. */
  22009. asArray(): number[];
  22010. /**
  22011. * Populates the given array from the given index with the Vector4 coordinates.
  22012. * @param array array to populate
  22013. * @param index index of the array to start at (default: 0)
  22014. * @returns the Vector4.
  22015. */
  22016. toArray(array: FloatArray, index?: number): Vector4;
  22017. /**
  22018. * Adds the given vector to the current Vector4.
  22019. * @param otherVector the vector to add
  22020. * @returns the updated Vector4.
  22021. */
  22022. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  22023. /**
  22024. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  22025. * @param otherVector the vector to add
  22026. * @returns the resulting vector
  22027. */
  22028. add(otherVector: DeepImmutable<Vector4>): Vector4;
  22029. /**
  22030. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  22031. * @param otherVector the vector to add
  22032. * @param result the vector to store the result
  22033. * @returns the current Vector4.
  22034. */
  22035. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  22036. /**
  22037. * Subtract in place the given vector from the current Vector4.
  22038. * @param otherVector the vector to subtract
  22039. * @returns the updated Vector4.
  22040. */
  22041. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  22042. /**
  22043. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  22044. * @param otherVector the vector to add
  22045. * @returns the new vector with the result
  22046. */
  22047. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  22048. /**
  22049. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  22050. * @param otherVector the vector to subtract
  22051. * @param result the vector to store the result
  22052. * @returns the current Vector4.
  22053. */
  22054. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  22055. /**
  22056. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  22057. */
  22058. /**
  22059. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  22060. * @param x value to subtract
  22061. * @param y value to subtract
  22062. * @param z value to subtract
  22063. * @param w value to subtract
  22064. * @returns new vector containing the result
  22065. */
  22066. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  22067. /**
  22068. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  22069. * @param x value to subtract
  22070. * @param y value to subtract
  22071. * @param z value to subtract
  22072. * @param w value to subtract
  22073. * @param result the vector to store the result in
  22074. * @returns the current Vector4.
  22075. */
  22076. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  22077. /**
  22078. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  22079. * @returns a new vector with the negated values
  22080. */
  22081. negate(): Vector4;
  22082. /**
  22083. * Multiplies the current Vector4 coordinates by scale (float).
  22084. * @param scale the number to scale with
  22085. * @returns the updated Vector4.
  22086. */
  22087. scaleInPlace(scale: number): Vector4;
  22088. /**
  22089. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  22090. * @param scale the number to scale with
  22091. * @returns a new vector with the result
  22092. */
  22093. scale(scale: number): Vector4;
  22094. /**
  22095. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  22096. * @param scale the number to scale with
  22097. * @param result a vector to store the result in
  22098. * @returns the current Vector4.
  22099. */
  22100. scaleToRef(scale: number, result: Vector4): Vector4;
  22101. /**
  22102. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  22103. * @param scale defines the scale factor
  22104. * @param result defines the Vector4 object where to store the result
  22105. * @returns the unmodified current Vector4
  22106. */
  22107. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  22108. /**
  22109. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  22110. * @param otherVector the vector to compare against
  22111. * @returns true if they are equal
  22112. */
  22113. equals(otherVector: DeepImmutable<Vector4>): boolean;
  22114. /**
  22115. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  22116. * @param otherVector vector to compare against
  22117. * @param epsilon (Default: very small number)
  22118. * @returns true if they are equal
  22119. */
  22120. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  22121. /**
  22122. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  22123. * @param x x value to compare against
  22124. * @param y y value to compare against
  22125. * @param z z value to compare against
  22126. * @param w w value to compare against
  22127. * @returns true if equal
  22128. */
  22129. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  22130. /**
  22131. * Multiplies in place the current Vector4 by the given one.
  22132. * @param otherVector vector to multiple with
  22133. * @returns the updated Vector4.
  22134. */
  22135. multiplyInPlace(otherVector: Vector4): Vector4;
  22136. /**
  22137. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  22138. * @param otherVector vector to multiple with
  22139. * @returns resulting new vector
  22140. */
  22141. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  22142. /**
  22143. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  22144. * @param otherVector vector to multiple with
  22145. * @param result vector to store the result
  22146. * @returns the current Vector4.
  22147. */
  22148. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  22149. /**
  22150. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  22151. * @param x x value multiply with
  22152. * @param y y value multiply with
  22153. * @param z z value multiply with
  22154. * @param w w value multiply with
  22155. * @returns resulting new vector
  22156. */
  22157. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  22158. /**
  22159. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  22160. * @param otherVector vector to devide with
  22161. * @returns resulting new vector
  22162. */
  22163. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  22164. /**
  22165. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  22166. * @param otherVector vector to devide with
  22167. * @param result vector to store the result
  22168. * @returns the current Vector4.
  22169. */
  22170. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  22171. /**
  22172. * Divides the current Vector3 coordinates by the given ones.
  22173. * @param otherVector vector to devide with
  22174. * @returns the updated Vector3.
  22175. */
  22176. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  22177. /**
  22178. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  22179. * @param other defines the second operand
  22180. * @returns the current updated Vector4
  22181. */
  22182. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  22183. /**
  22184. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  22185. * @param other defines the second operand
  22186. * @returns the current updated Vector4
  22187. */
  22188. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  22189. /**
  22190. * Gets a new Vector4 from current Vector4 floored values
  22191. * @returns a new Vector4
  22192. */
  22193. floor(): Vector4;
  22194. /**
  22195. * Gets a new Vector4 from current Vector3 floored values
  22196. * @returns a new Vector4
  22197. */
  22198. fract(): Vector4;
  22199. /**
  22200. * Returns the Vector4 length (float).
  22201. * @returns the length
  22202. */
  22203. length(): number;
  22204. /**
  22205. * Returns the Vector4 squared length (float).
  22206. * @returns the length squared
  22207. */
  22208. lengthSquared(): number;
  22209. /**
  22210. * Normalizes in place the Vector4.
  22211. * @returns the updated Vector4.
  22212. */
  22213. normalize(): Vector4;
  22214. /**
  22215. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  22216. * @returns this converted to a new vector3
  22217. */
  22218. toVector3(): Vector3;
  22219. /**
  22220. * Returns a new Vector4 copied from the current one.
  22221. * @returns the new cloned vector
  22222. */
  22223. clone(): Vector4;
  22224. /**
  22225. * Updates the current Vector4 with the given one coordinates.
  22226. * @param source the source vector to copy from
  22227. * @returns the updated Vector4.
  22228. */
  22229. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  22230. /**
  22231. * Updates the current Vector4 coordinates with the given floats.
  22232. * @param x float to copy from
  22233. * @param y float to copy from
  22234. * @param z float to copy from
  22235. * @param w float to copy from
  22236. * @returns the updated Vector4.
  22237. */
  22238. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  22239. /**
  22240. * Updates the current Vector4 coordinates with the given floats.
  22241. * @param x float to set from
  22242. * @param y float to set from
  22243. * @param z float to set from
  22244. * @param w float to set from
  22245. * @returns the updated Vector4.
  22246. */
  22247. set(x: number, y: number, z: number, w: number): Vector4;
  22248. /**
  22249. * Copies the given float to the current Vector3 coordinates
  22250. * @param v defines the x, y, z and w coordinates of the operand
  22251. * @returns the current updated Vector3
  22252. */
  22253. setAll(v: number): Vector4;
  22254. /**
  22255. * Returns a new Vector4 set from the starting index of the given array.
  22256. * @param array the array to pull values from
  22257. * @param offset the offset into the array to start at
  22258. * @returns the new vector
  22259. */
  22260. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  22261. /**
  22262. * Updates the given vector "result" from the starting index of the given array.
  22263. * @param array the array to pull values from
  22264. * @param offset the offset into the array to start at
  22265. * @param result the vector to store the result in
  22266. */
  22267. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  22268. /**
  22269. * Updates the given vector "result" from the starting index of the given Float32Array.
  22270. * @param array the array to pull values from
  22271. * @param offset the offset into the array to start at
  22272. * @param result the vector to store the result in
  22273. */
  22274. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  22275. /**
  22276. * Updates the given vector "result" coordinates from the given floats.
  22277. * @param x float to set from
  22278. * @param y float to set from
  22279. * @param z float to set from
  22280. * @param w float to set from
  22281. * @param result the vector to the floats in
  22282. */
  22283. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  22284. /**
  22285. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  22286. * @returns the new vector
  22287. */
  22288. static Zero(): Vector4;
  22289. /**
  22290. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  22291. * @returns the new vector
  22292. */
  22293. static One(): Vector4;
  22294. /**
  22295. * Returns a new normalized Vector4 from the given one.
  22296. * @param vector the vector to normalize
  22297. * @returns the vector
  22298. */
  22299. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  22300. /**
  22301. * Updates the given vector "result" from the normalization of the given one.
  22302. * @param vector the vector to normalize
  22303. * @param result the vector to store the result in
  22304. */
  22305. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  22306. /**
  22307. * Returns a vector with the minimum values from the left and right vectors
  22308. * @param left left vector to minimize
  22309. * @param right right vector to minimize
  22310. * @returns a new vector with the minimum of the left and right vector values
  22311. */
  22312. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  22313. /**
  22314. * Returns a vector with the maximum values from the left and right vectors
  22315. * @param left left vector to maximize
  22316. * @param right right vector to maximize
  22317. * @returns a new vector with the maximum of the left and right vector values
  22318. */
  22319. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  22320. /**
  22321. * Returns the distance (float) between the vectors "value1" and "value2".
  22322. * @param value1 value to calulate the distance between
  22323. * @param value2 value to calulate the distance between
  22324. * @return the distance between the two vectors
  22325. */
  22326. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  22327. /**
  22328. * Returns the squared distance (float) between the vectors "value1" and "value2".
  22329. * @param value1 value to calulate the distance between
  22330. * @param value2 value to calulate the distance between
  22331. * @return the distance between the two vectors squared
  22332. */
  22333. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  22334. /**
  22335. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  22336. * @param value1 value to calulate the center between
  22337. * @param value2 value to calulate the center between
  22338. * @return the center between the two vectors
  22339. */
  22340. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  22341. /**
  22342. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  22343. * This methods computes transformed normalized direction vectors only.
  22344. * @param vector the vector to transform
  22345. * @param transformation the transformation matrix to apply
  22346. * @returns the new vector
  22347. */
  22348. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  22349. /**
  22350. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  22351. * This methods computes transformed normalized direction vectors only.
  22352. * @param vector the vector to transform
  22353. * @param transformation the transformation matrix to apply
  22354. * @param result the vector to store the result in
  22355. */
  22356. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  22357. /**
  22358. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  22359. * This methods computes transformed normalized direction vectors only.
  22360. * @param x value to transform
  22361. * @param y value to transform
  22362. * @param z value to transform
  22363. * @param w value to transform
  22364. * @param transformation the transformation matrix to apply
  22365. * @param result the vector to store the results in
  22366. */
  22367. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  22368. /**
  22369. * Creates a new Vector4 from a Vector3
  22370. * @param source defines the source data
  22371. * @param w defines the 4th component (default is 0)
  22372. * @returns a new Vector4
  22373. */
  22374. static FromVector3(source: Vector3, w?: number): Vector4;
  22375. }
  22376. /**
  22377. * Interface for the size containing width and height
  22378. */
  22379. interface ISize {
  22380. /**
  22381. * Width
  22382. */
  22383. width: number;
  22384. /**
  22385. * Heighht
  22386. */
  22387. height: number;
  22388. }
  22389. /**
  22390. * Size containing widht and height
  22391. */
  22392. class Size implements ISize {
  22393. /**
  22394. * Width
  22395. */
  22396. width: number;
  22397. /**
  22398. * Height
  22399. */
  22400. height: number;
  22401. /**
  22402. * Creates a Size object from the given width and height (floats).
  22403. * @param width width of the new size
  22404. * @param height height of the new size
  22405. */
  22406. constructor(width: number, height: number);
  22407. /**
  22408. * Returns a string with the Size width and height
  22409. * @returns a string with the Size width and height
  22410. */
  22411. toString(): string;
  22412. /**
  22413. * "Size"
  22414. * @returns the string "Size"
  22415. */
  22416. getClassName(): string;
  22417. /**
  22418. * Returns the Size hash code.
  22419. * @returns a hash code for a unique width and height
  22420. */
  22421. getHashCode(): number;
  22422. /**
  22423. * Updates the current size from the given one.
  22424. * @param src the given size
  22425. */
  22426. copyFrom(src: Size): void;
  22427. /**
  22428. * Updates in place the current Size from the given floats.
  22429. * @param width width of the new size
  22430. * @param height height of the new size
  22431. * @returns the updated Size.
  22432. */
  22433. copyFromFloats(width: number, height: number): Size;
  22434. /**
  22435. * Updates in place the current Size from the given floats.
  22436. * @param width width to set
  22437. * @param height height to set
  22438. * @returns the updated Size.
  22439. */
  22440. set(width: number, height: number): Size;
  22441. /**
  22442. * Multiplies the width and height by numbers
  22443. * @param w factor to multiple the width by
  22444. * @param h factor to multiple the height by
  22445. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  22446. */
  22447. multiplyByFloats(w: number, h: number): Size;
  22448. /**
  22449. * Clones the size
  22450. * @returns a new Size copied from the given one.
  22451. */
  22452. clone(): Size;
  22453. /**
  22454. * True if the current Size and the given one width and height are strictly equal.
  22455. * @param other the other size to compare against
  22456. * @returns True if the current Size and the given one width and height are strictly equal.
  22457. */
  22458. equals(other: Size): boolean;
  22459. /**
  22460. * The surface of the Size : width * height (float).
  22461. */
  22462. readonly surface: number;
  22463. /**
  22464. * Create a new size of zero
  22465. * @returns a new Size set to (0.0, 0.0)
  22466. */
  22467. static Zero(): Size;
  22468. /**
  22469. * Sums the width and height of two sizes
  22470. * @param otherSize size to add to this size
  22471. * @returns a new Size set as the addition result of the current Size and the given one.
  22472. */
  22473. add(otherSize: Size): Size;
  22474. /**
  22475. * Subtracts the width and height of two
  22476. * @param otherSize size to subtract to this size
  22477. * @returns a new Size set as the subtraction result of the given one from the current Size.
  22478. */
  22479. subtract(otherSize: Size): Size;
  22480. /**
  22481. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  22482. * @param start starting size to lerp between
  22483. * @param end end size to lerp between
  22484. * @param amount amount to lerp between the start and end values
  22485. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  22486. */
  22487. static Lerp(start: Size, end: Size, amount: number): Size;
  22488. }
  22489. /**
  22490. * Class used to store quaternion data
  22491. * @see https://en.wikipedia.org/wiki/Quaternion
  22492. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  22493. */
  22494. class Quaternion {
  22495. /** defines the first component (0 by default) */
  22496. x: number;
  22497. /** defines the second component (0 by default) */
  22498. y: number;
  22499. /** defines the third component (0 by default) */
  22500. z: number;
  22501. /** defines the fourth component (1.0 by default) */
  22502. w: number;
  22503. /**
  22504. * Creates a new Quaternion from the given floats
  22505. * @param x defines the first component (0 by default)
  22506. * @param y defines the second component (0 by default)
  22507. * @param z defines the third component (0 by default)
  22508. * @param w defines the fourth component (1.0 by default)
  22509. */
  22510. constructor(
  22511. /** defines the first component (0 by default) */
  22512. x?: number,
  22513. /** defines the second component (0 by default) */
  22514. y?: number,
  22515. /** defines the third component (0 by default) */
  22516. z?: number,
  22517. /** defines the fourth component (1.0 by default) */
  22518. w?: number);
  22519. /**
  22520. * Gets a string representation for the current quaternion
  22521. * @returns a string with the Quaternion coordinates
  22522. */
  22523. toString(): string;
  22524. /**
  22525. * Gets the class name of the quaternion
  22526. * @returns the string "Quaternion"
  22527. */
  22528. getClassName(): string;
  22529. /**
  22530. * Gets a hash code for this quaternion
  22531. * @returns the quaternion hash code
  22532. */
  22533. getHashCode(): number;
  22534. /**
  22535. * Copy the quaternion to an array
  22536. * @returns a new array populated with 4 elements from the quaternion coordinates
  22537. */
  22538. asArray(): number[];
  22539. /**
  22540. * Check if two quaternions are equals
  22541. * @param otherQuaternion defines the second operand
  22542. * @return true if the current quaternion and the given one coordinates are strictly equals
  22543. */
  22544. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  22545. /**
  22546. * Clone the current quaternion
  22547. * @returns a new quaternion copied from the current one
  22548. */
  22549. clone(): Quaternion;
  22550. /**
  22551. * Copy a quaternion to the current one
  22552. * @param other defines the other quaternion
  22553. * @returns the updated current quaternion
  22554. */
  22555. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  22556. /**
  22557. * Updates the current quaternion with the given float coordinates
  22558. * @param x defines the x coordinate
  22559. * @param y defines the y coordinate
  22560. * @param z defines the z coordinate
  22561. * @param w defines the w coordinate
  22562. * @returns the updated current quaternion
  22563. */
  22564. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  22565. /**
  22566. * Updates the current quaternion from the given float coordinates
  22567. * @param x defines the x coordinate
  22568. * @param y defines the y coordinate
  22569. * @param z defines the z coordinate
  22570. * @param w defines the w coordinate
  22571. * @returns the updated current quaternion
  22572. */
  22573. set(x: number, y: number, z: number, w: number): Quaternion;
  22574. /**
  22575. * Adds two quaternions
  22576. * @param other defines the second operand
  22577. * @returns a new quaternion as the addition result of the given one and the current quaternion
  22578. */
  22579. add(other: DeepImmutable<Quaternion>): Quaternion;
  22580. /**
  22581. * Add a quaternion to the current one
  22582. * @param other defines the quaternion to add
  22583. * @returns the current quaternion
  22584. */
  22585. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  22586. /**
  22587. * Subtract two quaternions
  22588. * @param other defines the second operand
  22589. * @returns a new quaternion as the subtraction result of the given one from the current one
  22590. */
  22591. subtract(other: Quaternion): Quaternion;
  22592. /**
  22593. * Multiplies the current quaternion by a scale factor
  22594. * @param value defines the scale factor
  22595. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  22596. */
  22597. scale(value: number): Quaternion;
  22598. /**
  22599. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  22600. * @param scale defines the scale factor
  22601. * @param result defines the Quaternion object where to store the result
  22602. * @returns the unmodified current quaternion
  22603. */
  22604. scaleToRef(scale: number, result: Quaternion): Quaternion;
  22605. /**
  22606. * Multiplies in place the current quaternion by a scale factor
  22607. * @param value defines the scale factor
  22608. * @returns the current modified quaternion
  22609. */
  22610. scaleInPlace(value: number): Quaternion;
  22611. /**
  22612. * Scale the current quaternion values by a factor and add the result to a given quaternion
  22613. * @param scale defines the scale factor
  22614. * @param result defines the Quaternion object where to store the result
  22615. * @returns the unmodified current quaternion
  22616. */
  22617. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  22618. /**
  22619. * Multiplies two quaternions
  22620. * @param q1 defines the second operand
  22621. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  22622. */
  22623. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  22624. /**
  22625. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  22626. * @param q1 defines the second operand
  22627. * @param result defines the target quaternion
  22628. * @returns the current quaternion
  22629. */
  22630. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  22631. /**
  22632. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  22633. * @param q1 defines the second operand
  22634. * @returns the currentupdated quaternion
  22635. */
  22636. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  22637. /**
  22638. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  22639. * @param ref defines the target quaternion
  22640. * @returns the current quaternion
  22641. */
  22642. conjugateToRef(ref: Quaternion): Quaternion;
  22643. /**
  22644. * Conjugates in place (1-q) the current quaternion
  22645. * @returns the current updated quaternion
  22646. */
  22647. conjugateInPlace(): Quaternion;
  22648. /**
  22649. * Conjugates in place (1-q) the current quaternion
  22650. * @returns a new quaternion
  22651. */
  22652. conjugate(): Quaternion;
  22653. /**
  22654. * Gets length of current quaternion
  22655. * @returns the quaternion length (float)
  22656. */
  22657. length(): number;
  22658. /**
  22659. * Normalize in place the current quaternion
  22660. * @returns the current updated quaternion
  22661. */
  22662. normalize(): Quaternion;
  22663. /**
  22664. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  22665. * @param order is a reserved parameter and is ignore for now
  22666. * @returns a new Vector3 containing the Euler angles
  22667. */
  22668. toEulerAngles(order?: string): Vector3;
  22669. /**
  22670. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  22671. * @param result defines the vector which will be filled with the Euler angles
  22672. * @param order is a reserved parameter and is ignore for now
  22673. * @returns the current unchanged quaternion
  22674. */
  22675. toEulerAnglesToRef(result: Vector3, order?: string): Quaternion;
  22676. /**
  22677. * Updates the given rotation matrix with the current quaternion values
  22678. * @param result defines the target matrix
  22679. * @returns the current unchanged quaternion
  22680. */
  22681. toRotationMatrix(result: Matrix): Quaternion;
  22682. /**
  22683. * Updates the current quaternion from the given rotation matrix values
  22684. * @param matrix defines the source matrix
  22685. * @returns the current updated quaternion
  22686. */
  22687. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  22688. /**
  22689. * Creates a new quaternion from a rotation matrix
  22690. * @param matrix defines the source matrix
  22691. * @returns a new quaternion created from the given rotation matrix values
  22692. */
  22693. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  22694. /**
  22695. * Updates the given quaternion with the given rotation matrix values
  22696. * @param matrix defines the source matrix
  22697. * @param result defines the target quaternion
  22698. */
  22699. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  22700. /**
  22701. * Returns the dot product (float) between the quaternions "left" and "right"
  22702. * @param left defines the left operand
  22703. * @param right defines the right operand
  22704. * @returns the dot product
  22705. */
  22706. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  22707. /**
  22708. * Checks if the two quaternions are close to each other
  22709. * @param quat0 defines the first quaternion to check
  22710. * @param quat1 defines the second quaternion to check
  22711. * @returns true if the two quaternions are close to each other
  22712. */
  22713. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  22714. /**
  22715. * Creates an empty quaternion
  22716. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  22717. */
  22718. static Zero(): Quaternion;
  22719. /**
  22720. * Inverse a given quaternion
  22721. * @param q defines the source quaternion
  22722. * @returns a new quaternion as the inverted current quaternion
  22723. */
  22724. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  22725. /**
  22726. * Inverse a given quaternion
  22727. * @param q defines the source quaternion
  22728. * @param result the quaternion the result will be stored in
  22729. * @returns the result quaternion
  22730. */
  22731. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  22732. /**
  22733. * Creates an identity quaternion
  22734. * @returns the identity quaternion
  22735. */
  22736. static Identity(): Quaternion;
  22737. /**
  22738. * Gets a boolean indicating if the given quaternion is identity
  22739. * @param quaternion defines the quaternion to check
  22740. * @returns true if the quaternion is identity
  22741. */
  22742. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  22743. /**
  22744. * Creates a quaternion from a rotation around an axis
  22745. * @param axis defines the axis to use
  22746. * @param angle defines the angle to use
  22747. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  22748. */
  22749. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  22750. /**
  22751. * Creates a rotation around an axis and stores it into the given quaternion
  22752. * @param axis defines the axis to use
  22753. * @param angle defines the angle to use
  22754. * @param result defines the target quaternion
  22755. * @returns the target quaternion
  22756. */
  22757. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  22758. /**
  22759. * Creates a new quaternion from data stored into an array
  22760. * @param array defines the data source
  22761. * @param offset defines the offset in the source array where the data starts
  22762. * @returns a new quaternion
  22763. */
  22764. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  22765. /**
  22766. * Create a quaternion from Euler rotation angles
  22767. * @param x Pitch
  22768. * @param y Yaw
  22769. * @param z Roll
  22770. * @returns the new Quaternion
  22771. */
  22772. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  22773. /**
  22774. * Updates a quaternion from Euler rotation angles
  22775. * @param x Pitch
  22776. * @param y Yaw
  22777. * @param z Roll
  22778. * @param result the quaternion to store the result
  22779. * @returns the updated quaternion
  22780. */
  22781. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  22782. /**
  22783. * Create a quaternion from Euler rotation vector
  22784. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  22785. * @returns the new Quaternion
  22786. */
  22787. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  22788. /**
  22789. * Updates a quaternion from Euler rotation vector
  22790. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  22791. * @param result the quaternion to store the result
  22792. * @returns the updated quaternion
  22793. */
  22794. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  22795. /**
  22796. * Creates a new quaternion from the given Euler float angles (y, x, z)
  22797. * @param yaw defines the rotation around Y axis
  22798. * @param pitch defines the rotation around X axis
  22799. * @param roll defines the rotation around Z axis
  22800. * @returns the new quaternion
  22801. */
  22802. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  22803. /**
  22804. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  22805. * @param yaw defines the rotation around Y axis
  22806. * @param pitch defines the rotation around X axis
  22807. * @param roll defines the rotation around Z axis
  22808. * @param result defines the target quaternion
  22809. */
  22810. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  22811. /**
  22812. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  22813. * @param alpha defines the rotation around first axis
  22814. * @param beta defines the rotation around second axis
  22815. * @param gamma defines the rotation around third axis
  22816. * @returns the new quaternion
  22817. */
  22818. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  22819. /**
  22820. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  22821. * @param alpha defines the rotation around first axis
  22822. * @param beta defines the rotation around second axis
  22823. * @param gamma defines the rotation around third axis
  22824. * @param result defines the target quaternion
  22825. */
  22826. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  22827. /**
  22828. * 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)
  22829. * @param axis1 defines the first axis
  22830. * @param axis2 defines the second axis
  22831. * @param axis3 defines the third axis
  22832. * @returns the new quaternion
  22833. */
  22834. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  22835. /**
  22836. * 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
  22837. * @param axis1 defines the first axis
  22838. * @param axis2 defines the second axis
  22839. * @param axis3 defines the third axis
  22840. * @param ref defines the target quaternion
  22841. */
  22842. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  22843. /**
  22844. * Interpolates between two quaternions
  22845. * @param left defines first quaternion
  22846. * @param right defines second quaternion
  22847. * @param amount defines the gradient to use
  22848. * @returns the new interpolated quaternion
  22849. */
  22850. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  22851. /**
  22852. * Interpolates between two quaternions and stores it into a target quaternion
  22853. * @param left defines first quaternion
  22854. * @param right defines second quaternion
  22855. * @param amount defines the gradient to use
  22856. * @param result defines the target quaternion
  22857. */
  22858. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  22859. /**
  22860. * Interpolate between two quaternions using Hermite interpolation
  22861. * @param value1 defines first quaternion
  22862. * @param tangent1 defines the incoming tangent
  22863. * @param value2 defines second quaternion
  22864. * @param tangent2 defines the outgoing tangent
  22865. * @param amount defines the target quaternion
  22866. * @returns the new interpolated quaternion
  22867. */
  22868. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  22869. }
  22870. /**
  22871. * Class used to store matrix data (4x4)
  22872. */
  22873. class Matrix {
  22874. private static _updateFlagSeed;
  22875. private static _identityReadOnly;
  22876. private _isIdentity;
  22877. private _isIdentityDirty;
  22878. private _isIdentity3x2;
  22879. private _isIdentity3x2Dirty;
  22880. /**
  22881. * Gets the update flag of the matrix which is an unique number for the matrix.
  22882. * It will be incremented every time the matrix data change.
  22883. * You can use it to speed the comparison between two versions of the same matrix.
  22884. */
  22885. updateFlag: number;
  22886. private readonly _m;
  22887. /**
  22888. * Gets the internal data of the matrix
  22889. */
  22890. readonly m: DeepImmutable<Float32Array>;
  22891. /** @hidden */
  22892. _markAsUpdated(): void;
  22893. /** @hidden */
  22894. private _updateIdentityStatus;
  22895. /**
  22896. * Creates an empty matrix (filled with zeros)
  22897. */
  22898. constructor();
  22899. /**
  22900. * Check if the current matrix is identity
  22901. * @returns true is the matrix is the identity matrix
  22902. */
  22903. isIdentity(): boolean;
  22904. /**
  22905. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  22906. * @returns true is the matrix is the identity matrix
  22907. */
  22908. isIdentityAs3x2(): boolean;
  22909. /**
  22910. * Gets the determinant of the matrix
  22911. * @returns the matrix determinant
  22912. */
  22913. determinant(): number;
  22914. /**
  22915. * Returns the matrix as a Float32Array
  22916. * @returns the matrix underlying array
  22917. */
  22918. toArray(): DeepImmutable<Float32Array>;
  22919. /**
  22920. * Returns the matrix as a Float32Array
  22921. * @returns the matrix underlying array.
  22922. */
  22923. asArray(): DeepImmutable<Float32Array>;
  22924. /**
  22925. * Inverts the current matrix in place
  22926. * @returns the current inverted matrix
  22927. */
  22928. invert(): Matrix;
  22929. /**
  22930. * Sets all the matrix elements to zero
  22931. * @returns the current matrix
  22932. */
  22933. reset(): Matrix;
  22934. /**
  22935. * Adds the current matrix with a second one
  22936. * @param other defines the matrix to add
  22937. * @returns a new matrix as the addition of the current matrix and the given one
  22938. */
  22939. add(other: DeepImmutable<Matrix>): Matrix;
  22940. /**
  22941. * Sets the given matrix "result" to the addition of the current matrix and the given one
  22942. * @param other defines the matrix to add
  22943. * @param result defines the target matrix
  22944. * @returns the current matrix
  22945. */
  22946. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  22947. /**
  22948. * Adds in place the given matrix to the current matrix
  22949. * @param other defines the second operand
  22950. * @returns the current updated matrix
  22951. */
  22952. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  22953. /**
  22954. * Sets the given matrix to the current inverted Matrix
  22955. * @param other defines the target matrix
  22956. * @returns the unmodified current matrix
  22957. */
  22958. invertToRef(other: Matrix): Matrix;
  22959. /**
  22960. * add a value at the specified position in the current Matrix
  22961. * @param index the index of the value within the matrix. between 0 and 15.
  22962. * @param value the value to be added
  22963. * @returns the current updated matrix
  22964. */
  22965. addAtIndex(index: number, value: number): Matrix;
  22966. /**
  22967. * mutiply the specified position in the current Matrix by a value
  22968. * @param index the index of the value within the matrix. between 0 and 15.
  22969. * @param value the value to be added
  22970. * @returns the current updated matrix
  22971. */
  22972. multiplyAtIndex(index: number, value: number): Matrix;
  22973. /**
  22974. * Inserts the translation vector (using 3 floats) in the current matrix
  22975. * @param x defines the 1st component of the translation
  22976. * @param y defines the 2nd component of the translation
  22977. * @param z defines the 3rd component of the translation
  22978. * @returns the current updated matrix
  22979. */
  22980. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  22981. /**
  22982. * Inserts the translation vector in the current matrix
  22983. * @param vector3 defines the translation to insert
  22984. * @returns the current updated matrix
  22985. */
  22986. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  22987. /**
  22988. * Gets the translation value of the current matrix
  22989. * @returns a new Vector3 as the extracted translation from the matrix
  22990. */
  22991. getTranslation(): Vector3;
  22992. /**
  22993. * Fill a Vector3 with the extracted translation from the matrix
  22994. * @param result defines the Vector3 where to store the translation
  22995. * @returns the current matrix
  22996. */
  22997. getTranslationToRef(result: Vector3): Matrix;
  22998. /**
  22999. * Remove rotation and scaling part from the matrix
  23000. * @returns the updated matrix
  23001. */
  23002. removeRotationAndScaling(): Matrix;
  23003. /**
  23004. * Multiply two matrices
  23005. * @param other defines the second operand
  23006. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  23007. */
  23008. multiply(other: DeepImmutable<Matrix>): Matrix;
  23009. /**
  23010. * Copy the current matrix from the given one
  23011. * @param other defines the source matrix
  23012. * @returns the current updated matrix
  23013. */
  23014. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  23015. /**
  23016. * Populates the given array from the starting index with the current matrix values
  23017. * @param array defines the target array
  23018. * @param offset defines the offset in the target array where to start storing values
  23019. * @returns the current matrix
  23020. */
  23021. copyToArray(array: Float32Array, offset?: number): Matrix;
  23022. /**
  23023. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  23024. * @param other defines the second operand
  23025. * @param result defines the matrix where to store the multiplication
  23026. * @returns the current matrix
  23027. */
  23028. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  23029. /**
  23030. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  23031. * @param other defines the second operand
  23032. * @param result defines the array where to store the multiplication
  23033. * @param offset defines the offset in the target array where to start storing values
  23034. * @returns the current matrix
  23035. */
  23036. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  23037. /**
  23038. * Check equality between this matrix and a second one
  23039. * @param value defines the second matrix to compare
  23040. * @returns true is the current matrix and the given one values are strictly equal
  23041. */
  23042. equals(value: DeepImmutable<Matrix>): boolean;
  23043. /**
  23044. * Clone the current matrix
  23045. * @returns a new matrix from the current matrix
  23046. */
  23047. clone(): Matrix;
  23048. /**
  23049. * Returns the name of the current matrix class
  23050. * @returns the string "Matrix"
  23051. */
  23052. getClassName(): string;
  23053. /**
  23054. * Gets the hash code of the current matrix
  23055. * @returns the hash code
  23056. */
  23057. getHashCode(): number;
  23058. /**
  23059. * Decomposes the current Matrix into a translation, rotation and scaling components
  23060. * @param scale defines the scale vector3 given as a reference to update
  23061. * @param rotation defines the rotation quaternion given as a reference to update
  23062. * @param translation defines the translation vector3 given as a reference to update
  23063. * @returns true if operation was successful
  23064. */
  23065. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  23066. /**
  23067. * Gets specific row of the matrix
  23068. * @param index defines the number of the row to get
  23069. * @returns the index-th row of the current matrix as a new Vector4
  23070. */
  23071. getRow(index: number): Nullable<Vector4>;
  23072. /**
  23073. * Sets the index-th row of the current matrix to the vector4 values
  23074. * @param index defines the number of the row to set
  23075. * @param row defines the target vector4
  23076. * @returns the updated current matrix
  23077. */
  23078. setRow(index: number, row: Vector4): Matrix;
  23079. /**
  23080. * Compute the transpose of the matrix
  23081. * @returns the new transposed matrix
  23082. */
  23083. transpose(): Matrix;
  23084. /**
  23085. * Compute the transpose of the matrix and store it in a given matrix
  23086. * @param result defines the target matrix
  23087. * @returns the current matrix
  23088. */
  23089. transposeToRef(result: Matrix): Matrix;
  23090. /**
  23091. * Sets the index-th row of the current matrix with the given 4 x float values
  23092. * @param index defines the row index
  23093. * @param x defines the x component to set
  23094. * @param y defines the y component to set
  23095. * @param z defines the z component to set
  23096. * @param w defines the w component to set
  23097. * @returns the updated current matrix
  23098. */
  23099. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  23100. /**
  23101. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  23102. * @param scale defines the scale factor
  23103. * @returns a new matrix
  23104. */
  23105. scale(scale: number): Matrix;
  23106. /**
  23107. * Scale the current matrix values by a factor to a given result matrix
  23108. * @param scale defines the scale factor
  23109. * @param result defines the matrix to store the result
  23110. * @returns the current matrix
  23111. */
  23112. scaleToRef(scale: number, result: Matrix): Matrix;
  23113. /**
  23114. * Scale the current matrix values by a factor and add the result to a given matrix
  23115. * @param scale defines the scale factor
  23116. * @param result defines the Matrix to store the result
  23117. * @returns the current matrix
  23118. */
  23119. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  23120. /**
  23121. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  23122. * @param ref matrix to store the result
  23123. */
  23124. toNormalMatrix(ref: Matrix): void;
  23125. /**
  23126. * Gets only rotation part of the current matrix
  23127. * @returns a new matrix sets to the extracted rotation matrix from the current one
  23128. */
  23129. getRotationMatrix(): Matrix;
  23130. /**
  23131. * Extracts the rotation matrix from the current one and sets it as the given "result"
  23132. * @param result defines the target matrix to store data to
  23133. * @returns the current matrix
  23134. */
  23135. getRotationMatrixToRef(result: Matrix): Matrix;
  23136. /**
  23137. * Toggles model matrix from being right handed to left handed in place and vice versa
  23138. */
  23139. toggleModelMatrixHandInPlace(): void;
  23140. /**
  23141. * Toggles projection matrix from being right handed to left handed in place and vice versa
  23142. */
  23143. toggleProjectionMatrixHandInPlace(): void;
  23144. /**
  23145. * Creates a matrix from an array
  23146. * @param array defines the source array
  23147. * @param offset defines an offset in the source array
  23148. * @returns a new Matrix set from the starting index of the given array
  23149. */
  23150. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  23151. /**
  23152. * Copy the content of an array into a given matrix
  23153. * @param array defines the source array
  23154. * @param offset defines an offset in the source array
  23155. * @param result defines the target matrix
  23156. */
  23157. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  23158. /**
  23159. * Stores an array into a matrix after having multiplied each component by a given factor
  23160. * @param array defines the source array
  23161. * @param offset defines the offset in the source array
  23162. * @param scale defines the scaling factor
  23163. * @param result defines the target matrix
  23164. */
  23165. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  23166. /**
  23167. * Gets an identity matrix that must not be updated
  23168. */
  23169. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  23170. /**
  23171. * Stores a list of values (16) inside a given matrix
  23172. * @param initialM11 defines 1st value of 1st row
  23173. * @param initialM12 defines 2nd value of 1st row
  23174. * @param initialM13 defines 3rd value of 1st row
  23175. * @param initialM14 defines 4th value of 1st row
  23176. * @param initialM21 defines 1st value of 2nd row
  23177. * @param initialM22 defines 2nd value of 2nd row
  23178. * @param initialM23 defines 3rd value of 2nd row
  23179. * @param initialM24 defines 4th value of 2nd row
  23180. * @param initialM31 defines 1st value of 3rd row
  23181. * @param initialM32 defines 2nd value of 3rd row
  23182. * @param initialM33 defines 3rd value of 3rd row
  23183. * @param initialM34 defines 4th value of 3rd row
  23184. * @param initialM41 defines 1st value of 4th row
  23185. * @param initialM42 defines 2nd value of 4th row
  23186. * @param initialM43 defines 3rd value of 4th row
  23187. * @param initialM44 defines 4th value of 4th row
  23188. * @param result defines the target matrix
  23189. */
  23190. 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;
  23191. /**
  23192. * Creates new matrix from a list of values (16)
  23193. * @param initialM11 defines 1st value of 1st row
  23194. * @param initialM12 defines 2nd value of 1st row
  23195. * @param initialM13 defines 3rd value of 1st row
  23196. * @param initialM14 defines 4th value of 1st row
  23197. * @param initialM21 defines 1st value of 2nd row
  23198. * @param initialM22 defines 2nd value of 2nd row
  23199. * @param initialM23 defines 3rd value of 2nd row
  23200. * @param initialM24 defines 4th value of 2nd row
  23201. * @param initialM31 defines 1st value of 3rd row
  23202. * @param initialM32 defines 2nd value of 3rd row
  23203. * @param initialM33 defines 3rd value of 3rd row
  23204. * @param initialM34 defines 4th value of 3rd row
  23205. * @param initialM41 defines 1st value of 4th row
  23206. * @param initialM42 defines 2nd value of 4th row
  23207. * @param initialM43 defines 3rd value of 4th row
  23208. * @param initialM44 defines 4th value of 4th row
  23209. * @returns the new matrix
  23210. */
  23211. 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;
  23212. /**
  23213. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  23214. * @param scale defines the scale vector3
  23215. * @param rotation defines the rotation quaternion
  23216. * @param translation defines the translation vector3
  23217. * @returns a new matrix
  23218. */
  23219. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  23220. /**
  23221. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  23222. * @param scale defines the scale vector3
  23223. * @param rotation defines the rotation quaternion
  23224. * @param translation defines the translation vector3
  23225. * @param result defines the target matrix
  23226. */
  23227. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  23228. /**
  23229. * Creates a new identity matrix
  23230. * @returns a new identity matrix
  23231. */
  23232. static Identity(): Matrix;
  23233. /**
  23234. * Creates a new identity matrix and stores the result in a given matrix
  23235. * @param result defines the target matrix
  23236. */
  23237. static IdentityToRef(result: Matrix): void;
  23238. /**
  23239. * Creates a new zero matrix
  23240. * @returns a new zero matrix
  23241. */
  23242. static Zero(): Matrix;
  23243. /**
  23244. * Creates a new rotation matrix for "angle" radians around the X axis
  23245. * @param angle defines the angle (in radians) to use
  23246. * @return the new matrix
  23247. */
  23248. static RotationX(angle: number): Matrix;
  23249. /**
  23250. * Creates a new matrix as the invert of a given matrix
  23251. * @param source defines the source matrix
  23252. * @returns the new matrix
  23253. */
  23254. static Invert(source: DeepImmutable<Matrix>): Matrix;
  23255. /**
  23256. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  23257. * @param angle defines the angle (in radians) to use
  23258. * @param result defines the target matrix
  23259. */
  23260. static RotationXToRef(angle: number, result: Matrix): void;
  23261. /**
  23262. * Creates a new rotation matrix for "angle" radians around the Y axis
  23263. * @param angle defines the angle (in radians) to use
  23264. * @return the new matrix
  23265. */
  23266. static RotationY(angle: number): Matrix;
  23267. /**
  23268. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  23269. * @param angle defines the angle (in radians) to use
  23270. * @param result defines the target matrix
  23271. */
  23272. static RotationYToRef(angle: number, result: Matrix): void;
  23273. /**
  23274. * Creates a new rotation matrix for "angle" radians around the Z axis
  23275. * @param angle defines the angle (in radians) to use
  23276. * @return the new matrix
  23277. */
  23278. static RotationZ(angle: number): Matrix;
  23279. /**
  23280. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  23281. * @param angle defines the angle (in radians) to use
  23282. * @param result defines the target matrix
  23283. */
  23284. static RotationZToRef(angle: number, result: Matrix): void;
  23285. /**
  23286. * Creates a new rotation matrix for "angle" radians around the given axis
  23287. * @param axis defines the axis to use
  23288. * @param angle defines the angle (in radians) to use
  23289. * @return the new matrix
  23290. */
  23291. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  23292. /**
  23293. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  23294. * @param axis defines the axis to use
  23295. * @param angle defines the angle (in radians) to use
  23296. * @param result defines the target matrix
  23297. */
  23298. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  23299. /**
  23300. * Creates a rotation matrix
  23301. * @param yaw defines the yaw angle in radians (Y axis)
  23302. * @param pitch defines the pitch angle in radians (X axis)
  23303. * @param roll defines the roll angle in radians (X axis)
  23304. * @returns the new rotation matrix
  23305. */
  23306. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  23307. /**
  23308. * Creates a rotation matrix and stores it in a given matrix
  23309. * @param yaw defines the yaw angle in radians (Y axis)
  23310. * @param pitch defines the pitch angle in radians (X axis)
  23311. * @param roll defines the roll angle in radians (X axis)
  23312. * @param result defines the target matrix
  23313. */
  23314. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  23315. /**
  23316. * Creates a scaling matrix
  23317. * @param x defines the scale factor on X axis
  23318. * @param y defines the scale factor on Y axis
  23319. * @param z defines the scale factor on Z axis
  23320. * @returns the new matrix
  23321. */
  23322. static Scaling(x: number, y: number, z: number): Matrix;
  23323. /**
  23324. * Creates a scaling matrix and stores it in a given matrix
  23325. * @param x defines the scale factor on X axis
  23326. * @param y defines the scale factor on Y axis
  23327. * @param z defines the scale factor on Z axis
  23328. * @param result defines the target matrix
  23329. */
  23330. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  23331. /**
  23332. * Creates a translation matrix
  23333. * @param x defines the translation on X axis
  23334. * @param y defines the translation on Y axis
  23335. * @param z defines the translationon Z axis
  23336. * @returns the new matrix
  23337. */
  23338. static Translation(x: number, y: number, z: number): Matrix;
  23339. /**
  23340. * Creates a translation matrix and stores it in a given matrix
  23341. * @param x defines the translation on X axis
  23342. * @param y defines the translation on Y axis
  23343. * @param z defines the translationon Z axis
  23344. * @param result defines the target matrix
  23345. */
  23346. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  23347. /**
  23348. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  23349. * @param startValue defines the start value
  23350. * @param endValue defines the end value
  23351. * @param gradient defines the gradient factor
  23352. * @returns the new matrix
  23353. */
  23354. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  23355. /**
  23356. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  23357. * @param startValue defines the start value
  23358. * @param endValue defines the end value
  23359. * @param gradient defines the gradient factor
  23360. * @param result defines the Matrix object where to store data
  23361. */
  23362. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  23363. /**
  23364. * Builds a new matrix whose values are computed by:
  23365. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  23366. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  23367. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  23368. * @param startValue defines the first matrix
  23369. * @param endValue defines the second matrix
  23370. * @param gradient defines the gradient between the two matrices
  23371. * @returns the new matrix
  23372. */
  23373. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  23374. /**
  23375. * Update a matrix to values which are computed by:
  23376. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  23377. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  23378. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  23379. * @param startValue defines the first matrix
  23380. * @param endValue defines the second matrix
  23381. * @param gradient defines the gradient between the two matrices
  23382. * @param result defines the target matrix
  23383. */
  23384. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  23385. /**
  23386. * 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"
  23387. * This function works in left handed mode
  23388. * @param eye defines the final position of the entity
  23389. * @param target defines where the entity should look at
  23390. * @param up defines the up vector for the entity
  23391. * @returns the new matrix
  23392. */
  23393. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  23394. /**
  23395. * 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".
  23396. * This function works in left handed mode
  23397. * @param eye defines the final position of the entity
  23398. * @param target defines where the entity should look at
  23399. * @param up defines the up vector for the entity
  23400. * @param result defines the target matrix
  23401. */
  23402. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  23403. /**
  23404. * 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"
  23405. * This function works in right handed mode
  23406. * @param eye defines the final position of the entity
  23407. * @param target defines where the entity should look at
  23408. * @param up defines the up vector for the entity
  23409. * @returns the new matrix
  23410. */
  23411. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  23412. /**
  23413. * 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".
  23414. * This function works in right handed mode
  23415. * @param eye defines the final position of the entity
  23416. * @param target defines where the entity should look at
  23417. * @param up defines the up vector for the entity
  23418. * @param result defines the target matrix
  23419. */
  23420. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  23421. /**
  23422. * Create a left-handed orthographic projection matrix
  23423. * @param width defines the viewport width
  23424. * @param height defines the viewport height
  23425. * @param znear defines the near clip plane
  23426. * @param zfar defines the far clip plane
  23427. * @returns a new matrix as a left-handed orthographic projection matrix
  23428. */
  23429. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  23430. /**
  23431. * Store a left-handed orthographic projection to a given matrix
  23432. * @param width defines the viewport width
  23433. * @param height defines the viewport height
  23434. * @param znear defines the near clip plane
  23435. * @param zfar defines the far clip plane
  23436. * @param result defines the target matrix
  23437. */
  23438. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  23439. /**
  23440. * Create a left-handed orthographic projection matrix
  23441. * @param left defines the viewport left coordinate
  23442. * @param right defines the viewport right coordinate
  23443. * @param bottom defines the viewport bottom coordinate
  23444. * @param top defines the viewport top coordinate
  23445. * @param znear defines the near clip plane
  23446. * @param zfar defines the far clip plane
  23447. * @returns a new matrix as a left-handed orthographic projection matrix
  23448. */
  23449. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  23450. /**
  23451. * Stores a left-handed orthographic projection into a given matrix
  23452. * @param left defines the viewport left coordinate
  23453. * @param right defines the viewport right coordinate
  23454. * @param bottom defines the viewport bottom coordinate
  23455. * @param top defines the viewport top coordinate
  23456. * @param znear defines the near clip plane
  23457. * @param zfar defines the far clip plane
  23458. * @param result defines the target matrix
  23459. */
  23460. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  23461. /**
  23462. * Creates a right-handed orthographic projection matrix
  23463. * @param left defines the viewport left coordinate
  23464. * @param right defines the viewport right coordinate
  23465. * @param bottom defines the viewport bottom coordinate
  23466. * @param top defines the viewport top coordinate
  23467. * @param znear defines the near clip plane
  23468. * @param zfar defines the far clip plane
  23469. * @returns a new matrix as a right-handed orthographic projection matrix
  23470. */
  23471. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  23472. /**
  23473. * Stores a right-handed orthographic projection into a given matrix
  23474. * @param left defines the viewport left coordinate
  23475. * @param right defines the viewport right coordinate
  23476. * @param bottom defines the viewport bottom coordinate
  23477. * @param top defines the viewport top coordinate
  23478. * @param znear defines the near clip plane
  23479. * @param zfar defines the far clip plane
  23480. * @param result defines the target matrix
  23481. */
  23482. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  23483. /**
  23484. * Creates a left-handed perspective projection matrix
  23485. * @param width defines the viewport width
  23486. * @param height defines the viewport height
  23487. * @param znear defines the near clip plane
  23488. * @param zfar defines the far clip plane
  23489. * @returns a new matrix as a left-handed perspective projection matrix
  23490. */
  23491. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  23492. /**
  23493. * Creates a left-handed perspective projection matrix
  23494. * @param fov defines the horizontal field of view
  23495. * @param aspect defines the aspect ratio
  23496. * @param znear defines the near clip plane
  23497. * @param zfar defines the far clip plane
  23498. * @returns a new matrix as a left-handed perspective projection matrix
  23499. */
  23500. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  23501. /**
  23502. * Stores a left-handed perspective projection into a given matrix
  23503. * @param fov defines the horizontal field of view
  23504. * @param aspect defines the aspect ratio
  23505. * @param znear defines the near clip plane
  23506. * @param zfar defines the far clip plane
  23507. * @param result defines the target matrix
  23508. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  23509. */
  23510. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  23511. /**
  23512. * Creates a right-handed perspective projection matrix
  23513. * @param fov defines the horizontal field of view
  23514. * @param aspect defines the aspect ratio
  23515. * @param znear defines the near clip plane
  23516. * @param zfar defines the far clip plane
  23517. * @returns a new matrix as a right-handed perspective projection matrix
  23518. */
  23519. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  23520. /**
  23521. * Stores a right-handed perspective projection into a given matrix
  23522. * @param fov defines the horizontal field of view
  23523. * @param aspect defines the aspect ratio
  23524. * @param znear defines the near clip plane
  23525. * @param zfar defines the far clip plane
  23526. * @param result defines the target matrix
  23527. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  23528. */
  23529. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  23530. /**
  23531. * Stores a perspective projection for WebVR info a given matrix
  23532. * @param fov defines the field of view
  23533. * @param znear defines the near clip plane
  23534. * @param zfar defines the far clip plane
  23535. * @param result defines the target matrix
  23536. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  23537. */
  23538. static PerspectiveFovWebVRToRef(fov: {
  23539. upDegrees: number;
  23540. downDegrees: number;
  23541. leftDegrees: number;
  23542. rightDegrees: number;
  23543. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  23544. /**
  23545. * Computes a complete transformation matrix
  23546. * @param viewport defines the viewport to use
  23547. * @param world defines the world matrix
  23548. * @param view defines the view matrix
  23549. * @param projection defines the projection matrix
  23550. * @param zmin defines the near clip plane
  23551. * @param zmax defines the far clip plane
  23552. * @returns the transformation matrix
  23553. */
  23554. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  23555. /**
  23556. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  23557. * @param matrix defines the matrix to use
  23558. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  23559. */
  23560. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  23561. /**
  23562. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  23563. * @param matrix defines the matrix to use
  23564. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  23565. */
  23566. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  23567. /**
  23568. * Compute the transpose of a given matrix
  23569. * @param matrix defines the matrix to transpose
  23570. * @returns the new matrix
  23571. */
  23572. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  23573. /**
  23574. * Compute the transpose of a matrix and store it in a target matrix
  23575. * @param matrix defines the matrix to transpose
  23576. * @param result defines the target matrix
  23577. */
  23578. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  23579. /**
  23580. * Computes a reflection matrix from a plane
  23581. * @param plane defines the reflection plane
  23582. * @returns a new matrix
  23583. */
  23584. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  23585. /**
  23586. * Computes a reflection matrix from a plane
  23587. * @param plane defines the reflection plane
  23588. * @param result defines the target matrix
  23589. */
  23590. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  23591. /**
  23592. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  23593. * @param xaxis defines the value of the 1st axis
  23594. * @param yaxis defines the value of the 2nd axis
  23595. * @param zaxis defines the value of the 3rd axis
  23596. * @param result defines the target matrix
  23597. */
  23598. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  23599. /**
  23600. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  23601. * @param quat defines the quaternion to use
  23602. * @param result defines the target matrix
  23603. */
  23604. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  23605. }
  23606. /**
  23607. * Represens a plane by the equation ax + by + cz + d = 0
  23608. */
  23609. class Plane {
  23610. /**
  23611. * Normal of the plane (a,b,c)
  23612. */
  23613. normal: Vector3;
  23614. /**
  23615. * d component of the plane
  23616. */
  23617. d: number;
  23618. /**
  23619. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  23620. * @param a a component of the plane
  23621. * @param b b component of the plane
  23622. * @param c c component of the plane
  23623. * @param d d component of the plane
  23624. */
  23625. constructor(a: number, b: number, c: number, d: number);
  23626. /**
  23627. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  23628. */
  23629. asArray(): number[];
  23630. /**
  23631. * @returns a new plane copied from the current Plane.
  23632. */
  23633. clone(): Plane;
  23634. /**
  23635. * @returns the string "Plane".
  23636. */
  23637. getClassName(): string;
  23638. /**
  23639. * @returns the Plane hash code.
  23640. */
  23641. getHashCode(): number;
  23642. /**
  23643. * Normalize the current Plane in place.
  23644. * @returns the updated Plane.
  23645. */
  23646. normalize(): Plane;
  23647. /**
  23648. * Applies a transformation the plane and returns the result
  23649. * @param transformation the transformation matrix to be applied to the plane
  23650. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  23651. */
  23652. transform(transformation: DeepImmutable<Matrix>): Plane;
  23653. /**
  23654. * Calcualtte the dot product between the point and the plane normal
  23655. * @param point point to calculate the dot product with
  23656. * @returns the dot product (float) of the point coordinates and the plane normal.
  23657. */
  23658. dotCoordinate(point: DeepImmutable<Vector3>): number;
  23659. /**
  23660. * Updates the current Plane from the plane defined by the three given points.
  23661. * @param point1 one of the points used to contruct the plane
  23662. * @param point2 one of the points used to contruct the plane
  23663. * @param point3 one of the points used to contruct the plane
  23664. * @returns the updated Plane.
  23665. */
  23666. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  23667. /**
  23668. * Checks if the plane is facing a given direction
  23669. * @param direction the direction to check if the plane is facing
  23670. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  23671. * @returns True is the vector "direction" is the same side than the plane normal.
  23672. */
  23673. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  23674. /**
  23675. * Calculates the distance to a point
  23676. * @param point point to calculate distance to
  23677. * @returns the signed distance (float) from the given point to the Plane.
  23678. */
  23679. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  23680. /**
  23681. * Creates a plane from an array
  23682. * @param array the array to create a plane from
  23683. * @returns a new Plane from the given array.
  23684. */
  23685. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  23686. /**
  23687. * Creates a plane from three points
  23688. * @param point1 point used to create the plane
  23689. * @param point2 point used to create the plane
  23690. * @param point3 point used to create the plane
  23691. * @returns a new Plane defined by the three given points.
  23692. */
  23693. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  23694. /**
  23695. * Creates a plane from an origin point and a normal
  23696. * @param origin origin of the plane to be constructed
  23697. * @param normal normal of the plane to be constructed
  23698. * @returns a new Plane the normal vector to this plane at the given origin point.
  23699. * Note : the vector "normal" is updated because normalized.
  23700. */
  23701. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  23702. /**
  23703. * Calculates the distance from a plane and a point
  23704. * @param origin origin of the plane to be constructed
  23705. * @param normal normal of the plane to be constructed
  23706. * @param point point to calculate distance to
  23707. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  23708. */
  23709. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  23710. }
  23711. /**
  23712. * Class used to represent a viewport on screen
  23713. */
  23714. class Viewport {
  23715. /** viewport left coordinate */
  23716. x: number;
  23717. /** viewport top coordinate */
  23718. y: number;
  23719. /**viewport width */
  23720. width: number;
  23721. /** viewport height */
  23722. height: number;
  23723. /**
  23724. * Creates a Viewport object located at (x, y) and sized (width, height)
  23725. * @param x defines viewport left coordinate
  23726. * @param y defines viewport top coordinate
  23727. * @param width defines the viewport width
  23728. * @param height defines the viewport height
  23729. */
  23730. constructor(
  23731. /** viewport left coordinate */
  23732. x: number,
  23733. /** viewport top coordinate */
  23734. y: number,
  23735. /**viewport width */
  23736. width: number,
  23737. /** viewport height */
  23738. height: number);
  23739. /**
  23740. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  23741. * @param renderWidthOrEngine defines either an engine or the rendering width
  23742. * @param renderHeight defines the rendering height
  23743. * @returns a new Viewport
  23744. */
  23745. toGlobal(renderWidthOrEngine: number | Engine, renderHeight: number): Viewport;
  23746. /**
  23747. * Returns a new Viewport copied from the current one
  23748. * @returns a new Viewport
  23749. */
  23750. clone(): Viewport;
  23751. }
  23752. /**
  23753. * Reprasents a camera frustum
  23754. */
  23755. class Frustum {
  23756. /**
  23757. * Gets the planes representing the frustum
  23758. * @param transform matrix to be applied to the returned planes
  23759. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  23760. */
  23761. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  23762. /**
  23763. * Gets the near frustum plane transformed by the transform matrix
  23764. * @param transform transformation matrix to be applied to the resulting frustum plane
  23765. * @param frustumPlane the resuling frustum plane
  23766. */
  23767. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  23768. /**
  23769. * Gets the far frustum plane transformed by the transform matrix
  23770. * @param transform transformation matrix to be applied to the resulting frustum plane
  23771. * @param frustumPlane the resuling frustum plane
  23772. */
  23773. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  23774. /**
  23775. * Gets the left frustum plane transformed by the transform matrix
  23776. * @param transform transformation matrix to be applied to the resulting frustum plane
  23777. * @param frustumPlane the resuling frustum plane
  23778. */
  23779. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  23780. /**
  23781. * Gets the right frustum plane transformed by the transform matrix
  23782. * @param transform transformation matrix to be applied to the resulting frustum plane
  23783. * @param frustumPlane the resuling frustum plane
  23784. */
  23785. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  23786. /**
  23787. * Gets the top frustum plane transformed by the transform matrix
  23788. * @param transform transformation matrix to be applied to the resulting frustum plane
  23789. * @param frustumPlane the resuling frustum plane
  23790. */
  23791. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  23792. /**
  23793. * Gets the bottom frustum plane transformed by the transform matrix
  23794. * @param transform transformation matrix to be applied to the resulting frustum plane
  23795. * @param frustumPlane the resuling frustum plane
  23796. */
  23797. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  23798. /**
  23799. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  23800. * @param transform transformation matrix to be applied to the resulting frustum planes
  23801. * @param frustumPlanes the resuling frustum planes
  23802. */
  23803. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  23804. }
  23805. /** Defines supported spaces */
  23806. enum Space {
  23807. /** Local (object) space */
  23808. LOCAL = 0,
  23809. /** World space */
  23810. WORLD = 1,
  23811. /** Bone space */
  23812. BONE = 2
  23813. }
  23814. /** Defines the 3 main axes */
  23815. class Axis {
  23816. /** X axis */
  23817. static X: Vector3;
  23818. /** Y axis */
  23819. static Y: Vector3;
  23820. /** Z axis */
  23821. static Z: Vector3;
  23822. }
  23823. /** Class used to represent a Bezier curve */
  23824. class BezierCurve {
  23825. /**
  23826. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  23827. * @param t defines the time
  23828. * @param x1 defines the left coordinate on X axis
  23829. * @param y1 defines the left coordinate on Y axis
  23830. * @param x2 defines the right coordinate on X axis
  23831. * @param y2 defines the right coordinate on Y axis
  23832. * @returns the interpolated value
  23833. */
  23834. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  23835. }
  23836. /**
  23837. * Defines potential orientation for back face culling
  23838. */
  23839. enum Orientation {
  23840. /**
  23841. * Clockwise
  23842. */
  23843. CW = 0,
  23844. /** Counter clockwise */
  23845. CCW = 1
  23846. }
  23847. /**
  23848. * Defines angle representation
  23849. */
  23850. class Angle {
  23851. private _radians;
  23852. /**
  23853. * Creates an Angle object of "radians" radians (float).
  23854. */
  23855. constructor(radians: number);
  23856. /**
  23857. * Get value in degrees
  23858. * @returns the Angle value in degrees (float)
  23859. */
  23860. degrees(): number;
  23861. /**
  23862. * Get value in radians
  23863. * @returns the Angle value in radians (float)
  23864. */
  23865. radians(): number;
  23866. /**
  23867. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  23868. * @param a defines first vector
  23869. * @param b defines second vector
  23870. * @returns a new Angle
  23871. */
  23872. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  23873. /**
  23874. * Gets a new Angle object from the given float in radians
  23875. * @param radians defines the angle value in radians
  23876. * @returns a new Angle
  23877. */
  23878. static FromRadians(radians: number): Angle;
  23879. /**
  23880. * Gets a new Angle object from the given float in degrees
  23881. * @param degrees defines the angle value in degrees
  23882. * @returns a new Angle
  23883. */
  23884. static FromDegrees(degrees: number): Angle;
  23885. }
  23886. /**
  23887. * This represents an arc in a 2d space.
  23888. */
  23889. class Arc2 {
  23890. /** Defines the start point of the arc */
  23891. startPoint: Vector2;
  23892. /** Defines the mid point of the arc */
  23893. midPoint: Vector2;
  23894. /** Defines the end point of the arc */
  23895. endPoint: Vector2;
  23896. /**
  23897. * Defines the center point of the arc.
  23898. */
  23899. centerPoint: Vector2;
  23900. /**
  23901. * Defines the radius of the arc.
  23902. */
  23903. radius: number;
  23904. /**
  23905. * Defines the angle of the arc (from mid point to end point).
  23906. */
  23907. angle: Angle;
  23908. /**
  23909. * Defines the start angle of the arc (from start point to middle point).
  23910. */
  23911. startAngle: Angle;
  23912. /**
  23913. * Defines the orientation of the arc (clock wise/counter clock wise).
  23914. */
  23915. orientation: Orientation;
  23916. /**
  23917. * Creates an Arc object from the three given points : start, middle and end.
  23918. * @param startPoint Defines the start point of the arc
  23919. * @param midPoint Defines the midlle point of the arc
  23920. * @param endPoint Defines the end point of the arc
  23921. */
  23922. constructor(
  23923. /** Defines the start point of the arc */
  23924. startPoint: Vector2,
  23925. /** Defines the mid point of the arc */
  23926. midPoint: Vector2,
  23927. /** Defines the end point of the arc */
  23928. endPoint: Vector2);
  23929. }
  23930. /**
  23931. * Represents a 2D path made up of multiple 2D points
  23932. */
  23933. class Path2 {
  23934. private _points;
  23935. private _length;
  23936. /**
  23937. * If the path start and end point are the same
  23938. */
  23939. closed: boolean;
  23940. /**
  23941. * Creates a Path2 object from the starting 2D coordinates x and y.
  23942. * @param x the starting points x value
  23943. * @param y the starting points y value
  23944. */
  23945. constructor(x: number, y: number);
  23946. /**
  23947. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  23948. * @param x the added points x value
  23949. * @param y the added points y value
  23950. * @returns the updated Path2.
  23951. */
  23952. addLineTo(x: number, y: number): Path2;
  23953. /**
  23954. * 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.
  23955. * @param midX middle point x value
  23956. * @param midY middle point y value
  23957. * @param endX end point x value
  23958. * @param endY end point y value
  23959. * @param numberOfSegments (default: 36)
  23960. * @returns the updated Path2.
  23961. */
  23962. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  23963. /**
  23964. * Closes the Path2.
  23965. * @returns the Path2.
  23966. */
  23967. close(): Path2;
  23968. /**
  23969. * Gets the sum of the distance between each sequential point in the path
  23970. * @returns the Path2 total length (float).
  23971. */
  23972. length(): number;
  23973. /**
  23974. * Gets the points which construct the path
  23975. * @returns the Path2 internal array of points.
  23976. */
  23977. getPoints(): Vector2[];
  23978. /**
  23979. * Retreives the point at the distance aways from the starting point
  23980. * @param normalizedLengthPosition the length along the path to retreive the point from
  23981. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  23982. */
  23983. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  23984. /**
  23985. * Creates a new path starting from an x and y position
  23986. * @param x starting x value
  23987. * @param y starting y value
  23988. * @returns a new Path2 starting at the coordinates (x, y).
  23989. */
  23990. static StartingAt(x: number, y: number): Path2;
  23991. }
  23992. /**
  23993. * Represents a 3D path made up of multiple 3D points
  23994. */
  23995. class Path3D {
  23996. /**
  23997. * an array of Vector3, the curve axis of the Path3D
  23998. */
  23999. path: Vector3[];
  24000. private _curve;
  24001. private _distances;
  24002. private _tangents;
  24003. private _normals;
  24004. private _binormals;
  24005. private _raw;
  24006. /**
  24007. * new Path3D(path, normal, raw)
  24008. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  24009. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  24010. * @param path an array of Vector3, the curve axis of the Path3D
  24011. * @param normal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  24012. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  24013. */
  24014. constructor(
  24015. /**
  24016. * an array of Vector3, the curve axis of the Path3D
  24017. */
  24018. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  24019. /**
  24020. * Returns the Path3D array of successive Vector3 designing its curve.
  24021. * @returns the Path3D array of successive Vector3 designing its curve.
  24022. */
  24023. getCurve(): Vector3[];
  24024. /**
  24025. * Returns an array populated with tangent vectors on each Path3D curve point.
  24026. * @returns an array populated with tangent vectors on each Path3D curve point.
  24027. */
  24028. getTangents(): Vector3[];
  24029. /**
  24030. * Returns an array populated with normal vectors on each Path3D curve point.
  24031. * @returns an array populated with normal vectors on each Path3D curve point.
  24032. */
  24033. getNormals(): Vector3[];
  24034. /**
  24035. * Returns an array populated with binormal vectors on each Path3D curve point.
  24036. * @returns an array populated with binormal vectors on each Path3D curve point.
  24037. */
  24038. getBinormals(): Vector3[];
  24039. /**
  24040. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  24041. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  24042. */
  24043. getDistances(): number[];
  24044. /**
  24045. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  24046. * @param path path which all values are copied into the curves points
  24047. * @param firstNormal which should be projected onto the curve
  24048. * @returns the same object updated.
  24049. */
  24050. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  24051. private _compute;
  24052. private _getFirstNonNullVector;
  24053. private _getLastNonNullVector;
  24054. private _normalVector;
  24055. }
  24056. /**
  24057. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  24058. * A Curve3 is designed from a series of successive Vector3.
  24059. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  24060. */
  24061. class Curve3 {
  24062. private _points;
  24063. private _length;
  24064. /**
  24065. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  24066. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  24067. * @param v1 (Vector3) the control point
  24068. * @param v2 (Vector3) the end point of the Quadratic Bezier
  24069. * @param nbPoints (integer) the wanted number of points in the curve
  24070. * @returns the created Curve3
  24071. */
  24072. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  24073. /**
  24074. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  24075. * @param v0 (Vector3) the origin point of the Cubic Bezier
  24076. * @param v1 (Vector3) the first control point
  24077. * @param v2 (Vector3) the second control point
  24078. * @param v3 (Vector3) the end point of the Cubic Bezier
  24079. * @param nbPoints (integer) the wanted number of points in the curve
  24080. * @returns the created Curve3
  24081. */
  24082. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  24083. /**
  24084. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  24085. * @param p1 (Vector3) the origin point of the Hermite Spline
  24086. * @param t1 (Vector3) the tangent vector at the origin point
  24087. * @param p2 (Vector3) the end point of the Hermite Spline
  24088. * @param t2 (Vector3) the tangent vector at the end point
  24089. * @param nbPoints (integer) the wanted number of points in the curve
  24090. * @returns the created Curve3
  24091. */
  24092. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  24093. /**
  24094. * Returns a Curve3 object along a CatmullRom Spline curve :
  24095. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  24096. * @param nbPoints (integer) the wanted number of points between each curve control points
  24097. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  24098. * @returns the created Curve3
  24099. */
  24100. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  24101. /**
  24102. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  24103. * A Curve3 is designed from a series of successive Vector3.
  24104. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  24105. * @param points points which make up the curve
  24106. */
  24107. constructor(points: Vector3[]);
  24108. /**
  24109. * @returns the Curve3 stored array of successive Vector3
  24110. */
  24111. getPoints(): Vector3[];
  24112. /**
  24113. * @returns the computed length (float) of the curve.
  24114. */
  24115. length(): number;
  24116. /**
  24117. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  24118. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  24119. * curveA and curveB keep unchanged.
  24120. * @param curve the curve to continue from this curve
  24121. * @returns the newly constructed curve
  24122. */
  24123. continue(curve: DeepImmutable<Curve3>): Curve3;
  24124. private _computeLength;
  24125. }
  24126. /**
  24127. * Contains position and normal vectors for a vertex
  24128. */
  24129. class PositionNormalVertex {
  24130. /** the position of the vertex (defaut: 0,0,0) */
  24131. position: Vector3;
  24132. /** the normal of the vertex (defaut: 0,1,0) */
  24133. normal: Vector3;
  24134. /**
  24135. * Creates a PositionNormalVertex
  24136. * @param position the position of the vertex (defaut: 0,0,0)
  24137. * @param normal the normal of the vertex (defaut: 0,1,0)
  24138. */
  24139. constructor(
  24140. /** the position of the vertex (defaut: 0,0,0) */
  24141. position?: Vector3,
  24142. /** the normal of the vertex (defaut: 0,1,0) */
  24143. normal?: Vector3);
  24144. /**
  24145. * Clones the PositionNormalVertex
  24146. * @returns the cloned PositionNormalVertex
  24147. */
  24148. clone(): PositionNormalVertex;
  24149. }
  24150. /**
  24151. * Contains position, normal and uv vectors for a vertex
  24152. */
  24153. class PositionNormalTextureVertex {
  24154. /** the position of the vertex (defaut: 0,0,0) */
  24155. position: Vector3;
  24156. /** the normal of the vertex (defaut: 0,1,0) */
  24157. normal: Vector3;
  24158. /** the uv of the vertex (default: 0,0) */
  24159. uv: Vector2;
  24160. /**
  24161. * Creates a PositionNormalTextureVertex
  24162. * @param position the position of the vertex (defaut: 0,0,0)
  24163. * @param normal the normal of the vertex (defaut: 0,1,0)
  24164. * @param uv the uv of the vertex (default: 0,0)
  24165. */
  24166. constructor(
  24167. /** the position of the vertex (defaut: 0,0,0) */
  24168. position?: Vector3,
  24169. /** the normal of the vertex (defaut: 0,1,0) */
  24170. normal?: Vector3,
  24171. /** the uv of the vertex (default: 0,0) */
  24172. uv?: Vector2);
  24173. /**
  24174. * Clones the PositionNormalTextureVertex
  24175. * @returns the cloned PositionNormalTextureVertex
  24176. */
  24177. clone(): PositionNormalTextureVertex;
  24178. }
  24179. /**
  24180. * @hidden
  24181. */
  24182. class Tmp {
  24183. static Color3: Color3[];
  24184. static Color4: Color4[];
  24185. static Vector2: Vector2[];
  24186. static Vector3: Vector3[];
  24187. static Vector4: Vector4[];
  24188. static Quaternion: Quaternion[];
  24189. static Matrix: Matrix[];
  24190. }
  24191. }
  24192. declare module BABYLON {
  24193. /**
  24194. * Class representing spherical polynomial coefficients to the 3rd degree
  24195. */
  24196. class SphericalPolynomial {
  24197. /**
  24198. * The x coefficients of the spherical polynomial
  24199. */
  24200. x: Vector3;
  24201. /**
  24202. * The y coefficients of the spherical polynomial
  24203. */
  24204. y: Vector3;
  24205. /**
  24206. * The z coefficients of the spherical polynomial
  24207. */
  24208. z: Vector3;
  24209. /**
  24210. * The xx coefficients of the spherical polynomial
  24211. */
  24212. xx: Vector3;
  24213. /**
  24214. * The yy coefficients of the spherical polynomial
  24215. */
  24216. yy: Vector3;
  24217. /**
  24218. * The zz coefficients of the spherical polynomial
  24219. */
  24220. zz: Vector3;
  24221. /**
  24222. * The xy coefficients of the spherical polynomial
  24223. */
  24224. xy: Vector3;
  24225. /**
  24226. * The yz coefficients of the spherical polynomial
  24227. */
  24228. yz: Vector3;
  24229. /**
  24230. * The zx coefficients of the spherical polynomial
  24231. */
  24232. zx: Vector3;
  24233. /**
  24234. * Adds an ambient color to the spherical polynomial
  24235. * @param color the color to add
  24236. */
  24237. addAmbient(color: Color3): void;
  24238. /**
  24239. * Scales the spherical polynomial by the given amount
  24240. * @param scale the amount to scale
  24241. */
  24242. scale(scale: number): void;
  24243. /**
  24244. * Gets the spherical polynomial from harmonics
  24245. * @param harmonics the spherical harmonics
  24246. * @returns the spherical polynomial
  24247. */
  24248. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  24249. /**
  24250. * Constructs a spherical polynomial from an array.
  24251. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  24252. * @returns the spherical polynomial
  24253. */
  24254. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  24255. }
  24256. /**
  24257. * Class representing spherical harmonics coefficients to the 3rd degree
  24258. */
  24259. class SphericalHarmonics {
  24260. /**
  24261. * The l0,0 coefficients of the spherical harmonics
  24262. */
  24263. l00: Vector3;
  24264. /**
  24265. * The l1,-1 coefficients of the spherical harmonics
  24266. */
  24267. l1_1: Vector3;
  24268. /**
  24269. * The l1,0 coefficients of the spherical harmonics
  24270. */
  24271. l10: Vector3;
  24272. /**
  24273. * The l1,1 coefficients of the spherical harmonics
  24274. */
  24275. l11: Vector3;
  24276. /**
  24277. * The l2,-2 coefficients of the spherical harmonics
  24278. */
  24279. l2_2: Vector3;
  24280. /**
  24281. * The l2,-1 coefficients of the spherical harmonics
  24282. */
  24283. l2_1: Vector3;
  24284. /**
  24285. * The l2,0 coefficients of the spherical harmonics
  24286. */
  24287. l20: Vector3;
  24288. /**
  24289. * The l2,1 coefficients of the spherical harmonics
  24290. */
  24291. l21: Vector3;
  24292. /**
  24293. * The l2,2 coefficients of the spherical harmonics
  24294. */
  24295. lL22: Vector3;
  24296. /**
  24297. * Adds a light to the spherical harmonics
  24298. * @param direction the direction of the light
  24299. * @param color the color of the light
  24300. * @param deltaSolidAngle the delta solid angle of the light
  24301. */
  24302. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  24303. /**
  24304. * Scales the spherical harmonics by the given amount
  24305. * @param scale the amount to scale
  24306. */
  24307. scale(scale: number): void;
  24308. /**
  24309. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  24310. *
  24311. * ```
  24312. * E_lm = A_l * L_lm
  24313. * ```
  24314. *
  24315. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  24316. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  24317. * the scaling factors are given in equation 9.
  24318. */
  24319. convertIncidentRadianceToIrradiance(): void;
  24320. /**
  24321. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  24322. *
  24323. * ```
  24324. * L = (1/pi) * E * rho
  24325. * ```
  24326. *
  24327. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  24328. */
  24329. convertIrradianceToLambertianRadiance(): void;
  24330. /**
  24331. * Gets the spherical harmonics from polynomial
  24332. * @param polynomial the spherical polynomial
  24333. * @returns the spherical harmonics
  24334. */
  24335. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  24336. /**
  24337. * Constructs a spherical harmonics from an array.
  24338. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  24339. * @returns the spherical harmonics
  24340. */
  24341. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  24342. }
  24343. }
  24344. declare module BABYLON {
  24345. /**
  24346. * Class used to store all common mesh properties
  24347. */
  24348. class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  24349. /** No occlusion */
  24350. static OCCLUSION_TYPE_NONE: number;
  24351. /** Occlusion set to optimisitic */
  24352. static OCCLUSION_TYPE_OPTIMISTIC: number;
  24353. /** Occlusion set to strict */
  24354. static OCCLUSION_TYPE_STRICT: number;
  24355. /** Use an accurante occlusion algorithm */
  24356. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  24357. /** Use a conservative occlusion algorithm */
  24358. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  24359. /** Default culling strategy with bounding box and bounding sphere and then frustum culling */
  24360. static readonly CULLINGSTRATEGY_STANDARD: number;
  24361. /** Culling strategy with bounding sphere only and then frustum culling */
  24362. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  24363. /**
  24364. * No billboard
  24365. */
  24366. static readonly BILLBOARDMODE_NONE: number;
  24367. /** Billboard on X axis */
  24368. static readonly BILLBOARDMODE_X: number;
  24369. /** Billboard on Y axis */
  24370. static readonly BILLBOARDMODE_Y: number;
  24371. /** Billboard on Z axis */
  24372. static readonly BILLBOARDMODE_Z: number;
  24373. /** Billboard on all axes */
  24374. static readonly BILLBOARDMODE_ALL: number;
  24375. private _facetData;
  24376. /** Gets ot sets the culling strategy to use to find visible meshes */
  24377. cullingStrategy: number;
  24378. /**
  24379. * Gets the number of facets in the mesh
  24380. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24381. */
  24382. readonly facetNb: number;
  24383. /**
  24384. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  24385. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24386. */
  24387. partitioningSubdivisions: number;
  24388. /**
  24389. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  24390. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  24391. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24392. */
  24393. partitioningBBoxRatio: number;
  24394. /**
  24395. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  24396. * Works only for updatable meshes.
  24397. * Doesn't work with multi-materials
  24398. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24399. */
  24400. mustDepthSortFacets: boolean;
  24401. /**
  24402. * The location (Vector3) where the facet depth sort must be computed from.
  24403. * By default, the active camera position.
  24404. * Used only when facet depth sort is enabled
  24405. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24406. */
  24407. facetDepthSortFrom: Vector3;
  24408. /**
  24409. * gets a boolean indicating if facetData is enabled
  24410. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24411. */
  24412. readonly isFacetDataEnabled: boolean;
  24413. /** @hidden */
  24414. _updateNonUniformScalingState(value: boolean): boolean;
  24415. /**
  24416. * An event triggered when this mesh collides with another one
  24417. */
  24418. onCollideObservable: Observable<AbstractMesh>;
  24419. private _onCollideObserver;
  24420. /** Set a function to call when this mesh collides with another one */
  24421. onCollide: () => void;
  24422. /**
  24423. * An event triggered when the collision's position changes
  24424. */
  24425. onCollisionPositionChangeObservable: Observable<Vector3>;
  24426. private _onCollisionPositionChangeObserver;
  24427. /** Set a function to call when the collision's position changes */
  24428. onCollisionPositionChange: () => void;
  24429. /**
  24430. * An event triggered when material is changed
  24431. */
  24432. onMaterialChangedObservable: Observable<AbstractMesh>;
  24433. /**
  24434. * Gets or sets the orientation for POV movement & rotation
  24435. */
  24436. definedFacingForward: boolean;
  24437. /** @hidden */
  24438. _occlusionQuery: Nullable<WebGLQuery>;
  24439. private _visibility;
  24440. /**
  24441. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24442. */
  24443. /**
  24444. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24445. */
  24446. visibility: number;
  24447. /** Gets or sets the alpha index used to sort transparent meshes
  24448. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  24449. */
  24450. alphaIndex: number;
  24451. /**
  24452. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  24453. */
  24454. isVisible: boolean;
  24455. /**
  24456. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  24457. */
  24458. isPickable: boolean;
  24459. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  24460. showSubMeshesBoundingBox: boolean;
  24461. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  24462. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  24463. */
  24464. isBlocker: boolean;
  24465. /**
  24466. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  24467. */
  24468. enablePointerMoveEvents: boolean;
  24469. /**
  24470. * Specifies the rendering group id for this mesh (0 by default)
  24471. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24472. */
  24473. renderingGroupId: number;
  24474. private _material;
  24475. /** Gets or sets current material */
  24476. material: Nullable<Material>;
  24477. private _receiveShadows;
  24478. /**
  24479. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  24480. * @see http://doc.babylonjs.com/babylon101/shadows
  24481. */
  24482. receiveShadows: boolean;
  24483. /** Defines color to use when rendering outline */
  24484. outlineColor: Color3;
  24485. /** Define width to use when rendering outline */
  24486. outlineWidth: number;
  24487. /** Defines color to use when rendering overlay */
  24488. overlayColor: Color3;
  24489. /** Defines alpha to use when rendering overlay */
  24490. overlayAlpha: number;
  24491. private _hasVertexAlpha;
  24492. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  24493. hasVertexAlpha: boolean;
  24494. private _useVertexColors;
  24495. /** 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) */
  24496. useVertexColors: boolean;
  24497. private _computeBonesUsingShaders;
  24498. /**
  24499. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  24500. */
  24501. computeBonesUsingShaders: boolean;
  24502. private _numBoneInfluencers;
  24503. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  24504. numBoneInfluencers: number;
  24505. private _applyFog;
  24506. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  24507. applyFog: boolean;
  24508. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  24509. useOctreeForRenderingSelection: boolean;
  24510. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  24511. useOctreeForPicking: boolean;
  24512. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  24513. useOctreeForCollisions: boolean;
  24514. private _layerMask;
  24515. /**
  24516. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  24517. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  24518. */
  24519. layerMask: number;
  24520. /**
  24521. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  24522. */
  24523. alwaysSelectAsActiveMesh: boolean;
  24524. /**
  24525. * Gets or sets the current action manager
  24526. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24527. */
  24528. actionManager: Nullable<ActionManager>;
  24529. private _checkCollisions;
  24530. private _collisionMask;
  24531. private _collisionGroup;
  24532. /**
  24533. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  24534. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24535. */
  24536. ellipsoid: Vector3;
  24537. /**
  24538. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  24539. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24540. */
  24541. ellipsoidOffset: Vector3;
  24542. private _collider;
  24543. private _oldPositionForCollisions;
  24544. private _diffPositionForCollisions;
  24545. /**
  24546. * Gets or sets a collision mask used to mask collisions (default is -1).
  24547. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24548. */
  24549. collisionMask: number;
  24550. /**
  24551. * Gets or sets the current collision group mask (-1 by default).
  24552. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24553. */
  24554. collisionGroup: number;
  24555. /**
  24556. * Defines edge width used when edgesRenderer is enabled
  24557. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24558. */
  24559. edgesWidth: number;
  24560. /**
  24561. * Defines edge color used when edgesRenderer is enabled
  24562. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24563. */
  24564. edgesColor: Color4;
  24565. /** @hidden */
  24566. _edgesRenderer: Nullable<IEdgesRenderer>;
  24567. /** @hidden */
  24568. _masterMesh: Nullable<AbstractMesh>;
  24569. /** @hidden */
  24570. _boundingInfo: Nullable<BoundingInfo>;
  24571. /** @hidden */
  24572. _renderId: number;
  24573. /**
  24574. * Gets or sets the list of subMeshes
  24575. * @see http://doc.babylonjs.com/how_to/multi_materials
  24576. */
  24577. subMeshes: SubMesh[];
  24578. /** @hidden */
  24579. _intersectionsInProgress: AbstractMesh[];
  24580. /** @hidden */
  24581. _unIndexed: boolean;
  24582. /** @hidden */
  24583. _lightSources: Light[];
  24584. /** @hidden */
  24585. readonly _positions: Nullable<Vector3[]>;
  24586. /** @hidden */
  24587. _waitingActions: any;
  24588. /** @hidden */
  24589. _waitingFreezeWorldMatrix: Nullable<boolean>;
  24590. private _skeleton;
  24591. /** @hidden */
  24592. _bonesTransformMatrices: Nullable<Float32Array>;
  24593. /**
  24594. * Gets or sets a skeleton to apply skining transformations
  24595. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24596. */
  24597. skeleton: Nullable<Skeleton>;
  24598. /**
  24599. * An event triggered when the mesh is rebuilt.
  24600. */
  24601. onRebuildObservable: Observable<AbstractMesh>;
  24602. /**
  24603. * Creates a new AbstractMesh
  24604. * @param name defines the name of the mesh
  24605. * @param scene defines the hosting scene
  24606. */
  24607. constructor(name: string, scene?: Nullable<Scene>);
  24608. /**
  24609. * Returns the string "AbstractMesh"
  24610. * @returns "AbstractMesh"
  24611. */
  24612. getClassName(): string;
  24613. /**
  24614. * Gets a string representation of the current mesh
  24615. * @param fullDetails defines a boolean indicating if full details must be included
  24616. * @returns a string representation of the current mesh
  24617. */
  24618. toString(fullDetails?: boolean): string;
  24619. /** @hidden */
  24620. _rebuild(): void;
  24621. /** @hidden */
  24622. _resyncLightSources(): void;
  24623. /** @hidden */
  24624. _resyncLighSource(light: Light): void;
  24625. /** @hidden */
  24626. _unBindEffect(): void;
  24627. /** @hidden */
  24628. _removeLightSource(light: Light): void;
  24629. private _markSubMeshesAsDirty;
  24630. /** @hidden */
  24631. _markSubMeshesAsLightDirty(): void;
  24632. /** @hidden */
  24633. _markSubMeshesAsAttributesDirty(): void;
  24634. /** @hidden */
  24635. _markSubMeshesAsMiscDirty(): void;
  24636. /**
  24637. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  24638. */
  24639. scaling: Vector3;
  24640. /**
  24641. * Returns true if the mesh is blocked. Implemented by child classes
  24642. */
  24643. readonly isBlocked: boolean;
  24644. /**
  24645. * Returns the mesh itself by default. Implemented by child classes
  24646. * @param camera defines the camera to use to pick the right LOD level
  24647. * @returns the currentAbstractMesh
  24648. */
  24649. getLOD(camera: Camera): Nullable<AbstractMesh>;
  24650. /**
  24651. * Returns 0 by default. Implemented by child classes
  24652. * @returns an integer
  24653. */
  24654. getTotalVertices(): number;
  24655. /**
  24656. * Returns a positive integer : the total number of indices in this mesh geometry.
  24657. * @returns the numner of indices or zero if the mesh has no geometry.
  24658. */
  24659. getTotalIndices(): number;
  24660. /**
  24661. * Returns null by default. Implemented by child classes
  24662. * @returns null
  24663. */
  24664. getIndices(): Nullable<IndicesArray>;
  24665. /**
  24666. * Returns the array of the requested vertex data kind. Implemented by child classes
  24667. * @param kind defines the vertex data kind to use
  24668. * @returns null
  24669. */
  24670. getVerticesData(kind: string): Nullable<FloatArray>;
  24671. /**
  24672. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24673. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24674. * Note that a new underlying VertexBuffer object is created each call.
  24675. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24676. * @param kind defines vertex data kind:
  24677. * * BABYLON.VertexBuffer.PositionKind
  24678. * * BABYLON.VertexBuffer.UVKind
  24679. * * BABYLON.VertexBuffer.UV2Kind
  24680. * * BABYLON.VertexBuffer.UV3Kind
  24681. * * BABYLON.VertexBuffer.UV4Kind
  24682. * * BABYLON.VertexBuffer.UV5Kind
  24683. * * BABYLON.VertexBuffer.UV6Kind
  24684. * * BABYLON.VertexBuffer.ColorKind
  24685. * * BABYLON.VertexBuffer.MatricesIndicesKind
  24686. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  24687. * * BABYLON.VertexBuffer.MatricesWeightsKind
  24688. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  24689. * @param data defines the data source
  24690. * @param updatable defines if the data must be flagged as updatable (or static)
  24691. * @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
  24692. * @returns the current mesh
  24693. */
  24694. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24695. /**
  24696. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  24697. * If the mesh has no geometry, it is simply returned as it is.
  24698. * @param kind defines vertex data kind:
  24699. * * BABYLON.VertexBuffer.PositionKind
  24700. * * BABYLON.VertexBuffer.UVKind
  24701. * * BABYLON.VertexBuffer.UV2Kind
  24702. * * BABYLON.VertexBuffer.UV3Kind
  24703. * * BABYLON.VertexBuffer.UV4Kind
  24704. * * BABYLON.VertexBuffer.UV5Kind
  24705. * * BABYLON.VertexBuffer.UV6Kind
  24706. * * BABYLON.VertexBuffer.ColorKind
  24707. * * BABYLON.VertexBuffer.MatricesIndicesKind
  24708. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  24709. * * BABYLON.VertexBuffer.MatricesWeightsKind
  24710. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  24711. * @param data defines the data source
  24712. * @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
  24713. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  24714. * @returns the current mesh
  24715. */
  24716. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24717. /**
  24718. * Sets the mesh indices,
  24719. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  24720. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  24721. * @param totalVertices Defines the total number of vertices
  24722. * @returns the current mesh
  24723. */
  24724. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  24725. /**
  24726. * Gets a boolean indicating if specific vertex data is present
  24727. * @param kind defines the vertex data kind to use
  24728. * @returns true is data kind is present
  24729. */
  24730. isVerticesDataPresent(kind: string): boolean;
  24731. /**
  24732. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  24733. * @returns a BoundingInfo
  24734. */
  24735. getBoundingInfo(): BoundingInfo;
  24736. /**
  24737. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  24738. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  24739. * @returns the current mesh
  24740. */
  24741. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  24742. /**
  24743. * Overwrite the current bounding info
  24744. * @param boundingInfo defines the new bounding info
  24745. * @returns the current mesh
  24746. */
  24747. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  24748. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  24749. readonly useBones: boolean;
  24750. /** @hidden */
  24751. _preActivate(): void;
  24752. /** @hidden */
  24753. _preActivateForIntermediateRendering(renderId: number): void;
  24754. /** @hidden */
  24755. _activate(renderId: number): void;
  24756. /**
  24757. * Gets the current world matrix
  24758. * @returns a Matrix
  24759. */
  24760. getWorldMatrix(): Matrix;
  24761. /** @hidden */
  24762. _getWorldMatrixDeterminant(): number;
  24763. /**
  24764. * Perform relative position change from the point of view of behind the front of the mesh.
  24765. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24766. * Supports definition of mesh facing forward or backward
  24767. * @param amountRight defines the distance on the right axis
  24768. * @param amountUp defines the distance on the up axis
  24769. * @param amountForward defines the distance on the forward axis
  24770. * @returns the current mesh
  24771. */
  24772. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  24773. /**
  24774. * Calculate relative position change from the point of view of behind the front of the mesh.
  24775. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24776. * Supports definition of mesh facing forward or backward
  24777. * @param amountRight defines the distance on the right axis
  24778. * @param amountUp defines the distance on the up axis
  24779. * @param amountForward defines the distance on the forward axis
  24780. * @returns the new displacement vector
  24781. */
  24782. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  24783. /**
  24784. * Perform relative rotation change from the point of view of behind the front of the mesh.
  24785. * Supports definition of mesh facing forward or backward
  24786. * @param flipBack defines the flip
  24787. * @param twirlClockwise defines the twirl
  24788. * @param tiltRight defines the tilt
  24789. * @returns the current mesh
  24790. */
  24791. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  24792. /**
  24793. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  24794. * Supports definition of mesh facing forward or backward.
  24795. * @param flipBack defines the flip
  24796. * @param twirlClockwise defines the twirl
  24797. * @param tiltRight defines the tilt
  24798. * @returns the new rotation vector
  24799. */
  24800. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  24801. /**
  24802. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  24803. * @param includeDescendants Include bounding info from descendants as well (true by default)
  24804. * @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
  24805. * @returns the new bounding vectors
  24806. */
  24807. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  24808. min: Vector3;
  24809. max: Vector3;
  24810. };
  24811. /**
  24812. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24813. * This means the mesh underlying bounding box and sphere are recomputed.
  24814. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24815. * @returns the current mesh
  24816. */
  24817. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  24818. /** @hidden */
  24819. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  24820. /** @hidden */
  24821. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  24822. /** @hidden */
  24823. _updateBoundingInfo(): AbstractMesh;
  24824. /** @hidden */
  24825. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  24826. /** @hidden */
  24827. protected _afterComputeWorldMatrix(): void;
  24828. /**
  24829. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24830. * A mesh is in the frustum if its bounding box intersects the frustum
  24831. * @param frustumPlanes defines the frustum to test
  24832. * @returns true if the mesh is in the frustum planes
  24833. */
  24834. isInFrustum(frustumPlanes: Plane[]): boolean;
  24835. /**
  24836. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  24837. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  24838. * @param frustumPlanes defines the frustum to test
  24839. * @returns true if the mesh is completely in the frustum planes
  24840. */
  24841. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24842. /**
  24843. * True if the mesh intersects another mesh or a SolidParticle object
  24844. * @param mesh defines a target mesh or SolidParticle to test
  24845. * @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)
  24846. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  24847. * @returns true if there is an intersection
  24848. */
  24849. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  24850. /**
  24851. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  24852. * @param point defines the point to test
  24853. * @returns true if there is an intersection
  24854. */
  24855. intersectsPoint(point: Vector3): boolean;
  24856. /**
  24857. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  24858. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24859. */
  24860. checkCollisions: boolean;
  24861. /**
  24862. * Gets Collider object used to compute collisions (not physics)
  24863. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24864. */
  24865. readonly collider: Collider;
  24866. /**
  24867. * Move the mesh using collision engine
  24868. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24869. * @param displacement defines the requested displacement vector
  24870. * @returns the current mesh
  24871. */
  24872. moveWithCollisions(displacement: Vector3): AbstractMesh;
  24873. private _onCollisionPositionChange;
  24874. /** @hidden */
  24875. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  24876. /** @hidden */
  24877. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  24878. /** @hidden */
  24879. _checkCollision(collider: Collider): AbstractMesh;
  24880. /** @hidden */
  24881. _generatePointsArray(): boolean;
  24882. /**
  24883. * Checks if the passed Ray intersects with the mesh
  24884. * @param ray defines the ray to use
  24885. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  24886. * @returns the picking info
  24887. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  24888. */
  24889. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  24890. /**
  24891. * Clones the current mesh
  24892. * @param name defines the mesh name
  24893. * @param newParent defines the new mesh parent
  24894. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  24895. * @returns the new mesh
  24896. */
  24897. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  24898. /**
  24899. * Disposes all the submeshes of the current meshnp
  24900. * @returns the current mesh
  24901. */
  24902. releaseSubMeshes(): AbstractMesh;
  24903. /**
  24904. * Releases resources associated with this abstract mesh.
  24905. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24906. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24907. */
  24908. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24909. /**
  24910. * Adds the passed mesh as a child to the current mesh
  24911. * @param mesh defines the child mesh
  24912. * @returns the current mesh
  24913. */
  24914. addChild(mesh: AbstractMesh): AbstractMesh;
  24915. /**
  24916. * Removes the passed mesh from the current mesh children list
  24917. * @param mesh defines the child mesh
  24918. * @returns the current mesh
  24919. */
  24920. removeChild(mesh: AbstractMesh): AbstractMesh;
  24921. /** @hidden */
  24922. private _initFacetData;
  24923. /**
  24924. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  24925. * This method can be called within the render loop.
  24926. * 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
  24927. * @returns the current mesh
  24928. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24929. */
  24930. updateFacetData(): AbstractMesh;
  24931. /**
  24932. * Returns the facetLocalNormals array.
  24933. * The normals are expressed in the mesh local spac
  24934. * @returns an array of Vector3
  24935. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24936. */
  24937. getFacetLocalNormals(): Vector3[];
  24938. /**
  24939. * Returns the facetLocalPositions array.
  24940. * The facet positions are expressed in the mesh local space
  24941. * @returns an array of Vector3
  24942. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24943. */
  24944. getFacetLocalPositions(): Vector3[];
  24945. /**
  24946. * Returns the facetLocalPartioning array
  24947. * @returns an array of array of numbers
  24948. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24949. */
  24950. getFacetLocalPartitioning(): number[][];
  24951. /**
  24952. * Returns the i-th facet position in the world system.
  24953. * This method allocates a new Vector3 per call
  24954. * @param i defines the facet index
  24955. * @returns a new Vector3
  24956. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24957. */
  24958. getFacetPosition(i: number): Vector3;
  24959. /**
  24960. * Sets the reference Vector3 with the i-th facet position in the world system
  24961. * @param i defines the facet index
  24962. * @param ref defines the target vector
  24963. * @returns the current mesh
  24964. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24965. */
  24966. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  24967. /**
  24968. * Returns the i-th facet normal in the world system.
  24969. * This method allocates a new Vector3 per call
  24970. * @param i defines the facet index
  24971. * @returns a new Vector3
  24972. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24973. */
  24974. getFacetNormal(i: number): Vector3;
  24975. /**
  24976. * Sets the reference Vector3 with the i-th facet normal in the world system
  24977. * @param i defines the facet index
  24978. * @param ref defines the target vector
  24979. * @returns the current mesh
  24980. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24981. */
  24982. getFacetNormalToRef(i: number, ref: Vector3): this;
  24983. /**
  24984. * 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)
  24985. * @param x defines x coordinate
  24986. * @param y defines y coordinate
  24987. * @param z defines z coordinate
  24988. * @returns the array of facet indexes
  24989. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24990. */
  24991. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  24992. /**
  24993. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  24994. * @param projected sets as the (x,y,z) world projection on the facet
  24995. * @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
  24996. * @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
  24997. * @param x defines x coordinate
  24998. * @param y defines y coordinate
  24999. * @param z defines z coordinate
  25000. * @returns the face index if found (or null instead)
  25001. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25002. */
  25003. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25004. /**
  25005. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  25006. * @param projected sets as the (x,y,z) local projection on the facet
  25007. * @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
  25008. * @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
  25009. * @param x defines x coordinate
  25010. * @param y defines y coordinate
  25011. * @param z defines z coordinate
  25012. * @returns the face index if found (or null instead)
  25013. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25014. */
  25015. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25016. /**
  25017. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  25018. * @returns the parameters
  25019. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25020. */
  25021. getFacetDataParameters(): any;
  25022. /**
  25023. * Disables the feature FacetData and frees the related memory
  25024. * @returns the current mesh
  25025. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25026. */
  25027. disableFacetData(): AbstractMesh;
  25028. /**
  25029. * Updates the AbstractMesh indices array
  25030. * @param indices defines the data source
  25031. * @returns the current mesh
  25032. */
  25033. updateIndices(indices: IndicesArray): AbstractMesh;
  25034. /**
  25035. * Creates new normals data for the mesh
  25036. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  25037. * @returns the current mesh
  25038. */
  25039. createNormals(updatable: boolean): AbstractMesh;
  25040. /**
  25041. * Align the mesh with a normal
  25042. * @param normal defines the normal to use
  25043. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  25044. * @returns the current mesh
  25045. */
  25046. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  25047. /** @hidden */
  25048. _checkOcclusionQuery(): boolean;
  25049. }
  25050. }
  25051. declare module BABYLON {
  25052. /**
  25053. * Class used to store data that will be store in GPU memory
  25054. */
  25055. class Buffer {
  25056. private _engine;
  25057. private _buffer;
  25058. /** @hidden */
  25059. _data: Nullable<DataArray>;
  25060. private _updatable;
  25061. private _instanced;
  25062. /**
  25063. * Gets the byte stride.
  25064. */
  25065. readonly byteStride: number;
  25066. /**
  25067. * Constructor
  25068. * @param engine the engine
  25069. * @param data the data to use for this buffer
  25070. * @param updatable whether the data is updatable
  25071. * @param stride the stride (optional)
  25072. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  25073. * @param instanced whether the buffer is instanced (optional)
  25074. * @param useBytes set to true if the stride in in bytes (optional)
  25075. */
  25076. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  25077. /**
  25078. * Create a new VertexBuffer based on the current buffer
  25079. * @param kind defines the vertex buffer kind (position, normal, etc.)
  25080. * @param offset defines offset in the buffer (0 by default)
  25081. * @param size defines the size in floats of attributes (position is 3 for instance)
  25082. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  25083. * @param instanced defines if the vertex buffer contains indexed data
  25084. * @param useBytes defines if the offset and stride are in bytes
  25085. * @returns the new vertex buffer
  25086. */
  25087. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  25088. /**
  25089. * Gets a boolean indicating if the Buffer is updatable?
  25090. * @returns true if the buffer is updatable
  25091. */
  25092. isUpdatable(): boolean;
  25093. /**
  25094. * Gets current buffer's data
  25095. * @returns a DataArray or null
  25096. */
  25097. getData(): Nullable<DataArray>;
  25098. /**
  25099. * Gets underlying native buffer
  25100. * @returns underlying native buffer
  25101. */
  25102. getBuffer(): Nullable<WebGLBuffer>;
  25103. /**
  25104. * Gets the stride in float32 units (i.e. byte stride / 4).
  25105. * May not be an integer if the byte stride is not divisible by 4.
  25106. * DEPRECATED. Use byteStride instead.
  25107. * @returns the stride in float32 units
  25108. */
  25109. getStrideSize(): number;
  25110. /**
  25111. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  25112. * @param data defines the data to store
  25113. */
  25114. create(data?: Nullable<DataArray>): void;
  25115. /** @hidden */
  25116. _rebuild(): void;
  25117. /**
  25118. * Update current buffer data
  25119. * @param data defines the data to store
  25120. */
  25121. update(data: DataArray): void;
  25122. /**
  25123. * Updates the data directly.
  25124. * @param data the new data
  25125. * @param offset the new offset
  25126. * @param vertexCount the vertex count (optional)
  25127. * @param useBytes set to true if the offset is in bytes
  25128. */
  25129. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  25130. /**
  25131. * Release all resources
  25132. */
  25133. dispose(): void;
  25134. }
  25135. }
  25136. declare module BABYLON {
  25137. /**
  25138. * Class for building Constructive Solid Geometry
  25139. */
  25140. class CSG {
  25141. private polygons;
  25142. /**
  25143. * The world matrix
  25144. */
  25145. matrix: Matrix;
  25146. /**
  25147. * Stores the position
  25148. */
  25149. position: Vector3;
  25150. /**
  25151. * Stores the rotation
  25152. */
  25153. rotation: Vector3;
  25154. /**
  25155. * Stores the rotation quaternion
  25156. */
  25157. rotationQuaternion: Nullable<Quaternion>;
  25158. /**
  25159. * Stores the scaling vector
  25160. */
  25161. scaling: Vector3;
  25162. /**
  25163. * Convert the BABYLON.Mesh to BABYLON.CSG
  25164. * @param mesh The BABYLON.Mesh to convert to BABYLON.CSG
  25165. * @returns A new BABYLON.CSG from the BABYLON.Mesh
  25166. */
  25167. static FromMesh(mesh: Mesh): CSG;
  25168. /**
  25169. * Construct a BABYLON.CSG solid from a list of `BABYLON.CSG.Polygon` instances.
  25170. * @param polygons Polygons used to construct a BABYLON.CSG solid
  25171. */
  25172. private static FromPolygons;
  25173. /**
  25174. * Clones, or makes a deep copy, of the BABYLON.CSG
  25175. * @returns A new BABYLON.CSG
  25176. */
  25177. clone(): CSG;
  25178. /**
  25179. * Unions this CSG with another CSG
  25180. * @param csg The CSG to union against this CSG
  25181. * @returns The unioned CSG
  25182. */
  25183. union(csg: CSG): CSG;
  25184. /**
  25185. * Unions this CSG with another CSG in place
  25186. * @param csg The CSG to union against this CSG
  25187. */
  25188. unionInPlace(csg: CSG): void;
  25189. /**
  25190. * Subtracts this CSG with another CSG
  25191. * @param csg The CSG to subtract against this CSG
  25192. * @returns A new BABYLON.CSG
  25193. */
  25194. subtract(csg: CSG): CSG;
  25195. /**
  25196. * Subtracts this CSG with another CSG in place
  25197. * @param csg The CSG to subtact against this CSG
  25198. */
  25199. subtractInPlace(csg: CSG): void;
  25200. /**
  25201. * Intersect this CSG with another CSG
  25202. * @param csg The CSG to intersect against this CSG
  25203. * @returns A new BABYLON.CSG
  25204. */
  25205. intersect(csg: CSG): CSG;
  25206. /**
  25207. * Intersects this CSG with another CSG in place
  25208. * @param csg The CSG to intersect against this CSG
  25209. */
  25210. intersectInPlace(csg: CSG): void;
  25211. /**
  25212. * Return a new BABYLON.CSG solid with solid and empty space switched. This solid is
  25213. * not modified.
  25214. * @returns A new BABYLON.CSG solid with solid and empty space switched
  25215. */
  25216. inverse(): CSG;
  25217. /**
  25218. * Inverses the BABYLON.CSG in place
  25219. */
  25220. inverseInPlace(): void;
  25221. /**
  25222. * This is used to keep meshes transformations so they can be restored
  25223. * when we build back a Babylon Mesh
  25224. * NB : All CSG operations are performed in world coordinates
  25225. * @param csg The BABYLON.CSG to copy the transform attributes from
  25226. * @returns This BABYLON.CSG
  25227. */
  25228. copyTransformAttributes(csg: CSG): CSG;
  25229. /**
  25230. * Build Raw mesh from CSG
  25231. * Coordinates here are in world space
  25232. * @param name The name of the mesh geometry
  25233. * @param scene The BABYLON.Scene
  25234. * @param keepSubMeshes Specifies if the submeshes should be kept
  25235. * @returns A new BABYLON.Mesh
  25236. */
  25237. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  25238. /**
  25239. * Build Mesh from CSG taking material and transforms into account
  25240. * @param name The name of the BABYLON.Mesh
  25241. * @param material The material of the BABYLON.Mesh
  25242. * @param scene The BABYLON.Scene
  25243. * @param keepSubMeshes Specifies if submeshes should be kept
  25244. * @returns The new BABYLON.Mesh
  25245. */
  25246. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  25247. }
  25248. }
  25249. declare module BABYLON {
  25250. /**
  25251. * Class used to store geometry data (vertex buffers + index buffer)
  25252. */
  25253. class Geometry implements IGetSetVerticesData {
  25254. /**
  25255. * Gets or sets the ID of the geometry
  25256. */
  25257. id: string;
  25258. /**
  25259. * Gets or sets the unique ID of the geometry
  25260. */
  25261. uniqueId: number;
  25262. /**
  25263. * Gets the delay loading state of the geometry (none by default which means not delayed)
  25264. */
  25265. delayLoadState: number;
  25266. /**
  25267. * Gets the file containing the data to load when running in delay load state
  25268. */
  25269. delayLoadingFile: Nullable<string>;
  25270. /**
  25271. * Callback called when the geometry is updated
  25272. */
  25273. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  25274. private _scene;
  25275. private _engine;
  25276. private _meshes;
  25277. private _totalVertices;
  25278. /** @hidden */
  25279. _indices: IndicesArray;
  25280. /** @hidden */
  25281. _vertexBuffers: {
  25282. [key: string]: VertexBuffer;
  25283. };
  25284. private _isDisposed;
  25285. private _extend;
  25286. private _boundingBias;
  25287. /** @hidden */
  25288. _delayInfo: Array<string>;
  25289. private _indexBuffer;
  25290. private _indexBufferIsUpdatable;
  25291. /** @hidden */
  25292. _boundingInfo: Nullable<BoundingInfo>;
  25293. /** @hidden */
  25294. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  25295. /** @hidden */
  25296. _softwareSkinningFrameId: number;
  25297. private _vertexArrayObjects;
  25298. private _updatable;
  25299. /** @hidden */
  25300. _positions: Nullable<Vector3[]>;
  25301. /**
  25302. * 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
  25303. */
  25304. /**
  25305. * 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
  25306. */
  25307. boundingBias: Vector2;
  25308. /**
  25309. * Static function used to attach a new empty geometry to a mesh
  25310. * @param mesh defines the mesh to attach the geometry to
  25311. * @returns the new Geometry
  25312. */
  25313. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  25314. /**
  25315. * Creates a new geometry
  25316. * @param id defines the unique ID
  25317. * @param scene defines the hosting scene
  25318. * @param vertexData defines the VertexData used to get geometry data
  25319. * @param updatable defines if geometry must be updatable (false by default)
  25320. * @param mesh defines the mesh that will be associated with the geometry
  25321. */
  25322. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  25323. /**
  25324. * Gets the current extend of the geometry
  25325. */
  25326. readonly extend: {
  25327. minimum: Vector3;
  25328. maximum: Vector3;
  25329. };
  25330. /**
  25331. * Gets the hosting scene
  25332. * @returns the hosting Scene
  25333. */
  25334. getScene(): Scene;
  25335. /**
  25336. * Gets the hosting engine
  25337. * @returns the hosting Engine
  25338. */
  25339. getEngine(): Engine;
  25340. /**
  25341. * Defines if the geometry is ready to use
  25342. * @returns true if the geometry is ready to be used
  25343. */
  25344. isReady(): boolean;
  25345. /**
  25346. * Gets a value indicating that the geometry should not be serialized
  25347. */
  25348. readonly doNotSerialize: boolean;
  25349. /** @hidden */
  25350. _rebuild(): void;
  25351. /**
  25352. * Affects all geometry data in one call
  25353. * @param vertexData defines the geometry data
  25354. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  25355. */
  25356. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  25357. /**
  25358. * Set specific vertex data
  25359. * @param kind defines the data kind (Position, normal, etc...)
  25360. * @param data defines the vertex data to use
  25361. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25362. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25363. */
  25364. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  25365. /**
  25366. * Removes a specific vertex data
  25367. * @param kind defines the data kind (Position, normal, etc...)
  25368. */
  25369. removeVerticesData(kind: string): void;
  25370. /**
  25371. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  25372. * @param buffer defines the vertex buffer to use
  25373. * @param totalVertices defines the total number of vertices for position kind (could be null)
  25374. */
  25375. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  25376. /**
  25377. * Update a specific vertex buffer
  25378. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  25379. * It will do nothing if the buffer is not updatable
  25380. * @param kind defines the data kind (Position, normal, etc...)
  25381. * @param data defines the data to use
  25382. * @param offset defines the offset in the target buffer where to store the data
  25383. * @param useBytes set to true if the offset is in bytes
  25384. */
  25385. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  25386. /**
  25387. * Update a specific vertex buffer
  25388. * This function will create a new buffer if the current one is not updatable
  25389. * @param kind defines the data kind (Position, normal, etc...)
  25390. * @param data defines the data to use
  25391. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  25392. */
  25393. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  25394. private _updateBoundingInfo;
  25395. /** @hidden */
  25396. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  25397. /**
  25398. * Gets total number of vertices
  25399. * @returns the total number of vertices
  25400. */
  25401. getTotalVertices(): number;
  25402. /**
  25403. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25404. * @param kind defines the data kind (Position, normal, etc...)
  25405. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25406. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25407. * @returns a float array containing vertex data
  25408. */
  25409. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25410. /**
  25411. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  25412. * @param kind defines the data kind (Position, normal, etc...)
  25413. * @returns true if the vertex buffer with the specified kind is updatable
  25414. */
  25415. isVertexBufferUpdatable(kind: string): boolean;
  25416. /**
  25417. * Gets a specific vertex buffer
  25418. * @param kind defines the data kind (Position, normal, etc...)
  25419. * @returns a VertexBuffer
  25420. */
  25421. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25422. /**
  25423. * Returns all vertex buffers
  25424. * @return an object holding all vertex buffers indexed by kind
  25425. */
  25426. getVertexBuffers(): Nullable<{
  25427. [key: string]: VertexBuffer;
  25428. }>;
  25429. /**
  25430. * Gets a boolean indicating if specific vertex buffer is present
  25431. * @param kind defines the data kind (Position, normal, etc...)
  25432. * @returns true if data is present
  25433. */
  25434. isVerticesDataPresent(kind: string): boolean;
  25435. /**
  25436. * Gets a list of all attached data kinds (Position, normal, etc...)
  25437. * @returns a list of string containing all kinds
  25438. */
  25439. getVerticesDataKinds(): string[];
  25440. /**
  25441. * Update index buffer
  25442. * @param indices defines the indices to store in the index buffer
  25443. * @param offset defines the offset in the target buffer where to store the data
  25444. */
  25445. updateIndices(indices: IndicesArray, offset?: number): void;
  25446. /**
  25447. * Creates a new index buffer
  25448. * @param indices defines the indices to store in the index buffer
  25449. * @param totalVertices defines the total number of vertices (could be null)
  25450. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25451. */
  25452. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  25453. /**
  25454. * Return the total number of indices
  25455. * @returns the total number of indices
  25456. */
  25457. getTotalIndices(): number;
  25458. /**
  25459. * Gets the index buffer array
  25460. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25461. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25462. * @returns the index buffer array
  25463. */
  25464. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25465. /**
  25466. * Gets the index buffer
  25467. * @return the index buffer
  25468. */
  25469. getIndexBuffer(): Nullable<WebGLBuffer>;
  25470. /** @hidden */
  25471. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  25472. /**
  25473. * Release the associated resources for a specific mesh
  25474. * @param mesh defines the source mesh
  25475. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  25476. */
  25477. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  25478. /**
  25479. * Apply current geometry to a given mesh
  25480. * @param mesh defines the mesh to apply geometry to
  25481. */
  25482. applyToMesh(mesh: Mesh): void;
  25483. private _updateExtend;
  25484. private _applyToMesh;
  25485. private notifyUpdate;
  25486. /**
  25487. * Load the geometry if it was flagged as delay loaded
  25488. * @param scene defines the hosting scene
  25489. * @param onLoaded defines a callback called when the geometry is loaded
  25490. */
  25491. load(scene: Scene, onLoaded?: () => void): void;
  25492. private _queueLoad;
  25493. /**
  25494. * Invert the geometry to move from a right handed system to a left handed one.
  25495. */
  25496. toLeftHanded(): void;
  25497. /** @hidden */
  25498. _resetPointsArrayCache(): void;
  25499. /** @hidden */
  25500. _generatePointsArray(): boolean;
  25501. /**
  25502. * Gets a value indicating if the geometry is disposed
  25503. * @returns true if the geometry was disposed
  25504. */
  25505. isDisposed(): boolean;
  25506. private _disposeVertexArrayObjects;
  25507. /**
  25508. * Free all associated resources
  25509. */
  25510. dispose(): void;
  25511. /**
  25512. * Clone the current geometry into a new geometry
  25513. * @param id defines the unique ID of the new geometry
  25514. * @returns a new geometry object
  25515. */
  25516. copy(id: string): Geometry;
  25517. /**
  25518. * Serialize the current geometry info (and not the vertices data) into a JSON object
  25519. * @return a JSON representation of the current geometry data (without the vertices data)
  25520. */
  25521. serialize(): any;
  25522. private toNumberArray;
  25523. /**
  25524. * Serialize all vertices data into a JSON oject
  25525. * @returns a JSON representation of the current geometry data
  25526. */
  25527. serializeVerticeData(): any;
  25528. /**
  25529. * Extracts a clone of a mesh geometry
  25530. * @param mesh defines the source mesh
  25531. * @param id defines the unique ID of the new geometry object
  25532. * @returns the new geometry object
  25533. */
  25534. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  25535. /**
  25536. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  25537. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  25538. * Be aware Math.random() could cause collisions, but:
  25539. * "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"
  25540. * @returns a string containing a new GUID
  25541. */
  25542. static RandomId(): string;
  25543. /** @hidden */
  25544. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  25545. private static _CleanMatricesWeights;
  25546. /**
  25547. * Create a new geometry from persisted data (Using .babylon file format)
  25548. * @param parsedVertexData defines the persisted data
  25549. * @param scene defines the hosting scene
  25550. * @param rootUrl defines the root url to use to load assets (like delayed data)
  25551. * @returns the new geometry object
  25552. */
  25553. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  25554. }
  25555. /**
  25556. * Abstract class used to provide common services for all typed geometries
  25557. * @hidden
  25558. */
  25559. class _PrimitiveGeometry extends Geometry {
  25560. private _canBeRegenerated;
  25561. private _beingRegenerated;
  25562. /**
  25563. * Creates a new typed geometry
  25564. * @param id defines the unique ID of the geometry
  25565. * @param scene defines the hosting scene
  25566. * @param _canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25567. * @param mesh defines the hosting mesh (can be null)
  25568. */
  25569. constructor(id: string, scene: Scene, _canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  25570. /**
  25571. * Gets a value indicating if the geometry supports being regenerated with new parameters (false by default)
  25572. * @returns true if the geometry can be regenerated
  25573. */
  25574. canBeRegenerated(): boolean;
  25575. /**
  25576. * If the geometry supports regeneration, the function will recreates the geometry with updated parameter values
  25577. */
  25578. regenerate(): void;
  25579. /**
  25580. * Clone the geometry
  25581. * @param id defines the unique ID of the new geometry
  25582. * @returns the new geometry
  25583. */
  25584. asNewGeometry(id: string): Geometry;
  25585. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  25586. setVerticesData(kind: string, data: FloatArray, updatable?: boolean): void;
  25587. /** @hidden */
  25588. _regenerateVertexData(): VertexData;
  25589. copy(id: string): Geometry;
  25590. serialize(): any;
  25591. }
  25592. /**
  25593. * Creates a ribbon geometry
  25594. * @description See http://doc.babylonjs.com/how_to/ribbon_tutorial, http://doc.babylonjs.com/resources/maths_make_ribbons
  25595. */
  25596. class RibbonGeometry extends _PrimitiveGeometry {
  25597. /**
  25598. * Defines the array of paths to use
  25599. */
  25600. pathArray: Vector3[][];
  25601. /**
  25602. * Defines if the last and first points of each path in your pathArray must be joined
  25603. */
  25604. closeArray: boolean;
  25605. /**
  25606. * Defines if the last and first points of each path in your pathArray must be joined
  25607. */
  25608. closePath: boolean;
  25609. /**
  25610. * Defines the offset between points
  25611. */
  25612. offset: number;
  25613. /**
  25614. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25615. */
  25616. side: number;
  25617. /**
  25618. * Creates a ribbon geometry
  25619. * @param id defines the unique ID of the geometry
  25620. * @param scene defines the hosting scene
  25621. * @param pathArray defines the array of paths to use
  25622. * @param closeArray defines if the last path and the first path must be joined
  25623. * @param closePath defines if the last and first points of each path in your pathArray must be joined
  25624. * @param offset defines the offset between points
  25625. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25626. * @param mesh defines the hosting mesh (can be null)
  25627. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25628. */
  25629. constructor(id: string, scene: Scene,
  25630. /**
  25631. * Defines the array of paths to use
  25632. */
  25633. pathArray: Vector3[][],
  25634. /**
  25635. * Defines if the last and first points of each path in your pathArray must be joined
  25636. */
  25637. closeArray: boolean,
  25638. /**
  25639. * Defines if the last and first points of each path in your pathArray must be joined
  25640. */
  25641. closePath: boolean,
  25642. /**
  25643. * Defines the offset between points
  25644. */
  25645. offset: number, canBeRegenerated?: boolean, mesh?: Mesh,
  25646. /**
  25647. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25648. */
  25649. side?: number);
  25650. /** @hidden */
  25651. _regenerateVertexData(): VertexData;
  25652. copy(id: string): Geometry;
  25653. }
  25654. /**
  25655. * Creates a box geometry
  25656. * @description see http://doc.babylonjs.com/how_to/set_shapes#box
  25657. */
  25658. class BoxGeometry extends _PrimitiveGeometry {
  25659. /**
  25660. * Defines the zise of the box (width, height and depth are the same)
  25661. */
  25662. size: number;
  25663. /**
  25664. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25665. */
  25666. side: number;
  25667. /**
  25668. * Creates a box geometry
  25669. * @param id defines the unique ID of the geometry
  25670. * @param scene defines the hosting scene
  25671. * @param size defines the zise of the box (width, height and depth are the same)
  25672. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25673. * @param mesh defines the hosting mesh (can be null)
  25674. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25675. */
  25676. constructor(id: string, scene: Scene,
  25677. /**
  25678. * Defines the zise of the box (width, height and depth are the same)
  25679. */
  25680. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25681. /**
  25682. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25683. */
  25684. side?: number);
  25685. /** @hidden */
  25686. _regenerateVertexData(): VertexData;
  25687. copy(id: string): Geometry;
  25688. serialize(): any;
  25689. static Parse(parsedBox: any, scene: Scene): Nullable<BoxGeometry>;
  25690. }
  25691. /**
  25692. * Creates a sphere geometry
  25693. * @description see http://doc.babylonjs.com/how_to/set_shapes#sphere
  25694. */
  25695. class SphereGeometry extends _PrimitiveGeometry {
  25696. /**
  25697. * Defines the number of segments to use to create the sphere
  25698. */
  25699. segments: number;
  25700. /**
  25701. * Defines the diameter of the sphere
  25702. */
  25703. diameter: number;
  25704. /**
  25705. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25706. */
  25707. side: number;
  25708. /**
  25709. * Create a new sphere geometry
  25710. * @param id defines the unique ID of the geometry
  25711. * @param scene defines the hosting scene
  25712. * @param segments defines the number of segments to use to create the sphere
  25713. * @param diameter defines the diameter of the sphere
  25714. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25715. * @param mesh defines the hosting mesh (can be null)
  25716. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25717. */
  25718. constructor(id: string, scene: Scene,
  25719. /**
  25720. * Defines the number of segments to use to create the sphere
  25721. */
  25722. segments: number,
  25723. /**
  25724. * Defines the diameter of the sphere
  25725. */
  25726. diameter: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25727. /**
  25728. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25729. */
  25730. side?: number);
  25731. /** @hidden */
  25732. _regenerateVertexData(): VertexData;
  25733. copy(id: string): Geometry;
  25734. serialize(): any;
  25735. static Parse(parsedSphere: any, scene: Scene): Nullable<SphereGeometry>;
  25736. }
  25737. /**
  25738. * Creates a disc geometry
  25739. * @description see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25740. */
  25741. class DiscGeometry extends _PrimitiveGeometry {
  25742. /**
  25743. * Defines the radius of the disc
  25744. */
  25745. radius: number;
  25746. /**
  25747. * Defines the tesselation factor to apply to the disc
  25748. */
  25749. tessellation: number;
  25750. /**
  25751. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25752. */
  25753. side: number;
  25754. /**
  25755. * Creates a new disc geometry
  25756. * @param id defines the unique ID of the geometry
  25757. * @param scene defines the hosting scene
  25758. * @param radius defines the radius of the disc
  25759. * @param tessellation defines the tesselation factor to apply to the disc
  25760. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25761. * @param mesh defines the hosting mesh (can be null)
  25762. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25763. */
  25764. constructor(id: string, scene: Scene,
  25765. /**
  25766. * Defines the radius of the disc
  25767. */
  25768. radius: number,
  25769. /**
  25770. * Defines the tesselation factor to apply to the disc
  25771. */
  25772. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25773. /**
  25774. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25775. */
  25776. side?: number);
  25777. /** @hidden */
  25778. _regenerateVertexData(): VertexData;
  25779. copy(id: string): Geometry;
  25780. }
  25781. /**
  25782. * Creates a new cylinder geometry
  25783. * @description see http://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  25784. */
  25785. class CylinderGeometry extends _PrimitiveGeometry {
  25786. /**
  25787. * Defines the height of the cylinder
  25788. */
  25789. height: number;
  25790. /**
  25791. * Defines the diameter of the cylinder's top cap
  25792. */
  25793. diameterTop: number;
  25794. /**
  25795. * Defines the diameter of the cylinder's bottom cap
  25796. */
  25797. diameterBottom: number;
  25798. /**
  25799. * Defines the tessellation factor to apply to the cylinder
  25800. */
  25801. tessellation: number;
  25802. /**
  25803. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  25804. */
  25805. subdivisions: number;
  25806. /**
  25807. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25808. */
  25809. side: number;
  25810. /**
  25811. * Creates a new cylinder geometry
  25812. * @param id defines the unique ID of the geometry
  25813. * @param scene defines the hosting scene
  25814. * @param height defines the height of the cylinder
  25815. * @param diameterTop defines the diameter of the cylinder's top cap
  25816. * @param diameterBottom defines the diameter of the cylinder's bottom cap
  25817. * @param tessellation defines the tessellation factor to apply to the cylinder (number of radial sides)
  25818. * @param subdivisions defines the number of subdivisions to apply to the cylinder (number of rings) (1 by default)
  25819. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25820. * @param mesh defines the hosting mesh (can be null)
  25821. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25822. */
  25823. constructor(id: string, scene: Scene,
  25824. /**
  25825. * Defines the height of the cylinder
  25826. */
  25827. height: number,
  25828. /**
  25829. * Defines the diameter of the cylinder's top cap
  25830. */
  25831. diameterTop: number,
  25832. /**
  25833. * Defines the diameter of the cylinder's bottom cap
  25834. */
  25835. diameterBottom: number,
  25836. /**
  25837. * Defines the tessellation factor to apply to the cylinder
  25838. */
  25839. tessellation: number,
  25840. /**
  25841. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  25842. */
  25843. subdivisions?: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25844. /**
  25845. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25846. */
  25847. side?: number);
  25848. /** @hidden */
  25849. _regenerateVertexData(): VertexData;
  25850. copy(id: string): Geometry;
  25851. serialize(): any;
  25852. static Parse(parsedCylinder: any, scene: Scene): Nullable<CylinderGeometry>;
  25853. }
  25854. /**
  25855. * Creates a new torus geometry
  25856. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus
  25857. */
  25858. class TorusGeometry extends _PrimitiveGeometry {
  25859. /**
  25860. * Defines the diameter of the torus
  25861. */
  25862. diameter: number;
  25863. /**
  25864. * Defines the thickness of the torus (ie. internal diameter)
  25865. */
  25866. thickness: number;
  25867. /**
  25868. * Defines the tesselation factor to apply to the torus
  25869. */
  25870. tessellation: number;
  25871. /**
  25872. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25873. */
  25874. side: number;
  25875. /**
  25876. * Creates a new torus geometry
  25877. * @param id defines the unique ID of the geometry
  25878. * @param scene defines the hosting scene
  25879. * @param diameter defines the diameter of the torus
  25880. * @param thickness defines the thickness of the torus (ie. internal diameter)
  25881. * @param tessellation defines the tesselation factor to apply to the torus (number of segments along the circle)
  25882. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25883. * @param mesh defines the hosting mesh (can be null)
  25884. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25885. */
  25886. constructor(id: string, scene: Scene,
  25887. /**
  25888. * Defines the diameter of the torus
  25889. */
  25890. diameter: number,
  25891. /**
  25892. * Defines the thickness of the torus (ie. internal diameter)
  25893. */
  25894. thickness: number,
  25895. /**
  25896. * Defines the tesselation factor to apply to the torus
  25897. */
  25898. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25899. /**
  25900. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25901. */
  25902. side?: number);
  25903. /** @hidden */
  25904. _regenerateVertexData(): VertexData;
  25905. copy(id: string): Geometry;
  25906. serialize(): any;
  25907. static Parse(parsedTorus: any, scene: Scene): Nullable<TorusGeometry>;
  25908. }
  25909. /**
  25910. * Creates a new ground geometry
  25911. * @description see http://doc.babylonjs.com/how_to/set_shapes#ground
  25912. */
  25913. class GroundGeometry extends _PrimitiveGeometry {
  25914. /**
  25915. * Defines the width of the ground
  25916. */
  25917. width: number;
  25918. /**
  25919. * Defines the height of the ground
  25920. */
  25921. height: number;
  25922. /**
  25923. * Defines the subdivisions to apply to the ground
  25924. */
  25925. subdivisions: number;
  25926. /**
  25927. * Creates a new ground geometry
  25928. * @param id defines the unique ID of the geometry
  25929. * @param scene defines the hosting scene
  25930. * @param width defines the width of the ground
  25931. * @param height defines the height of the ground
  25932. * @param subdivisions defines the subdivisions to apply to the ground
  25933. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25934. * @param mesh defines the hosting mesh (can be null)
  25935. */
  25936. constructor(id: string, scene: Scene,
  25937. /**
  25938. * Defines the width of the ground
  25939. */
  25940. width: number,
  25941. /**
  25942. * Defines the height of the ground
  25943. */
  25944. height: number,
  25945. /**
  25946. * Defines the subdivisions to apply to the ground
  25947. */
  25948. subdivisions: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  25949. /** @hidden */
  25950. _regenerateVertexData(): VertexData;
  25951. copy(id: string): Geometry;
  25952. serialize(): any;
  25953. static Parse(parsedGround: any, scene: Scene): Nullable<GroundGeometry>;
  25954. }
  25955. /**
  25956. * Creates a tiled ground geometry
  25957. * @description see http://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  25958. */
  25959. class TiledGroundGeometry extends _PrimitiveGeometry {
  25960. /**
  25961. * Defines the minimum value on X axis
  25962. */
  25963. xmin: number;
  25964. /**
  25965. * Defines the minimum value on Z axis
  25966. */
  25967. zmin: number;
  25968. /**
  25969. * Defines the maximum value on X axis
  25970. */
  25971. xmax: number;
  25972. /**
  25973. * Defines the maximum value on Z axis
  25974. */
  25975. zmax: number;
  25976. /**
  25977. * Defines the subdivisions to apply to the ground
  25978. */
  25979. subdivisions: {
  25980. w: number;
  25981. h: number;
  25982. };
  25983. /**
  25984. * Defines the precision to use when computing the tiles
  25985. */
  25986. precision: {
  25987. w: number;
  25988. h: number;
  25989. };
  25990. /**
  25991. * Creates a tiled ground geometry
  25992. * @param id defines the unique ID of the geometry
  25993. * @param scene defines the hosting scene
  25994. * @param xmin defines the minimum value on X axis
  25995. * @param zmin defines the minimum value on Z axis
  25996. * @param xmax defines the maximum value on X axis
  25997. * @param zmax defines the maximum value on Z axis
  25998. * @param subdivisions defines the subdivisions to apply to the ground (number of subdivisions (tiles) on the height and the width of the map)
  25999. * @param precision defines the precision to use when computing the tiles
  26000. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  26001. * @param mesh defines the hosting mesh (can be null)
  26002. */
  26003. constructor(id: string, scene: Scene,
  26004. /**
  26005. * Defines the minimum value on X axis
  26006. */
  26007. xmin: number,
  26008. /**
  26009. * Defines the minimum value on Z axis
  26010. */
  26011. zmin: number,
  26012. /**
  26013. * Defines the maximum value on X axis
  26014. */
  26015. xmax: number,
  26016. /**
  26017. * Defines the maximum value on Z axis
  26018. */
  26019. zmax: number,
  26020. /**
  26021. * Defines the subdivisions to apply to the ground
  26022. */
  26023. subdivisions: {
  26024. w: number;
  26025. h: number;
  26026. },
  26027. /**
  26028. * Defines the precision to use when computing the tiles
  26029. */
  26030. precision: {
  26031. w: number;
  26032. h: number;
  26033. }, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  26034. /** @hidden */
  26035. _regenerateVertexData(): VertexData;
  26036. copy(id: string): Geometry;
  26037. }
  26038. /**
  26039. * Creates a plane geometry
  26040. * @description see http://doc.babylonjs.com/how_to/set_shapes#plane
  26041. */
  26042. class PlaneGeometry extends _PrimitiveGeometry {
  26043. /**
  26044. * Defines the size of the plane (width === height)
  26045. */
  26046. size: number;
  26047. /**
  26048. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26049. */
  26050. side: number;
  26051. /**
  26052. * Creates a plane geometry
  26053. * @param id defines the unique ID of the geometry
  26054. * @param scene defines the hosting scene
  26055. * @param size defines the size of the plane (width === height)
  26056. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  26057. * @param mesh defines the hosting mesh (can be null)
  26058. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26059. */
  26060. constructor(id: string, scene: Scene,
  26061. /**
  26062. * Defines the size of the plane (width === height)
  26063. */
  26064. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  26065. /**
  26066. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26067. */
  26068. side?: number);
  26069. /** @hidden */
  26070. _regenerateVertexData(): VertexData;
  26071. copy(id: string): Geometry;
  26072. serialize(): any;
  26073. static Parse(parsedPlane: any, scene: Scene): Nullable<PlaneGeometry>;
  26074. }
  26075. /**
  26076. * Creates a torus knot geometry
  26077. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus-knot
  26078. */
  26079. class TorusKnotGeometry extends _PrimitiveGeometry {
  26080. /**
  26081. * Defines the radius of the torus knot
  26082. */
  26083. radius: number;
  26084. /**
  26085. * Defines the thickness of the torus knot tube
  26086. */
  26087. tube: number;
  26088. /**
  26089. * Defines the number of radial segments
  26090. */
  26091. radialSegments: number;
  26092. /**
  26093. * Defines the number of tubular segments
  26094. */
  26095. tubularSegments: number;
  26096. /**
  26097. * Defines the first number of windings
  26098. */
  26099. p: number;
  26100. /**
  26101. * Defines the second number of windings
  26102. */
  26103. q: number;
  26104. /**
  26105. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26106. */
  26107. side: number;
  26108. /**
  26109. * Creates a torus knot geometry
  26110. * @param id defines the unique ID of the geometry
  26111. * @param scene defines the hosting scene
  26112. * @param radius defines the radius of the torus knot
  26113. * @param tube defines the thickness of the torus knot tube
  26114. * @param radialSegments defines the number of radial segments
  26115. * @param tubularSegments defines the number of tubular segments
  26116. * @param p defines the first number of windings
  26117. * @param q defines the second number of windings
  26118. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  26119. * @param mesh defines the hosting mesh (can be null)
  26120. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26121. */
  26122. constructor(id: string, scene: Scene,
  26123. /**
  26124. * Defines the radius of the torus knot
  26125. */
  26126. radius: number,
  26127. /**
  26128. * Defines the thickness of the torus knot tube
  26129. */
  26130. tube: number,
  26131. /**
  26132. * Defines the number of radial segments
  26133. */
  26134. radialSegments: number,
  26135. /**
  26136. * Defines the number of tubular segments
  26137. */
  26138. tubularSegments: number,
  26139. /**
  26140. * Defines the first number of windings
  26141. */
  26142. p: number,
  26143. /**
  26144. * Defines the second number of windings
  26145. */
  26146. q: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  26147. /**
  26148. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26149. */
  26150. side?: number);
  26151. /** @hidden */
  26152. _regenerateVertexData(): VertexData;
  26153. copy(id: string): Geometry;
  26154. serialize(): any;
  26155. static Parse(parsedTorusKnot: any, scene: Scene): Nullable<TorusKnotGeometry>;
  26156. }
  26157. }
  26158. declare module BABYLON {
  26159. /**
  26160. * Mesh representing the gorund
  26161. */
  26162. class GroundMesh extends Mesh {
  26163. /** If octree should be generated */
  26164. generateOctree: boolean;
  26165. private _heightQuads;
  26166. /** @hidden */
  26167. _subdivisionsX: number;
  26168. /** @hidden */
  26169. _subdivisionsY: number;
  26170. /** @hidden */
  26171. _width: number;
  26172. /** @hidden */
  26173. _height: number;
  26174. /** @hidden */
  26175. _minX: number;
  26176. /** @hidden */
  26177. _maxX: number;
  26178. /** @hidden */
  26179. _minZ: number;
  26180. /** @hidden */
  26181. _maxZ: number;
  26182. constructor(name: string, scene: Scene);
  26183. /**
  26184. * "GroundMesh"
  26185. * @returns "GroundMesh"
  26186. */
  26187. getClassName(): string;
  26188. /**
  26189. * The minimum of x and y subdivisions
  26190. */
  26191. readonly subdivisions: number;
  26192. /**
  26193. * X subdivisions
  26194. */
  26195. readonly subdivisionsX: number;
  26196. /**
  26197. * Y subdivisions
  26198. */
  26199. readonly subdivisionsY: number;
  26200. /**
  26201. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  26202. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  26203. * @param chunksCount the number of subdivisions for x and y
  26204. * @param octreeBlocksSize (Default: 32)
  26205. */
  26206. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  26207. /**
  26208. * Returns a height (y) value in the Worl system :
  26209. * the ground altitude at the coordinates (x, z) expressed in the World system.
  26210. * @param x x coordinate
  26211. * @param z z coordinate
  26212. * @returns the ground y position if (x, z) are outside the ground surface.
  26213. */
  26214. getHeightAtCoordinates(x: number, z: number): number;
  26215. /**
  26216. * Returns a normalized vector (Vector3) orthogonal to the ground
  26217. * at the ground coordinates (x, z) expressed in the World system.
  26218. * @param x x coordinate
  26219. * @param z z coordinate
  26220. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  26221. */
  26222. getNormalAtCoordinates(x: number, z: number): Vector3;
  26223. /**
  26224. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  26225. * at the ground coordinates (x, z) expressed in the World system.
  26226. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  26227. * @param x x coordinate
  26228. * @param z z coordinate
  26229. * @param ref vector to store the result
  26230. * @returns the GroundMesh.
  26231. */
  26232. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  26233. /**
  26234. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  26235. * if the ground has been updated.
  26236. * This can be used in the render loop.
  26237. * @returns the GroundMesh.
  26238. */
  26239. updateCoordinateHeights(): GroundMesh;
  26240. private _getFacetAt;
  26241. private _initHeightQuads;
  26242. private _computeHeightQuads;
  26243. /**
  26244. * Serializes this ground mesh
  26245. * @param serializationObject object to write serialization to
  26246. */
  26247. serialize(serializationObject: any): void;
  26248. /**
  26249. * Parses a serialized ground mesh
  26250. * @param parsedMesh the serialized mesh
  26251. * @param scene the scene to create the ground mesh in
  26252. * @returns the created ground mesh
  26253. */
  26254. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  26255. }
  26256. }
  26257. declare module BABYLON {
  26258. /**
  26259. * Creates an instance based on a source mesh.
  26260. */
  26261. class InstancedMesh extends AbstractMesh {
  26262. private _sourceMesh;
  26263. private _currentLOD;
  26264. /** @hidden */
  26265. _indexInSourceMeshInstanceArray: number;
  26266. constructor(name: string, source: Mesh);
  26267. /**
  26268. * Returns the string "InstancedMesh".
  26269. */
  26270. getClassName(): string;
  26271. /**
  26272. * If the source mesh receives shadows
  26273. */
  26274. readonly receiveShadows: boolean;
  26275. /**
  26276. * The material of the source mesh
  26277. */
  26278. readonly material: Nullable<Material>;
  26279. /**
  26280. * Visibility of the source mesh
  26281. */
  26282. readonly visibility: number;
  26283. /**
  26284. * Skeleton of the source mesh
  26285. */
  26286. readonly skeleton: Nullable<Skeleton>;
  26287. /**
  26288. * Rendering ground id of the source mesh
  26289. */
  26290. renderingGroupId: number;
  26291. /**
  26292. * Returns the total number of vertices (integer).
  26293. */
  26294. getTotalVertices(): number;
  26295. /**
  26296. * Returns a positive integer : the total number of indices in this mesh geometry.
  26297. * @returns the numner of indices or zero if the mesh has no geometry.
  26298. */
  26299. getTotalIndices(): number;
  26300. /**
  26301. * The source mesh of the instance
  26302. */
  26303. readonly sourceMesh: Mesh;
  26304. /**
  26305. * Is this node ready to be used/rendered
  26306. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26307. * @return {boolean} is it ready
  26308. */
  26309. isReady(completeCheck?: boolean): boolean;
  26310. /**
  26311. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  26312. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  26313. * @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.
  26314. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  26315. */
  26316. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  26317. /**
  26318. * Sets the vertex data of the mesh geometry for the requested `kind`.
  26319. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  26320. * The `data` are either a numeric array either a Float32Array.
  26321. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  26322. * 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).
  26323. * Note that a new underlying VertexBuffer object is created each call.
  26324. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  26325. *
  26326. * Possible `kind` values :
  26327. * - BABYLON.VertexBuffer.PositionKind
  26328. * - BABYLON.VertexBuffer.UVKind
  26329. * - BABYLON.VertexBuffer.UV2Kind
  26330. * - BABYLON.VertexBuffer.UV3Kind
  26331. * - BABYLON.VertexBuffer.UV4Kind
  26332. * - BABYLON.VertexBuffer.UV5Kind
  26333. * - BABYLON.VertexBuffer.UV6Kind
  26334. * - BABYLON.VertexBuffer.ColorKind
  26335. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26336. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26337. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26338. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26339. *
  26340. * Returns the Mesh.
  26341. */
  26342. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  26343. /**
  26344. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  26345. * If the mesh has no geometry, it is simply returned as it is.
  26346. * The `data` are either a numeric array either a Float32Array.
  26347. * No new underlying VertexBuffer object is created.
  26348. * 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.
  26349. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  26350. *
  26351. * Possible `kind` values :
  26352. * - BABYLON.VertexBuffer.PositionKind
  26353. * - BABYLON.VertexBuffer.UVKind
  26354. * - BABYLON.VertexBuffer.UV2Kind
  26355. * - BABYLON.VertexBuffer.UV3Kind
  26356. * - BABYLON.VertexBuffer.UV4Kind
  26357. * - BABYLON.VertexBuffer.UV5Kind
  26358. * - BABYLON.VertexBuffer.UV6Kind
  26359. * - BABYLON.VertexBuffer.ColorKind
  26360. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26361. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26362. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26363. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26364. *
  26365. * Returns the Mesh.
  26366. */
  26367. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  26368. /**
  26369. * Sets the mesh indices.
  26370. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  26371. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  26372. * This method creates a new index buffer each call.
  26373. * Returns the Mesh.
  26374. */
  26375. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  26376. /**
  26377. * Boolean : True if the mesh owns the requested kind of data.
  26378. */
  26379. isVerticesDataPresent(kind: string): boolean;
  26380. /**
  26381. * Returns an array of indices (IndicesArray).
  26382. */
  26383. getIndices(): Nullable<IndicesArray>;
  26384. readonly _positions: Nullable<Vector3[]>;
  26385. /**
  26386. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26387. * This means the mesh underlying bounding box and sphere are recomputed.
  26388. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  26389. * @returns the current mesh
  26390. */
  26391. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  26392. /** @hidden */
  26393. _preActivate(): InstancedMesh;
  26394. /** @hidden */
  26395. _activate(renderId: number): InstancedMesh;
  26396. /**
  26397. * Returns the current associated LOD AbstractMesh.
  26398. */
  26399. getLOD(camera: Camera): AbstractMesh;
  26400. /** @hidden */
  26401. _syncSubMeshes(): InstancedMesh;
  26402. /** @hidden */
  26403. _generatePointsArray(): boolean;
  26404. /**
  26405. * Creates a new InstancedMesh from the current mesh.
  26406. * - name (string) : the cloned mesh name
  26407. * - newParent (optional Node) : the optional Node to parent the clone to.
  26408. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  26409. *
  26410. * Returns the clone.
  26411. */
  26412. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  26413. /**
  26414. * Disposes the InstancedMesh.
  26415. * Returns nothing.
  26416. */
  26417. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26418. }
  26419. }
  26420. declare module BABYLON {
  26421. /**
  26422. * Line mesh
  26423. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  26424. */
  26425. class LinesMesh extends Mesh {
  26426. /**
  26427. * If vertex color should be applied to the mesh
  26428. */
  26429. useVertexColor?: boolean | undefined;
  26430. /**
  26431. * If vertex alpha should be applied to the mesh
  26432. */
  26433. useVertexAlpha?: boolean | undefined;
  26434. /**
  26435. * Color of the line (Default: White)
  26436. */
  26437. color: Color3;
  26438. /**
  26439. * Alpha of the line (Default: 1)
  26440. */
  26441. alpha: number;
  26442. /**
  26443. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  26444. * This margin is expressed in world space coordinates, so its value may vary.
  26445. * Default value is 0.1
  26446. */
  26447. intersectionThreshold: number;
  26448. private _colorShader;
  26449. /**
  26450. * Creates a new LinesMesh
  26451. * @param name defines the name
  26452. * @param scene defines the hosting scene
  26453. * @param parent defines the parent mesh if any
  26454. * @param source defines the optional source LinesMesh used to clone data from
  26455. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  26456. * When false, achieved by calling a clone(), also passing False.
  26457. * This will make creation of children, recursive.
  26458. * @param useVertexColor defines if this LinesMesh supports vertex color
  26459. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  26460. */
  26461. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  26462. /**
  26463. * If vertex color should be applied to the mesh
  26464. */
  26465. useVertexColor?: boolean | undefined,
  26466. /**
  26467. * If vertex alpha should be applied to the mesh
  26468. */
  26469. useVertexAlpha?: boolean | undefined);
  26470. /**
  26471. * Returns the string "LineMesh"
  26472. */
  26473. getClassName(): string;
  26474. /**
  26475. * @hidden
  26476. */
  26477. /**
  26478. * @hidden
  26479. */
  26480. material: Material;
  26481. /**
  26482. * @hidden
  26483. */
  26484. readonly checkCollisions: boolean;
  26485. /** @hidden */
  26486. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  26487. /** @hidden */
  26488. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  26489. /**
  26490. * Disposes of the line mesh
  26491. * @param doNotRecurse If children should be disposed
  26492. */
  26493. dispose(doNotRecurse?: boolean): void;
  26494. /**
  26495. * Returns a new LineMesh object cloned from the current one.
  26496. */
  26497. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  26498. /**
  26499. * Creates a new InstancedLinesMesh object from the mesh model.
  26500. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  26501. * @param name defines the name of the new instance
  26502. * @returns a new InstancedLinesMesh
  26503. */
  26504. createInstance(name: string): InstancedLinesMesh;
  26505. }
  26506. /**
  26507. * Creates an instance based on a source LinesMesh
  26508. */
  26509. class InstancedLinesMesh extends InstancedMesh {
  26510. /**
  26511. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  26512. * This margin is expressed in world space coordinates, so its value may vary.
  26513. * Initilized with the intersectionThreshold value of the source LinesMesh
  26514. */
  26515. intersectionThreshold: number;
  26516. constructor(name: string, source: LinesMesh);
  26517. /**
  26518. * Returns the string "InstancedLinesMesh".
  26519. */
  26520. getClassName(): string;
  26521. }
  26522. }
  26523. declare module BABYLON {
  26524. /**
  26525. * @hidden
  26526. **/
  26527. class _CreationDataStorage {
  26528. closePath?: boolean;
  26529. closeArray?: boolean;
  26530. idx: number[];
  26531. dashSize: number;
  26532. gapSize: number;
  26533. path3D: Path3D;
  26534. pathArray: Vector3[][];
  26535. arc: number;
  26536. radius: number;
  26537. cap: number;
  26538. tessellation: number;
  26539. }
  26540. /**
  26541. * @hidden
  26542. **/
  26543. class _InstanceDataStorage {
  26544. visibleInstances: any;
  26545. renderIdForInstances: number[];
  26546. batchCache: _InstancesBatch;
  26547. instancesBufferSize: number;
  26548. instancesBuffer: Nullable<Buffer>;
  26549. instancesData: Float32Array;
  26550. overridenInstanceCount: number;
  26551. }
  26552. /**
  26553. * @hidden
  26554. **/
  26555. class _InstancesBatch {
  26556. mustReturn: boolean;
  26557. visibleInstances: Nullable<InstancedMesh[]>[];
  26558. renderSelf: boolean[];
  26559. }
  26560. /**
  26561. * Class used to represent renderable models
  26562. */
  26563. class Mesh extends AbstractMesh implements IGetSetVerticesData {
  26564. /**
  26565. * Mesh side orientation : usually the external or front surface
  26566. */
  26567. static readonly FRONTSIDE: number;
  26568. /**
  26569. * Mesh side orientation : usually the internal or back surface
  26570. */
  26571. static readonly BACKSIDE: number;
  26572. /**
  26573. * Mesh side orientation : both internal and external or front and back surfaces
  26574. */
  26575. static readonly DOUBLESIDE: number;
  26576. /**
  26577. * Mesh side orientation : by default, `FRONTSIDE`
  26578. */
  26579. static readonly DEFAULTSIDE: number;
  26580. /**
  26581. * Mesh cap setting : no cap
  26582. */
  26583. static readonly NO_CAP: number;
  26584. /**
  26585. * Mesh cap setting : one cap at the beginning of the mesh
  26586. */
  26587. static readonly CAP_START: number;
  26588. /**
  26589. * Mesh cap setting : one cap at the end of the mesh
  26590. */
  26591. static readonly CAP_END: number;
  26592. /**
  26593. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  26594. */
  26595. static readonly CAP_ALL: number;
  26596. private _onBeforeRenderObservable;
  26597. private _onAfterRenderObservable;
  26598. private _onBeforeDrawObservable;
  26599. /**
  26600. * An event triggered before rendering the mesh
  26601. */
  26602. readonly onBeforeRenderObservable: Observable<Mesh>;
  26603. /**
  26604. * An event triggered after rendering the mesh
  26605. */
  26606. readonly onAfterRenderObservable: Observable<Mesh>;
  26607. /**
  26608. * An event triggered before drawing the mesh
  26609. */
  26610. readonly onBeforeDrawObservable: Observable<Mesh>;
  26611. private _onBeforeDrawObserver;
  26612. /**
  26613. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  26614. */
  26615. onBeforeDraw: () => void;
  26616. /**
  26617. * Gets the delay loading state of the mesh (when delay loading is turned on)
  26618. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  26619. */
  26620. delayLoadState: number;
  26621. /**
  26622. * Gets the list of instances created from this mesh
  26623. * it is not supposed to be modified manually.
  26624. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  26625. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  26626. */
  26627. instances: InstancedMesh[];
  26628. /**
  26629. * Gets the file containing delay loading data for this mesh
  26630. */
  26631. delayLoadingFile: string;
  26632. /** @hidden */
  26633. _binaryInfo: any;
  26634. private _LODLevels;
  26635. /**
  26636. * User defined function used to change how LOD level selection is done
  26637. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  26638. */
  26639. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  26640. private _morphTargetManager;
  26641. /**
  26642. * Gets or sets the morph target manager
  26643. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26644. */
  26645. morphTargetManager: Nullable<MorphTargetManager>;
  26646. /** @hidden */
  26647. _creationDataStorage: Nullable<_CreationDataStorage>;
  26648. /** @hidden */
  26649. _geometry: Nullable<Geometry>;
  26650. /** @hidden */
  26651. _delayInfo: Array<string>;
  26652. /** @hidden */
  26653. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  26654. /** @hidden */
  26655. _instanceDataStorage: _InstanceDataStorage;
  26656. private _effectiveMaterial;
  26657. /** @hidden */
  26658. _shouldGenerateFlatShading: boolean;
  26659. private _preActivateId;
  26660. /** @hidden */
  26661. _originalBuilderSideOrientation: number;
  26662. /**
  26663. * Use this property to change the original side orientation defined at construction time
  26664. */
  26665. overrideMaterialSideOrientation: Nullable<number>;
  26666. private _areNormalsFrozen;
  26667. private _sourcePositions;
  26668. private _sourceNormals;
  26669. private _source;
  26670. private meshMap;
  26671. /**
  26672. * Gets the source mesh (the one used to clone this one from)
  26673. */
  26674. readonly source: Nullable<Mesh>;
  26675. /**
  26676. * Gets or sets a boolean indicating that this mesh does not use index buffer
  26677. */
  26678. isUnIndexed: boolean;
  26679. /**
  26680. * @constructor
  26681. * @param name The value used by scene.getMeshByName() to do a lookup.
  26682. * @param scene The scene to add this mesh to.
  26683. * @param parent The parent of this mesh, if it has one
  26684. * @param source An optional Mesh from which geometry is shared, cloned.
  26685. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  26686. * When false, achieved by calling a clone(), also passing False.
  26687. * This will make creation of children, recursive.
  26688. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  26689. */
  26690. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  26691. /**
  26692. * Gets the class name
  26693. * @returns the string "Mesh".
  26694. */
  26695. getClassName(): string;
  26696. /**
  26697. * Returns a description of this mesh
  26698. * @param fullDetails define if full details about this mesh must be used
  26699. * @returns a descriptive string representing this mesh
  26700. */
  26701. toString(fullDetails?: boolean): string;
  26702. /** @hidden */
  26703. _unBindEffect(): void;
  26704. /**
  26705. * Gets a boolean indicating if this mesh has LOD
  26706. */
  26707. readonly hasLODLevels: boolean;
  26708. /**
  26709. * Gets the list of MeshLODLevel associated with the current mesh
  26710. * @returns an array of MeshLODLevel
  26711. */
  26712. getLODLevels(): MeshLODLevel[];
  26713. private _sortLODLevels;
  26714. /**
  26715. * Add a mesh as LOD level triggered at the given distance.
  26716. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26717. * @param distance The distance from the center of the object to show this level
  26718. * @param mesh The mesh to be added as LOD level (can be null)
  26719. * @return This mesh (for chaining)
  26720. */
  26721. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  26722. /**
  26723. * Returns the LOD level mesh at the passed distance or null if not found.
  26724. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26725. * @param distance The distance from the center of the object to show this level
  26726. * @returns a Mesh or `null`
  26727. */
  26728. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  26729. /**
  26730. * Remove a mesh from the LOD array
  26731. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26732. * @param mesh defines the mesh to be removed
  26733. * @return This mesh (for chaining)
  26734. */
  26735. removeLODLevel(mesh: Mesh): Mesh;
  26736. /**
  26737. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  26738. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26739. * @param camera defines the camera to use to compute distance
  26740. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  26741. * @return This mesh (for chaining)
  26742. */
  26743. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  26744. /**
  26745. * Gets the mesh internal Geometry object
  26746. */
  26747. readonly geometry: Nullable<Geometry>;
  26748. /**
  26749. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  26750. * @returns the total number of vertices
  26751. */
  26752. getTotalVertices(): number;
  26753. /**
  26754. * Returns the content of an associated vertex buffer
  26755. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  26756. * - BABYLON.VertexBuffer.PositionKind
  26757. * - BABYLON.VertexBuffer.UVKind
  26758. * - BABYLON.VertexBuffer.UV2Kind
  26759. * - BABYLON.VertexBuffer.UV3Kind
  26760. * - BABYLON.VertexBuffer.UV4Kind
  26761. * - BABYLON.VertexBuffer.UV5Kind
  26762. * - BABYLON.VertexBuffer.UV6Kind
  26763. * - BABYLON.VertexBuffer.ColorKind
  26764. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26765. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26766. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26767. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26768. * @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
  26769. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  26770. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  26771. */
  26772. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  26773. /**
  26774. * Returns the mesh VertexBuffer object from the requested `kind`
  26775. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  26776. * - BABYLON.VertexBuffer.PositionKind
  26777. * - BABYLON.VertexBuffer.UVKind
  26778. * - BABYLON.VertexBuffer.UV2Kind
  26779. * - BABYLON.VertexBuffer.UV3Kind
  26780. * - BABYLON.VertexBuffer.UV4Kind
  26781. * - BABYLON.VertexBuffer.UV5Kind
  26782. * - BABYLON.VertexBuffer.UV6Kind
  26783. * - BABYLON.VertexBuffer.ColorKind
  26784. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26785. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26786. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26787. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26788. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  26789. */
  26790. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  26791. /**
  26792. * Tests if a specific vertex buffer is associated with this mesh
  26793. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  26794. * - BABYLON.VertexBuffer.PositionKind
  26795. * - BABYLON.VertexBuffer.UVKind
  26796. * - BABYLON.VertexBuffer.UV2Kind
  26797. * - BABYLON.VertexBuffer.UV3Kind
  26798. * - BABYLON.VertexBuffer.UV4Kind
  26799. * - BABYLON.VertexBuffer.UV5Kind
  26800. * - BABYLON.VertexBuffer.UV6Kind
  26801. * - BABYLON.VertexBuffer.ColorKind
  26802. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26803. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26804. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26805. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26806. * @returns a boolean
  26807. */
  26808. isVerticesDataPresent(kind: string): boolean;
  26809. /**
  26810. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  26811. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  26812. * - BABYLON.VertexBuffer.PositionKind
  26813. * - BABYLON.VertexBuffer.UVKind
  26814. * - BABYLON.VertexBuffer.UV2Kind
  26815. * - BABYLON.VertexBuffer.UV3Kind
  26816. * - BABYLON.VertexBuffer.UV4Kind
  26817. * - BABYLON.VertexBuffer.UV5Kind
  26818. * - BABYLON.VertexBuffer.UV6Kind
  26819. * - BABYLON.VertexBuffer.ColorKind
  26820. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26821. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26822. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26823. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26824. * @returns a boolean
  26825. */
  26826. isVertexBufferUpdatable(kind: string): boolean;
  26827. /**
  26828. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  26829. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  26830. * - BABYLON.VertexBuffer.PositionKind
  26831. * - BABYLON.VertexBuffer.UVKind
  26832. * - BABYLON.VertexBuffer.UV2Kind
  26833. * - BABYLON.VertexBuffer.UV3Kind
  26834. * - BABYLON.VertexBuffer.UV4Kind
  26835. * - BABYLON.VertexBuffer.UV5Kind
  26836. * - BABYLON.VertexBuffer.UV6Kind
  26837. * - BABYLON.VertexBuffer.ColorKind
  26838. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26839. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26840. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26841. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26842. * @returns an array of strings
  26843. */
  26844. getVerticesDataKinds(): string[];
  26845. /**
  26846. * Returns a positive integer : the total number of indices in this mesh geometry.
  26847. * @returns the numner of indices or zero if the mesh has no geometry.
  26848. */
  26849. getTotalIndices(): number;
  26850. /**
  26851. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  26852. * @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.
  26853. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26854. * @returns the indices array or an empty array if the mesh has no geometry
  26855. */
  26856. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  26857. readonly isBlocked: boolean;
  26858. /**
  26859. * Determine if the current mesh is ready to be rendered
  26860. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26861. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  26862. * @returns true if all associated assets are ready (material, textures, shaders)
  26863. */
  26864. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  26865. /**
  26866. * 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.
  26867. */
  26868. readonly areNormalsFrozen: boolean;
  26869. /**
  26870. * 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.
  26871. * @returns the current mesh
  26872. */
  26873. freezeNormals(): Mesh;
  26874. /**
  26875. * 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
  26876. * @returns the current mesh
  26877. */
  26878. unfreezeNormals(): Mesh;
  26879. /**
  26880. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  26881. */
  26882. overridenInstanceCount: number;
  26883. /** @hidden */
  26884. _preActivate(): Mesh;
  26885. /** @hidden */
  26886. _preActivateForIntermediateRendering(renderId: number): Mesh;
  26887. /** @hidden */
  26888. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  26889. /**
  26890. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26891. * This means the mesh underlying bounding box and sphere are recomputed.
  26892. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  26893. * @returns the current mesh
  26894. */
  26895. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  26896. /** @hidden */
  26897. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  26898. /**
  26899. * This function will subdivide the mesh into multiple submeshes
  26900. * @param count defines the expected number of submeshes
  26901. */
  26902. subdivide(count: number): void;
  26903. /**
  26904. * Copy a FloatArray into a specific associated vertex buffer
  26905. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  26906. * - BABYLON.VertexBuffer.PositionKind
  26907. * - BABYLON.VertexBuffer.UVKind
  26908. * - BABYLON.VertexBuffer.UV2Kind
  26909. * - BABYLON.VertexBuffer.UV3Kind
  26910. * - BABYLON.VertexBuffer.UV4Kind
  26911. * - BABYLON.VertexBuffer.UV5Kind
  26912. * - BABYLON.VertexBuffer.UV6Kind
  26913. * - BABYLON.VertexBuffer.ColorKind
  26914. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26915. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26916. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26917. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26918. * @param data defines the data source
  26919. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  26920. * @param stride defines the data stride size (can be null)
  26921. * @returns the current mesh
  26922. */
  26923. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  26924. /**
  26925. * Flags an associated vertex buffer as updatable
  26926. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  26927. * - BABYLON.VertexBuffer.PositionKind
  26928. * - BABYLON.VertexBuffer.UVKind
  26929. * - BABYLON.VertexBuffer.UV2Kind
  26930. * - BABYLON.VertexBuffer.UV3Kind
  26931. * - BABYLON.VertexBuffer.UV4Kind
  26932. * - BABYLON.VertexBuffer.UV5Kind
  26933. * - BABYLON.VertexBuffer.UV6Kind
  26934. * - BABYLON.VertexBuffer.ColorKind
  26935. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26936. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26937. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26938. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26939. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  26940. */
  26941. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  26942. /**
  26943. * Sets the mesh global Vertex Buffer
  26944. * @param buffer defines the buffer to use
  26945. * @returns the current mesh
  26946. */
  26947. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  26948. /**
  26949. * Update a specific associated vertex buffer
  26950. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  26951. * - BABYLON.VertexBuffer.PositionKind
  26952. * - BABYLON.VertexBuffer.UVKind
  26953. * - BABYLON.VertexBuffer.UV2Kind
  26954. * - BABYLON.VertexBuffer.UV3Kind
  26955. * - BABYLON.VertexBuffer.UV4Kind
  26956. * - BABYLON.VertexBuffer.UV5Kind
  26957. * - BABYLON.VertexBuffer.UV6Kind
  26958. * - BABYLON.VertexBuffer.ColorKind
  26959. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26960. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26961. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26962. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26963. * @param data defines the data source
  26964. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  26965. * @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)
  26966. * @returns the current mesh
  26967. */
  26968. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  26969. /**
  26970. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  26971. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  26972. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  26973. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  26974. * @returns the current mesh
  26975. */
  26976. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  26977. /**
  26978. * Creates a un-shared specific occurence of the geometry for the mesh.
  26979. * @returns the current mesh
  26980. */
  26981. makeGeometryUnique(): Mesh;
  26982. /**
  26983. * Set the index buffer of this mesh
  26984. * @param indices defines the source data
  26985. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  26986. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  26987. * @returns the current mesh
  26988. */
  26989. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  26990. /**
  26991. * Update the current index buffer
  26992. * @param indices defines the source data
  26993. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  26994. * @returns the current mesh
  26995. */
  26996. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  26997. /**
  26998. * Invert the geometry to move from a right handed system to a left handed one.
  26999. * @returns the current mesh
  27000. */
  27001. toLeftHanded(): Mesh;
  27002. /** @hidden */
  27003. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  27004. /** @hidden */
  27005. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  27006. /**
  27007. * Registers for this mesh a javascript function called just before the rendering process
  27008. * @param func defines the function to call before rendering this mesh
  27009. * @returns the current mesh
  27010. */
  27011. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  27012. /**
  27013. * Disposes a previously registered javascript function called before the rendering
  27014. * @param func defines the function to remove
  27015. * @returns the current mesh
  27016. */
  27017. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  27018. /**
  27019. * Registers for this mesh a javascript function called just after the rendering is complete
  27020. * @param func defines the function to call after rendering this mesh
  27021. * @returns the current mesh
  27022. */
  27023. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  27024. /**
  27025. * Disposes a previously registered javascript function called after the rendering.
  27026. * @param func defines the function to remove
  27027. * @returns the current mesh
  27028. */
  27029. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  27030. /** @hidden */
  27031. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  27032. /** @hidden */
  27033. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  27034. /** @hidden */
  27035. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  27036. /**
  27037. * 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
  27038. * @param subMesh defines the subMesh to render
  27039. * @param enableAlphaMode defines if alpha mode can be changed
  27040. * @returns the current mesh
  27041. */
  27042. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  27043. private _onBeforeDraw;
  27044. /**
  27045. * Renormalize the mesh and patch it up if there are no weights
  27046. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  27047. * However in the case of zero weights then we set just a single influence to 1.
  27048. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  27049. */
  27050. cleanMatrixWeights(): void;
  27051. private normalizeSkinFourWeights;
  27052. private normalizeSkinWeightsAndExtra;
  27053. /**
  27054. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  27055. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  27056. * the user know there was an issue with importing the mesh
  27057. * @returns a validation object with skinned, valid and report string
  27058. */
  27059. validateSkinning(): {
  27060. skinned: boolean;
  27061. valid: boolean;
  27062. report: string;
  27063. };
  27064. /** @hidden */
  27065. _checkDelayState(): Mesh;
  27066. private _queueLoad;
  27067. /**
  27068. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  27069. * A mesh is in the frustum if its bounding box intersects the frustum
  27070. * @param frustumPlanes defines the frustum to test
  27071. * @returns true if the mesh is in the frustum planes
  27072. */
  27073. isInFrustum(frustumPlanes: Plane[]): boolean;
  27074. /**
  27075. * Sets the mesh material by the material or multiMaterial `id` property
  27076. * @param id is a string identifying the material or the multiMaterial
  27077. * @returns the current mesh
  27078. */
  27079. setMaterialByID(id: string): Mesh;
  27080. /**
  27081. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  27082. * @returns an array of IAnimatable
  27083. */
  27084. getAnimatables(): IAnimatable[];
  27085. /**
  27086. * Modifies the mesh geometry according to the passed transformation matrix.
  27087. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  27088. * The mesh normals are modified using the same transformation.
  27089. * Note that, under the hood, this method sets a new VertexBuffer each call.
  27090. * @param transform defines the transform matrix to use
  27091. * @see http://doc.babylonjs.com/resources/baking_transformations
  27092. * @returns the current mesh
  27093. */
  27094. bakeTransformIntoVertices(transform: Matrix): Mesh;
  27095. /**
  27096. * Modifies the mesh geometry according to its own current World Matrix.
  27097. * The mesh World Matrix is then reset.
  27098. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  27099. * Note that, under the hood, this method sets a new VertexBuffer each call.
  27100. * @see http://doc.babylonjs.com/resources/baking_transformations
  27101. * @returns the current mesh
  27102. */
  27103. bakeCurrentTransformIntoVertices(): Mesh;
  27104. /** @hidden */
  27105. readonly _positions: Nullable<Vector3[]>;
  27106. /** @hidden */
  27107. _resetPointsArrayCache(): Mesh;
  27108. /** @hidden */
  27109. _generatePointsArray(): boolean;
  27110. /**
  27111. * Returns a new Mesh object generated from the current mesh properties.
  27112. * This method must not get confused with createInstance()
  27113. * @param name is a string, the name given to the new mesh
  27114. * @param newParent can be any Node object (default `null`)
  27115. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  27116. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  27117. * @returns a new mesh
  27118. */
  27119. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  27120. /**
  27121. * Releases resources associated with this mesh.
  27122. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27123. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27124. */
  27125. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27126. /**
  27127. * Modifies the mesh geometry according to a displacement map.
  27128. * 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.
  27129. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  27130. * @param url is a string, the URL from the image file is to be downloaded.
  27131. * @param minHeight is the lower limit of the displacement.
  27132. * @param maxHeight is the upper limit of the displacement.
  27133. * @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.
  27134. * @param uvOffset is an optional vector2 used to offset UV.
  27135. * @param uvScale is an optional vector2 used to scale UV.
  27136. * @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.
  27137. * @returns the Mesh.
  27138. */
  27139. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  27140. /**
  27141. * Modifies the mesh geometry according to a displacementMap buffer.
  27142. * 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.
  27143. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  27144. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  27145. * @param heightMapWidth is the width of the buffer image.
  27146. * @param heightMapHeight is the height of the buffer image.
  27147. * @param minHeight is the lower limit of the displacement.
  27148. * @param maxHeight is the upper limit of the displacement.
  27149. * @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.
  27150. * @param uvOffset is an optional vector2 used to offset UV.
  27151. * @param uvScale is an optional vector2 used to scale UV.
  27152. * @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.
  27153. * @returns the Mesh.
  27154. */
  27155. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  27156. /**
  27157. * Modify the mesh to get a flat shading rendering.
  27158. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  27159. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  27160. * @returns current mesh
  27161. */
  27162. convertToFlatShadedMesh(): Mesh;
  27163. /**
  27164. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  27165. * In other words, more vertices, no more indices and a single bigger VBO.
  27166. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  27167. * @returns current mesh
  27168. */
  27169. convertToUnIndexedMesh(): Mesh;
  27170. /**
  27171. * Inverses facet orientations.
  27172. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  27173. * @param flipNormals will also inverts the normals
  27174. * @returns current mesh
  27175. */
  27176. flipFaces(flipNormals?: boolean): Mesh;
  27177. /**
  27178. * Creates a new InstancedMesh object from the mesh model.
  27179. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  27180. * @param name defines the name of the new instance
  27181. * @returns a new InstancedMesh
  27182. */
  27183. createInstance(name: string): InstancedMesh;
  27184. /**
  27185. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  27186. * After this call, all the mesh instances have the same submeshes than the current mesh.
  27187. * @returns the current mesh
  27188. */
  27189. synchronizeInstances(): Mesh;
  27190. /**
  27191. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  27192. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  27193. * This should be used together with the simplification to avoid disappearing triangles.
  27194. * @param successCallback an optional success callback to be called after the optimization finished.
  27195. * @returns the current mesh
  27196. */
  27197. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  27198. /**
  27199. * Serialize current mesh
  27200. * @param serializationObject defines the object which will receive the serialization data
  27201. */
  27202. serialize(serializationObject: any): void;
  27203. /** @hidden */
  27204. _syncGeometryWithMorphTargetManager(): void;
  27205. /**
  27206. * Returns a new Mesh object parsed from the source provided.
  27207. * @param parsedMesh is the source
  27208. * @param scene defines the hosting scene
  27209. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  27210. * @returns a new Mesh
  27211. */
  27212. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  27213. /**
  27214. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  27215. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  27216. * @param name defines the name of the mesh to create
  27217. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  27218. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  27219. * @param closePath creates a seam between the first and the last points of each path of the path array
  27220. * @param offset is taken in account only if the `pathArray` is containing a single path
  27221. * @param scene defines the hosting scene
  27222. * @param updatable defines if the mesh must be flagged as updatable
  27223. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27224. * @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)
  27225. * @returns a new Mesh
  27226. */
  27227. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean | undefined, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  27228. /**
  27229. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  27230. * @param name defines the name of the mesh to create
  27231. * @param radius sets the radius size (float) of the polygon (default 0.5)
  27232. * @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
  27233. * @param scene defines the hosting scene
  27234. * @param updatable defines if the mesh must be flagged as updatable
  27235. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27236. * @returns a new Mesh
  27237. */
  27238. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  27239. /**
  27240. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  27241. * @param name defines the name of the mesh to create
  27242. * @param size sets the size (float) of each box side (default 1)
  27243. * @param scene defines the hosting scene
  27244. * @param updatable defines if the mesh must be flagged as updatable
  27245. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27246. * @returns a new Mesh
  27247. */
  27248. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  27249. /**
  27250. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  27251. * @param name defines the name of the mesh to create
  27252. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  27253. * @param diameter sets the diameter size (float) of the sphere (default 1)
  27254. * @param scene defines the hosting scene
  27255. * @param updatable defines if the mesh must be flagged as updatable
  27256. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27257. * @returns a new Mesh
  27258. */
  27259. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27260. /**
  27261. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  27262. * @param name defines the name of the mesh to create
  27263. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  27264. * @param diameterTop set the top cap diameter (floats, default 1)
  27265. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  27266. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  27267. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  27268. * @param scene defines the hosting scene
  27269. * @param updatable defines if the mesh must be flagged as updatable
  27270. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27271. * @returns a new Mesh
  27272. */
  27273. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  27274. /**
  27275. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  27276. * @param name defines the name of the mesh to create
  27277. * @param diameter sets the diameter size (float) of the torus (default 1)
  27278. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  27279. * @param tessellation sets the number of torus sides (postive integer, default 16)
  27280. * @param scene defines the hosting scene
  27281. * @param updatable defines if the mesh must be flagged as updatable
  27282. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27283. * @returns a new Mesh
  27284. */
  27285. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27286. /**
  27287. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  27288. * @param name defines the name of the mesh to create
  27289. * @param radius sets the global radius size (float) of the torus knot (default 2)
  27290. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  27291. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  27292. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  27293. * @param p the number of windings on X axis (positive integers, default 2)
  27294. * @param q the number of windings on Y axis (positive integers, default 3)
  27295. * @param scene defines the hosting scene
  27296. * @param updatable defines if the mesh must be flagged as updatable
  27297. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27298. * @returns a new Mesh
  27299. */
  27300. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27301. /**
  27302. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  27303. * @param name defines the name of the mesh to create
  27304. * @param points is an array successive Vector3
  27305. * @param scene defines the hosting scene
  27306. * @param updatable defines if the mesh must be flagged as updatable
  27307. * @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).
  27308. * @returns a new Mesh
  27309. */
  27310. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  27311. /**
  27312. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  27313. * @param name defines the name of the mesh to create
  27314. * @param points is an array successive Vector3
  27315. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  27316. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  27317. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  27318. * @param scene defines the hosting scene
  27319. * @param updatable defines if the mesh must be flagged as updatable
  27320. * @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)
  27321. * @returns a new Mesh
  27322. */
  27323. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  27324. /**
  27325. * Creates a polygon mesh.
  27326. * Please consider using the same method from the MeshBuilder class instead.
  27327. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  27328. * 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.
  27329. * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27330. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  27331. * Remember you can only change the shape positions, not their number when updating a polygon.
  27332. */
  27333. /**
  27334. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  27335. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  27336. * @param name defines the name of the mesh to create
  27337. * @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
  27338. * @param scene defines the hosting scene
  27339. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  27340. * @param updatable defines if the mesh must be flagged as updatable
  27341. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27342. * @returns a new Mesh
  27343. */
  27344. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  27345. /**
  27346. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  27347. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  27348. * @param name defines the name of the mesh to create
  27349. * @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
  27350. * @param depth defines the height of extrusion
  27351. * @param scene defines the hosting scene
  27352. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  27353. * @param updatable defines if the mesh must be flagged as updatable
  27354. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27355. * @returns a new Mesh
  27356. */
  27357. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  27358. /**
  27359. * Creates an extruded shape mesh.
  27360. * 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
  27361. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  27362. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  27363. * @param name defines the name of the mesh to create
  27364. * @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
  27365. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  27366. * @param scale is the value to scale the shape
  27367. * @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
  27368. * @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
  27369. * @param scene defines the hosting scene
  27370. * @param updatable defines if the mesh must be flagged as updatable
  27371. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27372. * @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)
  27373. * @returns a new Mesh
  27374. */
  27375. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  27376. /**
  27377. * Creates an custom extruded shape mesh.
  27378. * The custom extrusion is a parametric shape.
  27379. * It has no predefined shape. Its final shape will depend on the input parameters.
  27380. * Please consider using the same method from the MeshBuilder class instead
  27381. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  27382. * @param name defines the name of the mesh to create
  27383. * @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
  27384. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  27385. * @param scaleFunction is a custom Javascript function called on each path point
  27386. * @param rotationFunction is a custom Javascript function called on each path point
  27387. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  27388. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  27389. * @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
  27390. * @param scene defines the hosting scene
  27391. * @param updatable defines if the mesh must be flagged as updatable
  27392. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27393. * @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)
  27394. * @returns a new Mesh
  27395. */
  27396. 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;
  27397. /**
  27398. * Creates lathe mesh.
  27399. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  27400. * Please consider using the same method from the MeshBuilder class instead
  27401. * @param name defines the name of the mesh to create
  27402. * @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
  27403. * @param radius is the radius value of the lathe
  27404. * @param tessellation is the side number of the lathe.
  27405. * @param scene defines the hosting scene
  27406. * @param updatable defines if the mesh must be flagged as updatable
  27407. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27408. * @returns a new Mesh
  27409. */
  27410. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27411. /**
  27412. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  27413. * @param name defines the name of the mesh to create
  27414. * @param size sets the size (float) of both sides of the plane at once (default 1)
  27415. * @param scene defines the hosting scene
  27416. * @param updatable defines if the mesh must be flagged as updatable
  27417. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27418. * @returns a new Mesh
  27419. */
  27420. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27421. /**
  27422. * Creates a ground mesh.
  27423. * Please consider using the same method from the MeshBuilder class instead
  27424. * @param name defines the name of the mesh to create
  27425. * @param width set the width of the ground
  27426. * @param height set the height of the ground
  27427. * @param subdivisions sets the number of subdivisions per side
  27428. * @param scene defines the hosting scene
  27429. * @param updatable defines if the mesh must be flagged as updatable
  27430. * @returns a new Mesh
  27431. */
  27432. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  27433. /**
  27434. * Creates a tiled ground mesh.
  27435. * Please consider using the same method from the MeshBuilder class instead
  27436. * @param name defines the name of the mesh to create
  27437. * @param xmin set the ground minimum X coordinate
  27438. * @param zmin set the ground minimum Y coordinate
  27439. * @param xmax set the ground maximum X coordinate
  27440. * @param zmax set the ground maximum Z coordinate
  27441. * @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
  27442. * @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
  27443. * @param scene defines the hosting scene
  27444. * @param updatable defines if the mesh must be flagged as updatable
  27445. * @returns a new Mesh
  27446. */
  27447. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  27448. w: number;
  27449. h: number;
  27450. }, precision: {
  27451. w: number;
  27452. h: number;
  27453. }, scene: Scene, updatable?: boolean): Mesh;
  27454. /**
  27455. * Creates a ground mesh from a height map.
  27456. * Please consider using the same method from the MeshBuilder class instead
  27457. * @see http://doc.babylonjs.com/babylon101/height_map
  27458. * @param name defines the name of the mesh to create
  27459. * @param url sets the URL of the height map image resource
  27460. * @param width set the ground width size
  27461. * @param height set the ground height size
  27462. * @param subdivisions sets the number of subdivision per side
  27463. * @param minHeight is the minimum altitude on the ground
  27464. * @param maxHeight is the maximum altitude on the ground
  27465. * @param scene defines the hosting scene
  27466. * @param updatable defines if the mesh must be flagged as updatable
  27467. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  27468. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  27469. * @returns a new Mesh
  27470. */
  27471. 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;
  27472. /**
  27473. * Creates a tube mesh.
  27474. * The tube is a parametric shape.
  27475. * It has no predefined shape. Its final shape will depend on the input parameters.
  27476. * Please consider using the same method from the MeshBuilder class instead
  27477. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  27478. * @param name defines the name of the mesh to create
  27479. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  27480. * @param radius sets the tube radius size
  27481. * @param tessellation is the number of sides on the tubular surface
  27482. * @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
  27483. * @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
  27484. * @param scene defines the hosting scene
  27485. * @param updatable defines if the mesh must be flagged as updatable
  27486. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27487. * @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)
  27488. * @returns a new Mesh
  27489. */
  27490. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  27491. (i: number, distance: number): number;
  27492. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  27493. /**
  27494. * Creates a polyhedron mesh.
  27495. * Please consider using the same method from the MeshBuilder class instead.
  27496. * * 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
  27497. * * The parameter `size` (positive float, default 1) sets the polygon size
  27498. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  27499. * * 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`
  27500. * * 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
  27501. * * 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)`)
  27502. * * 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
  27503. * * 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
  27504. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27505. * * 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
  27506. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27507. * @param name defines the name of the mesh to create
  27508. * @param options defines the options used to create the mesh
  27509. * @param scene defines the hosting scene
  27510. * @returns a new Mesh
  27511. */
  27512. static CreatePolyhedron(name: string, options: {
  27513. type?: number;
  27514. size?: number;
  27515. sizeX?: number;
  27516. sizeY?: number;
  27517. sizeZ?: number;
  27518. custom?: any;
  27519. faceUV?: Vector4[];
  27520. faceColors?: Color4[];
  27521. updatable?: boolean;
  27522. sideOrientation?: number;
  27523. }, scene: Scene): Mesh;
  27524. /**
  27525. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  27526. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  27527. * * 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`)
  27528. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  27529. * * 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
  27530. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27531. * * 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
  27532. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27533. * @param name defines the name of the mesh
  27534. * @param options defines the options used to create the mesh
  27535. * @param scene defines the hosting scene
  27536. * @returns a new Mesh
  27537. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  27538. */
  27539. static CreateIcoSphere(name: string, options: {
  27540. radius?: number;
  27541. flat?: boolean;
  27542. subdivisions?: number;
  27543. sideOrientation?: number;
  27544. updatable?: boolean;
  27545. }, scene: Scene): Mesh;
  27546. /**
  27547. * Creates a decal mesh.
  27548. * Please consider using the same method from the MeshBuilder class instead.
  27549. * A decal is a mesh usually applied as a model onto the surface of another mesh
  27550. * @param name defines the name of the mesh
  27551. * @param sourceMesh defines the mesh receiving the decal
  27552. * @param position sets the position of the decal in world coordinates
  27553. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  27554. * @param size sets the decal scaling
  27555. * @param angle sets the angle to rotate the decal
  27556. * @returns a new Mesh
  27557. */
  27558. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  27559. /**
  27560. * Prepare internal position array for software CPU skinning
  27561. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  27562. */
  27563. setPositionsForCPUSkinning(): Float32Array;
  27564. /**
  27565. * Prepare internal normal array for software CPU skinning
  27566. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  27567. */
  27568. setNormalsForCPUSkinning(): Float32Array;
  27569. /**
  27570. * Updates the vertex buffer by applying transformation from the bones
  27571. * @param skeleton defines the skeleton to apply to current mesh
  27572. * @returns the current mesh
  27573. */
  27574. applySkeleton(skeleton: Skeleton): Mesh;
  27575. /**
  27576. * 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
  27577. * @param meshes defines the list of meshes to scan
  27578. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  27579. */
  27580. static MinMax(meshes: AbstractMesh[]): {
  27581. min: Vector3;
  27582. max: Vector3;
  27583. };
  27584. /**
  27585. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  27586. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  27587. * @returns a vector3
  27588. */
  27589. static Center(meshesOrMinMaxVector: {
  27590. min: Vector3;
  27591. max: Vector3;
  27592. } | AbstractMesh[]): Vector3;
  27593. /**
  27594. * Merge the array of meshes into a single mesh for performance reasons.
  27595. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  27596. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  27597. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  27598. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  27599. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  27600. * @returns a new mesh
  27601. */
  27602. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean): Nullable<Mesh>;
  27603. /** @hidden */
  27604. addInstance(instance: InstancedMesh): void;
  27605. /** @hidden */
  27606. removeInstance(instance: InstancedMesh): void;
  27607. }
  27608. }
  27609. declare module BABYLON {
  27610. /**
  27611. * Define an interface for all classes that will get and set the data on vertices
  27612. */
  27613. interface IGetSetVerticesData {
  27614. /**
  27615. * Gets a boolean indicating if specific vertex data is present
  27616. * @param kind defines the vertex data kind to use
  27617. * @returns true is data kind is present
  27618. */
  27619. isVerticesDataPresent(kind: string): boolean;
  27620. /**
  27621. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  27622. * @param kind defines the data kind (Position, normal, etc...)
  27623. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  27624. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  27625. * @returns a float array containing vertex data
  27626. */
  27627. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  27628. /**
  27629. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  27630. * @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.
  27631. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  27632. * @returns the indices array or an empty array if the mesh has no geometry
  27633. */
  27634. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  27635. /**
  27636. * Set specific vertex data
  27637. * @param kind defines the data kind (Position, normal, etc...)
  27638. * @param data defines the vertex data to use
  27639. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  27640. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  27641. */
  27642. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  27643. /**
  27644. * Update a specific associated vertex buffer
  27645. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  27646. * - BABYLON.VertexBuffer.PositionKind
  27647. * - BABYLON.VertexBuffer.UVKind
  27648. * - BABYLON.VertexBuffer.UV2Kind
  27649. * - BABYLON.VertexBuffer.UV3Kind
  27650. * - BABYLON.VertexBuffer.UV4Kind
  27651. * - BABYLON.VertexBuffer.UV5Kind
  27652. * - BABYLON.VertexBuffer.UV6Kind
  27653. * - BABYLON.VertexBuffer.ColorKind
  27654. * - BABYLON.VertexBuffer.MatricesIndicesKind
  27655. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  27656. * - BABYLON.VertexBuffer.MatricesWeightsKind
  27657. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  27658. * @param data defines the data source
  27659. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  27660. * @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)
  27661. */
  27662. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  27663. /**
  27664. * Creates a new index buffer
  27665. * @param indices defines the indices to store in the index buffer
  27666. * @param totalVertices defines the total number of vertices (could be null)
  27667. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  27668. */
  27669. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  27670. }
  27671. /**
  27672. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  27673. */
  27674. class VertexData {
  27675. /**
  27676. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  27677. */
  27678. positions: Nullable<FloatArray>;
  27679. /**
  27680. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  27681. */
  27682. normals: Nullable<FloatArray>;
  27683. /**
  27684. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  27685. */
  27686. tangents: Nullable<FloatArray>;
  27687. /**
  27688. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27689. */
  27690. uvs: Nullable<FloatArray>;
  27691. /**
  27692. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27693. */
  27694. uvs2: Nullable<FloatArray>;
  27695. /**
  27696. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27697. */
  27698. uvs3: Nullable<FloatArray>;
  27699. /**
  27700. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27701. */
  27702. uvs4: Nullable<FloatArray>;
  27703. /**
  27704. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27705. */
  27706. uvs5: Nullable<FloatArray>;
  27707. /**
  27708. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27709. */
  27710. uvs6: Nullable<FloatArray>;
  27711. /**
  27712. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  27713. */
  27714. colors: Nullable<FloatArray>;
  27715. /**
  27716. * 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).
  27717. */
  27718. matricesIndices: Nullable<FloatArray>;
  27719. /**
  27720. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  27721. */
  27722. matricesWeights: Nullable<FloatArray>;
  27723. /**
  27724. * An array extending the number of possible indices
  27725. */
  27726. matricesIndicesExtra: Nullable<FloatArray>;
  27727. /**
  27728. * An array extending the number of possible weights when the number of indices is extended
  27729. */
  27730. matricesWeightsExtra: Nullable<FloatArray>;
  27731. /**
  27732. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  27733. */
  27734. indices: Nullable<IndicesArray>;
  27735. /**
  27736. * Uses the passed data array to set the set the values for the specified kind of data
  27737. * @param data a linear array of floating numbers
  27738. * @param kind the type of data that is being set, eg positions, colors etc
  27739. */
  27740. set(data: FloatArray, kind: string): void;
  27741. /**
  27742. * Associates the vertexData to the passed Mesh.
  27743. * Sets it as updatable or not (default `false`)
  27744. * @param mesh the mesh the vertexData is applied to
  27745. * @param updatable when used and having the value true allows new data to update the vertexData
  27746. * @returns the VertexData
  27747. */
  27748. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  27749. /**
  27750. * Associates the vertexData to the passed Geometry.
  27751. * Sets it as updatable or not (default `false`)
  27752. * @param geometry the geometry the vertexData is applied to
  27753. * @param updatable when used and having the value true allows new data to update the vertexData
  27754. * @returns VertexData
  27755. */
  27756. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  27757. /**
  27758. * Updates the associated mesh
  27759. * @param mesh the mesh to be updated
  27760. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  27761. * @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
  27762. * @returns VertexData
  27763. */
  27764. updateMesh(mesh: Mesh, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  27765. /**
  27766. * Updates the associated geometry
  27767. * @param geometry the geometry to be updated
  27768. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  27769. * @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
  27770. * @returns VertexData.
  27771. */
  27772. updateGeometry(geometry: Geometry, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  27773. private _applyTo;
  27774. private _update;
  27775. /**
  27776. * Transforms each position and each normal of the vertexData according to the passed Matrix
  27777. * @param matrix the transforming matrix
  27778. * @returns the VertexData
  27779. */
  27780. transform(matrix: Matrix): VertexData;
  27781. /**
  27782. * Merges the passed VertexData into the current one
  27783. * @param other the VertexData to be merged into the current one
  27784. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  27785. * @returns the modified VertexData
  27786. */
  27787. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  27788. private _mergeElement;
  27789. private _validate;
  27790. /**
  27791. * Serializes the VertexData
  27792. * @returns a serialized object
  27793. */
  27794. serialize(): any;
  27795. /**
  27796. * Extracts the vertexData from a mesh
  27797. * @param mesh the mesh from which to extract the VertexData
  27798. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  27799. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  27800. * @returns the object VertexData associated to the passed mesh
  27801. */
  27802. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  27803. /**
  27804. * Extracts the vertexData from the geometry
  27805. * @param geometry the geometry from which to extract the VertexData
  27806. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  27807. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  27808. * @returns the object VertexData associated to the passed mesh
  27809. */
  27810. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  27811. private static _ExtractFrom;
  27812. /**
  27813. * Creates the VertexData for a Ribbon
  27814. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  27815. * * pathArray array of paths, each of which an array of successive Vector3
  27816. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  27817. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  27818. * * 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
  27819. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27820. * * 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)
  27821. * * 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)
  27822. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  27823. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  27824. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  27825. * @returns the VertexData of the ribbon
  27826. */
  27827. static CreateRibbon(options: {
  27828. pathArray: Vector3[][];
  27829. closeArray?: boolean;
  27830. closePath?: boolean;
  27831. offset?: number;
  27832. sideOrientation?: number;
  27833. frontUVs?: Vector4;
  27834. backUVs?: Vector4;
  27835. invertUV?: boolean;
  27836. uvs?: Vector2[];
  27837. colors?: Color4[];
  27838. }): VertexData;
  27839. /**
  27840. * Creates the VertexData for a box
  27841. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27842. * * size sets the width, height and depth of the box to the value of size, optional default 1
  27843. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  27844. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  27845. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  27846. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  27847. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  27848. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27849. * * 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)
  27850. * * 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)
  27851. * @returns the VertexData of the box
  27852. */
  27853. static CreateBox(options: {
  27854. size?: number;
  27855. width?: number;
  27856. height?: number;
  27857. depth?: number;
  27858. faceUV?: Vector4[];
  27859. faceColors?: Color4[];
  27860. sideOrientation?: number;
  27861. frontUVs?: Vector4;
  27862. backUVs?: Vector4;
  27863. }): VertexData;
  27864. /**
  27865. * Creates the VertexData for an ellipsoid, defaults to a sphere
  27866. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27867. * * segments sets the number of horizontal strips optional, default 32
  27868. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  27869. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  27870. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  27871. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  27872. * * 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
  27873. * * 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
  27874. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27875. * * 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)
  27876. * * 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)
  27877. * @returns the VertexData of the ellipsoid
  27878. */
  27879. static CreateSphere(options: {
  27880. segments?: number;
  27881. diameter?: number;
  27882. diameterX?: number;
  27883. diameterY?: number;
  27884. diameterZ?: number;
  27885. arc?: number;
  27886. slice?: number;
  27887. sideOrientation?: number;
  27888. frontUVs?: Vector4;
  27889. backUVs?: Vector4;
  27890. }): VertexData;
  27891. /**
  27892. * Creates the VertexData for a cylinder, cone or prism
  27893. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27894. * * height sets the height (y direction) of the cylinder, optional, default 2
  27895. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  27896. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  27897. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  27898. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  27899. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  27900. * * 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
  27901. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27902. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27903. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  27904. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  27905. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27906. * * 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)
  27907. * * 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)
  27908. * @returns the VertexData of the cylinder, cone or prism
  27909. */
  27910. static CreateCylinder(options: {
  27911. height?: number;
  27912. diameterTop?: number;
  27913. diameterBottom?: number;
  27914. diameter?: number;
  27915. tessellation?: number;
  27916. subdivisions?: number;
  27917. arc?: number;
  27918. faceColors?: Color4[];
  27919. faceUV?: Vector4[];
  27920. hasRings?: boolean;
  27921. enclose?: boolean;
  27922. sideOrientation?: number;
  27923. frontUVs?: Vector4;
  27924. backUVs?: Vector4;
  27925. }): VertexData;
  27926. /**
  27927. * Creates the VertexData for a torus
  27928. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27929. * * diameter the diameter of the torus, optional default 1
  27930. * * thickness the diameter of the tube forming the torus, optional default 0.5
  27931. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  27932. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27933. * * 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)
  27934. * * 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)
  27935. * @returns the VertexData of the torus
  27936. */
  27937. static CreateTorus(options: {
  27938. diameter?: number;
  27939. thickness?: number;
  27940. tessellation?: number;
  27941. sideOrientation?: number;
  27942. frontUVs?: Vector4;
  27943. backUVs?: Vector4;
  27944. }): VertexData;
  27945. /**
  27946. * Creates the VertexData of the LineSystem
  27947. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  27948. * - lines an array of lines, each line being an array of successive Vector3
  27949. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  27950. * @returns the VertexData of the LineSystem
  27951. */
  27952. static CreateLineSystem(options: {
  27953. lines: Vector3[][];
  27954. colors?: Nullable<Color4[][]>;
  27955. }): VertexData;
  27956. /**
  27957. * Create the VertexData for a DashedLines
  27958. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  27959. * - points an array successive Vector3
  27960. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  27961. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  27962. * - dashNb the intended total number of dashes, optional, default 200
  27963. * @returns the VertexData for the DashedLines
  27964. */
  27965. static CreateDashedLines(options: {
  27966. points: Vector3[];
  27967. dashSize?: number;
  27968. gapSize?: number;
  27969. dashNb?: number;
  27970. }): VertexData;
  27971. /**
  27972. * Creates the VertexData for a Ground
  27973. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  27974. * - width the width (x direction) of the ground, optional, default 1
  27975. * - height the height (z direction) of the ground, optional, default 1
  27976. * - subdivisions the number of subdivisions per side, optional, default 1
  27977. * @returns the VertexData of the Ground
  27978. */
  27979. static CreateGround(options: {
  27980. width?: number;
  27981. height?: number;
  27982. subdivisions?: number;
  27983. subdivisionsX?: number;
  27984. subdivisionsY?: number;
  27985. }): VertexData;
  27986. /**
  27987. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  27988. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  27989. * * xmin the ground minimum X coordinate, optional, default -1
  27990. * * zmin the ground minimum Z coordinate, optional, default -1
  27991. * * xmax the ground maximum X coordinate, optional, default 1
  27992. * * zmax the ground maximum Z coordinate, optional, default 1
  27993. * * 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}
  27994. * * 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}
  27995. * @returns the VertexData of the TiledGround
  27996. */
  27997. static CreateTiledGround(options: {
  27998. xmin: number;
  27999. zmin: number;
  28000. xmax: number;
  28001. zmax: number;
  28002. subdivisions?: {
  28003. w: number;
  28004. h: number;
  28005. };
  28006. precision?: {
  28007. w: number;
  28008. h: number;
  28009. };
  28010. }): VertexData;
  28011. /**
  28012. * Creates the VertexData of the Ground designed from a heightmap
  28013. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  28014. * * width the width (x direction) of the ground
  28015. * * height the height (z direction) of the ground
  28016. * * subdivisions the number of subdivisions per side
  28017. * * minHeight the minimum altitude on the ground, optional, default 0
  28018. * * maxHeight the maximum altitude on the ground, optional default 1
  28019. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  28020. * * buffer the array holding the image color data
  28021. * * bufferWidth the width of image
  28022. * * bufferHeight the height of image
  28023. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  28024. * @returns the VertexData of the Ground designed from a heightmap
  28025. */
  28026. static CreateGroundFromHeightMap(options: {
  28027. width: number;
  28028. height: number;
  28029. subdivisions: number;
  28030. minHeight: number;
  28031. maxHeight: number;
  28032. colorFilter: Color3;
  28033. buffer: Uint8Array;
  28034. bufferWidth: number;
  28035. bufferHeight: number;
  28036. alphaFilter: number;
  28037. }): VertexData;
  28038. /**
  28039. * Creates the VertexData for a Plane
  28040. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  28041. * * size sets the width and height of the plane to the value of size, optional default 1
  28042. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  28043. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  28044. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28045. * * 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)
  28046. * * 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)
  28047. * @returns the VertexData of the box
  28048. */
  28049. static CreatePlane(options: {
  28050. size?: number;
  28051. width?: number;
  28052. height?: number;
  28053. sideOrientation?: number;
  28054. frontUVs?: Vector4;
  28055. backUVs?: Vector4;
  28056. }): VertexData;
  28057. /**
  28058. * Creates the VertexData of the Disc or regular Polygon
  28059. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  28060. * * radius the radius of the disc, optional default 0.5
  28061. * * tessellation the number of polygon sides, optional, default 64
  28062. * * 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
  28063. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28064. * * 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)
  28065. * * 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)
  28066. * @returns the VertexData of the box
  28067. */
  28068. static CreateDisc(options: {
  28069. radius?: number;
  28070. tessellation?: number;
  28071. arc?: number;
  28072. sideOrientation?: number;
  28073. frontUVs?: Vector4;
  28074. backUVs?: Vector4;
  28075. }): VertexData;
  28076. /**
  28077. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  28078. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  28079. * @param polygon a mesh built from polygonTriangulation.build()
  28080. * @param sideOrientation takes the values BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28081. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  28082. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  28083. * @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)
  28084. * @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)
  28085. * @returns the VertexData of the Polygon
  28086. */
  28087. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  28088. /**
  28089. * Creates the VertexData of the IcoSphere
  28090. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  28091. * * radius the radius of the IcoSphere, optional default 1
  28092. * * radiusX allows stretching in the x direction, optional, default radius
  28093. * * radiusY allows stretching in the y direction, optional, default radius
  28094. * * radiusZ allows stretching in the z direction, optional, default radius
  28095. * * flat when true creates a flat shaded mesh, optional, default true
  28096. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  28097. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28098. * * 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)
  28099. * * 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)
  28100. * @returns the VertexData of the IcoSphere
  28101. */
  28102. static CreateIcoSphere(options: {
  28103. radius?: number;
  28104. radiusX?: number;
  28105. radiusY?: number;
  28106. radiusZ?: number;
  28107. flat?: boolean;
  28108. subdivisions?: number;
  28109. sideOrientation?: number;
  28110. frontUVs?: Vector4;
  28111. backUVs?: Vector4;
  28112. }): VertexData;
  28113. /**
  28114. * Creates the VertexData for a Polyhedron
  28115. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  28116. * * type provided types are:
  28117. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  28118. * * 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)
  28119. * * size the size of the IcoSphere, optional default 1
  28120. * * sizeX allows stretching in the x direction, optional, default size
  28121. * * sizeY allows stretching in the y direction, optional, default size
  28122. * * sizeZ allows stretching in the z direction, optional, default size
  28123. * * 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
  28124. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  28125. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  28126. * * flat when true creates a flat shaded mesh, optional, default true
  28127. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  28128. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28129. * * 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)
  28130. * * 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)
  28131. * @returns the VertexData of the Polyhedron
  28132. */
  28133. static CreatePolyhedron(options: {
  28134. type?: number;
  28135. size?: number;
  28136. sizeX?: number;
  28137. sizeY?: number;
  28138. sizeZ?: number;
  28139. custom?: any;
  28140. faceUV?: Vector4[];
  28141. faceColors?: Color4[];
  28142. flat?: boolean;
  28143. sideOrientation?: number;
  28144. frontUVs?: Vector4;
  28145. backUVs?: Vector4;
  28146. }): VertexData;
  28147. /**
  28148. * Creates the VertexData for a TorusKnot
  28149. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  28150. * * radius the radius of the torus knot, optional, default 2
  28151. * * tube the thickness of the tube, optional, default 0.5
  28152. * * radialSegments the number of sides on each tube segments, optional, default 32
  28153. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  28154. * * p the number of windings around the z axis, optional, default 2
  28155. * * q the number of windings around the x axis, optional, default 3
  28156. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28157. * * 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)
  28158. * * 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)
  28159. * @returns the VertexData of the Torus Knot
  28160. */
  28161. static CreateTorusKnot(options: {
  28162. radius?: number;
  28163. tube?: number;
  28164. radialSegments?: number;
  28165. tubularSegments?: number;
  28166. p?: number;
  28167. q?: number;
  28168. sideOrientation?: number;
  28169. frontUVs?: Vector4;
  28170. backUVs?: Vector4;
  28171. }): VertexData;
  28172. /**
  28173. * Compute normals for given positions and indices
  28174. * @param positions an array of vertex positions, [...., x, y, z, ......]
  28175. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  28176. * @param normals an array of vertex normals, [...., x, y, z, ......]
  28177. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  28178. * * facetNormals : optional array of facet normals (vector3)
  28179. * * facetPositions : optional array of facet positions (vector3)
  28180. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  28181. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  28182. * * bInfo : optional bounding info, required for facetPartitioning computation
  28183. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  28184. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  28185. * * useRightHandedSystem: optional boolean to for right handed system computation
  28186. * * depthSort : optional boolean to enable the facet depth sort computation
  28187. * * distanceTo : optional Vector3 to compute the facet depth from this location
  28188. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  28189. */
  28190. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  28191. facetNormals?: any;
  28192. facetPositions?: any;
  28193. facetPartitioning?: any;
  28194. ratio?: number;
  28195. bInfo?: any;
  28196. bbSize?: Vector3;
  28197. subDiv?: any;
  28198. useRightHandedSystem?: boolean;
  28199. depthSort?: boolean;
  28200. distanceTo?: Vector3;
  28201. depthSortedFacets?: any;
  28202. }): void;
  28203. private static _ComputeSides;
  28204. /**
  28205. * Applies VertexData created from the imported parameters to the geometry
  28206. * @param parsedVertexData the parsed data from an imported file
  28207. * @param geometry the geometry to apply the VertexData to
  28208. */
  28209. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  28210. }
  28211. }
  28212. declare module BABYLON {
  28213. /**
  28214. * Class containing static functions to help procedurally build meshes
  28215. */
  28216. class MeshBuilder {
  28217. private static updateSideOrientation;
  28218. /**
  28219. * Creates a box mesh
  28220. * * The parameter `size` sets the size (float) of each box side (default 1)
  28221. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  28222. * * 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)
  28223. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  28224. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28225. * * 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
  28226. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28227. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  28228. * @param name defines the name of the mesh
  28229. * @param options defines the options used to create the mesh
  28230. * @param scene defines the hosting scene
  28231. * @returns the box mesh
  28232. */
  28233. static CreateBox(name: string, options: {
  28234. size?: number;
  28235. width?: number;
  28236. height?: number;
  28237. depth?: number;
  28238. faceUV?: Vector4[];
  28239. faceColors?: Color4[];
  28240. sideOrientation?: number;
  28241. frontUVs?: Vector4;
  28242. backUVs?: Vector4;
  28243. updatable?: boolean;
  28244. }, scene?: Nullable<Scene>): Mesh;
  28245. /**
  28246. * Creates a sphere mesh
  28247. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  28248. * * 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`)
  28249. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  28250. * * 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
  28251. * * 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)
  28252. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28253. * * 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
  28254. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28255. * @param name defines the name of the mesh
  28256. * @param options defines the options used to create the mesh
  28257. * @param scene defines the hosting scene
  28258. * @returns the sphere mesh
  28259. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  28260. */
  28261. static CreateSphere(name: string, options: {
  28262. segments?: number;
  28263. diameter?: number;
  28264. diameterX?: number;
  28265. diameterY?: number;
  28266. diameterZ?: number;
  28267. arc?: number;
  28268. slice?: number;
  28269. sideOrientation?: number;
  28270. frontUVs?: Vector4;
  28271. backUVs?: Vector4;
  28272. updatable?: boolean;
  28273. }, scene: any): Mesh;
  28274. /**
  28275. * Creates a plane polygonal mesh. By default, this is a disc
  28276. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  28277. * * 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
  28278. * * 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
  28279. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28280. * * 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
  28281. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28282. * @param name defines the name of the mesh
  28283. * @param options defines the options used to create the mesh
  28284. * @param scene defines the hosting scene
  28285. * @returns the plane polygonal mesh
  28286. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  28287. */
  28288. static CreateDisc(name: string, options: {
  28289. radius?: number;
  28290. tessellation?: number;
  28291. arc?: number;
  28292. updatable?: boolean;
  28293. sideOrientation?: number;
  28294. frontUVs?: Vector4;
  28295. backUVs?: Vector4;
  28296. }, scene?: Nullable<Scene>): Mesh;
  28297. /**
  28298. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  28299. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  28300. * * 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`)
  28301. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  28302. * * 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
  28303. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28304. * * 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
  28305. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28306. * @param name defines the name of the mesh
  28307. * @param options defines the options used to create the mesh
  28308. * @param scene defines the hosting scene
  28309. * @returns the icosahedron mesh
  28310. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  28311. */
  28312. static CreateIcoSphere(name: string, options: {
  28313. radius?: number;
  28314. radiusX?: number;
  28315. radiusY?: number;
  28316. radiusZ?: number;
  28317. flat?: boolean;
  28318. subdivisions?: number;
  28319. sideOrientation?: number;
  28320. frontUVs?: Vector4;
  28321. backUVs?: Vector4;
  28322. updatable?: boolean;
  28323. }, scene: Scene): Mesh;
  28324. /**
  28325. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  28326. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  28327. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  28328. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  28329. * * 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
  28330. * * 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
  28331. * * 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
  28332. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28333. * * 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
  28334. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  28335. * * 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
  28336. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  28337. * * 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
  28338. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  28339. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28340. * @param name defines the name of the mesh
  28341. * @param options defines the options used to create the mesh
  28342. * @param scene defines the hosting scene
  28343. * @returns the ribbon mesh
  28344. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  28345. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28346. */
  28347. static CreateRibbon(name: string, options: {
  28348. pathArray: Vector3[][];
  28349. closeArray?: boolean;
  28350. closePath?: boolean;
  28351. offset?: number;
  28352. updatable?: boolean;
  28353. sideOrientation?: number;
  28354. frontUVs?: Vector4;
  28355. backUVs?: Vector4;
  28356. instance?: Mesh;
  28357. invertUV?: boolean;
  28358. uvs?: Vector2[];
  28359. colors?: Color4[];
  28360. }, scene?: Nullable<Scene>): Mesh;
  28361. /**
  28362. * Creates a cylinder or a cone mesh
  28363. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  28364. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  28365. * * 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.
  28366. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  28367. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  28368. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  28369. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  28370. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  28371. * * 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).
  28372. * * 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
  28373. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  28374. * * 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
  28375. * * 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.
  28376. * * If `enclose` is false, a ring surface is one element.
  28377. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  28378. * * 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
  28379. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28380. * * 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
  28381. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28382. * @param name defines the name of the mesh
  28383. * @param options defines the options used to create the mesh
  28384. * @param scene defines the hosting scene
  28385. * @returns the cylinder mesh
  28386. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  28387. */
  28388. static CreateCylinder(name: string, options: {
  28389. height?: number;
  28390. diameterTop?: number;
  28391. diameterBottom?: number;
  28392. diameter?: number;
  28393. tessellation?: number;
  28394. subdivisions?: number;
  28395. arc?: number;
  28396. faceColors?: Color4[];
  28397. faceUV?: Vector4[];
  28398. updatable?: boolean;
  28399. hasRings?: boolean;
  28400. enclose?: boolean;
  28401. sideOrientation?: number;
  28402. frontUVs?: Vector4;
  28403. backUVs?: Vector4;
  28404. }, scene: any): Mesh;
  28405. /**
  28406. * Creates a torus mesh
  28407. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  28408. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  28409. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  28410. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28411. * * 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
  28412. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28413. * @param name defines the name of the mesh
  28414. * @param options defines the options used to create the mesh
  28415. * @param scene defines the hosting scene
  28416. * @returns the torus mesh
  28417. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  28418. */
  28419. static CreateTorus(name: string, options: {
  28420. diameter?: number;
  28421. thickness?: number;
  28422. tessellation?: number;
  28423. updatable?: boolean;
  28424. sideOrientation?: number;
  28425. frontUVs?: Vector4;
  28426. backUVs?: Vector4;
  28427. }, scene: any): Mesh;
  28428. /**
  28429. * Creates a torus knot mesh
  28430. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  28431. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  28432. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  28433. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  28434. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28435. * * 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
  28436. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28437. * @param name defines the name of the mesh
  28438. * @param options defines the options used to create the mesh
  28439. * @param scene defines the hosting scene
  28440. * @returns the torus knot mesh
  28441. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  28442. */
  28443. static CreateTorusKnot(name: string, options: {
  28444. radius?: number;
  28445. tube?: number;
  28446. radialSegments?: number;
  28447. tubularSegments?: number;
  28448. p?: number;
  28449. q?: number;
  28450. updatable?: boolean;
  28451. sideOrientation?: number;
  28452. frontUVs?: Vector4;
  28453. backUVs?: Vector4;
  28454. }, scene: any): Mesh;
  28455. /**
  28456. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  28457. * * 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
  28458. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  28459. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  28460. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  28461. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  28462. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  28463. * * 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
  28464. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  28465. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28466. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  28467. * @param name defines the name of the new line system
  28468. * @param options defines the options used to create the line system
  28469. * @param scene defines the hosting scene
  28470. * @returns a new line system mesh
  28471. */
  28472. static CreateLineSystem(name: string, options: {
  28473. lines: Vector3[][];
  28474. updatable?: boolean;
  28475. instance?: Nullable<LinesMesh>;
  28476. colors?: Nullable<Color4[][]>;
  28477. useVertexAlpha?: boolean;
  28478. }, scene: Nullable<Scene>): LinesMesh;
  28479. /**
  28480. * Creates a line mesh
  28481. * 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
  28482. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  28483. * * The parameter `points` is an array successive Vector3
  28484. * * 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
  28485. * * The optional parameter `colors` is an array of successive Color4, one per line point
  28486. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  28487. * * When updating an instance, remember that only point positions can change, not the number of points
  28488. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28489. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  28490. * @param name defines the name of the new line system
  28491. * @param options defines the options used to create the line system
  28492. * @param scene defines the hosting scene
  28493. * @returns a new line mesh
  28494. */
  28495. static CreateLines(name: string, options: {
  28496. points: Vector3[];
  28497. updatable?: boolean;
  28498. instance?: Nullable<LinesMesh>;
  28499. colors?: Color4[];
  28500. useVertexAlpha?: boolean;
  28501. }, scene?: Nullable<Scene>): LinesMesh;
  28502. /**
  28503. * Creates a dashed line mesh
  28504. * * 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
  28505. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  28506. * * The parameter `points` is an array successive Vector3
  28507. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  28508. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  28509. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  28510. * * 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
  28511. * * When updating an instance, remember that only point positions can change, not the number of points
  28512. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28513. * @param name defines the name of the mesh
  28514. * @param options defines the options used to create the mesh
  28515. * @param scene defines the hosting scene
  28516. * @returns the dashed line mesh
  28517. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  28518. */
  28519. static CreateDashedLines(name: string, options: {
  28520. points: Vector3[];
  28521. dashSize?: number;
  28522. gapSize?: number;
  28523. dashNb?: number;
  28524. updatable?: boolean;
  28525. instance?: LinesMesh;
  28526. }, scene?: Nullable<Scene>): LinesMesh;
  28527. /**
  28528. * 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.
  28529. * * 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.
  28530. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  28531. * * 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.
  28532. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  28533. * * 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
  28534. * * 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
  28535. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  28536. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28537. * * 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
  28538. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  28539. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28540. * @param name defines the name of the mesh
  28541. * @param options defines the options used to create the mesh
  28542. * @param scene defines the hosting scene
  28543. * @returns the extruded shape mesh
  28544. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28545. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28546. */
  28547. static ExtrudeShape(name: string, options: {
  28548. shape: Vector3[];
  28549. path: Vector3[];
  28550. scale?: number;
  28551. rotation?: number;
  28552. cap?: number;
  28553. updatable?: boolean;
  28554. sideOrientation?: number;
  28555. frontUVs?: Vector4;
  28556. backUVs?: Vector4;
  28557. instance?: Mesh;
  28558. invertUV?: boolean;
  28559. }, scene?: Nullable<Scene>): Mesh;
  28560. /**
  28561. * Creates an custom extruded shape mesh.
  28562. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  28563. * * 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.
  28564. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  28565. * * 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
  28566. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  28567. * * 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
  28568. * * It must returns a float value that will be the scale value applied to the shape on each path point
  28569. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  28570. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  28571. * * 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
  28572. * * 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
  28573. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  28574. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28575. * * 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
  28576. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  28577. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28578. * @param name defines the name of the mesh
  28579. * @param options defines the options used to create the mesh
  28580. * @param scene defines the hosting scene
  28581. * @returns the custom extruded shape mesh
  28582. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  28583. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28584. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28585. */
  28586. static ExtrudeShapeCustom(name: string, options: {
  28587. shape: Vector3[];
  28588. path: Vector3[];
  28589. scaleFunction?: any;
  28590. rotationFunction?: any;
  28591. ribbonCloseArray?: boolean;
  28592. ribbonClosePath?: boolean;
  28593. cap?: number;
  28594. updatable?: boolean;
  28595. sideOrientation?: number;
  28596. frontUVs?: Vector4;
  28597. backUVs?: Vector4;
  28598. instance?: Mesh;
  28599. invertUV?: boolean;
  28600. }, scene: Scene): Mesh;
  28601. /**
  28602. * Creates lathe mesh.
  28603. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  28604. * * 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
  28605. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  28606. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  28607. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  28608. * * 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
  28609. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  28610. * * 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
  28611. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28612. * * 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
  28613. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  28614. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28615. * @param name defines the name of the mesh
  28616. * @param options defines the options used to create the mesh
  28617. * @param scene defines the hosting scene
  28618. * @returns the lathe mesh
  28619. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  28620. */
  28621. static CreateLathe(name: string, options: {
  28622. shape: Vector3[];
  28623. radius?: number;
  28624. tessellation?: number;
  28625. clip?: number;
  28626. arc?: number;
  28627. closed?: boolean;
  28628. updatable?: boolean;
  28629. sideOrientation?: number;
  28630. frontUVs?: Vector4;
  28631. backUVs?: Vector4;
  28632. cap?: number;
  28633. invertUV?: boolean;
  28634. }, scene: Scene): Mesh;
  28635. /**
  28636. * Creates a plane mesh
  28637. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  28638. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  28639. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  28640. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28641. * * 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
  28642. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28643. * @param name defines the name of the mesh
  28644. * @param options defines the options used to create the mesh
  28645. * @param scene defines the hosting scene
  28646. * @returns the plane mesh
  28647. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  28648. */
  28649. static CreatePlane(name: string, options: {
  28650. size?: number;
  28651. width?: number;
  28652. height?: number;
  28653. sideOrientation?: number;
  28654. frontUVs?: Vector4;
  28655. backUVs?: Vector4;
  28656. updatable?: boolean;
  28657. sourcePlane?: Plane;
  28658. }, scene: Scene): Mesh;
  28659. /**
  28660. * Creates a ground mesh
  28661. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  28662. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  28663. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28664. * @param name defines the name of the mesh
  28665. * @param options defines the options used to create the mesh
  28666. * @param scene defines the hosting scene
  28667. * @returns the ground mesh
  28668. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  28669. */
  28670. static CreateGround(name: string, options: {
  28671. width?: number;
  28672. height?: number;
  28673. subdivisions?: number;
  28674. subdivisionsX?: number;
  28675. subdivisionsY?: number;
  28676. updatable?: boolean;
  28677. }, scene: any): Mesh;
  28678. /**
  28679. * Creates a tiled ground mesh
  28680. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  28681. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  28682. * * 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
  28683. * * 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
  28684. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28685. * @param name defines the name of the mesh
  28686. * @param options defines the options used to create the mesh
  28687. * @param scene defines the hosting scene
  28688. * @returns the tiled ground mesh
  28689. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  28690. */
  28691. static CreateTiledGround(name: string, options: {
  28692. xmin: number;
  28693. zmin: number;
  28694. xmax: number;
  28695. zmax: number;
  28696. subdivisions?: {
  28697. w: number;
  28698. h: number;
  28699. };
  28700. precision?: {
  28701. w: number;
  28702. h: number;
  28703. };
  28704. updatable?: boolean;
  28705. }, scene: Scene): Mesh;
  28706. /**
  28707. * Creates a ground mesh from a height map
  28708. * * The parameter `url` sets the URL of the height map image resource.
  28709. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  28710. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  28711. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  28712. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  28713. * * 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.
  28714. * * 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).
  28715. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  28716. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28717. * @param name defines the name of the mesh
  28718. * @param url defines the url to the height map
  28719. * @param options defines the options used to create the mesh
  28720. * @param scene defines the hosting scene
  28721. * @returns the ground mesh
  28722. * @see https://doc.babylonjs.com/babylon101/height_map
  28723. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  28724. */
  28725. static CreateGroundFromHeightMap(name: string, url: string, options: {
  28726. width?: number;
  28727. height?: number;
  28728. subdivisions?: number;
  28729. minHeight?: number;
  28730. maxHeight?: number;
  28731. colorFilter?: Color3;
  28732. alphaFilter?: number;
  28733. updatable?: boolean;
  28734. onReady?: (mesh: GroundMesh) => void;
  28735. }, scene: Scene): GroundMesh;
  28736. /**
  28737. * Creates a polygon mesh
  28738. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  28739. * * 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
  28740. * * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28741. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28742. * * 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)
  28743. * * Remember you can only change the shape positions, not their number when updating a polygon
  28744. * @param name defines the name of the mesh
  28745. * @param options defines the options used to create the mesh
  28746. * @param scene defines the hosting scene
  28747. * @returns the polygon mesh
  28748. */
  28749. static CreatePolygon(name: string, options: {
  28750. shape: Vector3[];
  28751. holes?: Vector3[][];
  28752. depth?: number;
  28753. faceUV?: Vector4[];
  28754. faceColors?: Color4[];
  28755. updatable?: boolean;
  28756. sideOrientation?: number;
  28757. frontUVs?: Vector4;
  28758. backUVs?: Vector4;
  28759. }, scene: Scene): Mesh;
  28760. /**
  28761. * Creates an extruded polygon mesh, with depth in the Y direction.
  28762. * * 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)
  28763. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  28764. * @param name defines the name of the mesh
  28765. * @param options defines the options used to create the mesh
  28766. * @param scene defines the hosting scene
  28767. * @returns the polygon mesh
  28768. */
  28769. static ExtrudePolygon(name: string, options: {
  28770. shape: Vector3[];
  28771. holes?: Vector3[][];
  28772. depth?: number;
  28773. faceUV?: Vector4[];
  28774. faceColors?: Color4[];
  28775. updatable?: boolean;
  28776. sideOrientation?: number;
  28777. frontUVs?: Vector4;
  28778. backUVs?: Vector4;
  28779. }, scene: Scene): Mesh;
  28780. /**
  28781. * Creates a tube mesh.
  28782. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  28783. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  28784. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  28785. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  28786. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  28787. * * 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)
  28788. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  28789. * * 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
  28790. * * 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
  28791. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28792. * * 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
  28793. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  28794. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28795. * @param name defines the name of the mesh
  28796. * @param options defines the options used to create the mesh
  28797. * @param scene defines the hosting scene
  28798. * @returns the tube mesh
  28799. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28800. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  28801. */
  28802. static CreateTube(name: string, options: {
  28803. path: Vector3[];
  28804. radius?: number;
  28805. tessellation?: number;
  28806. radiusFunction?: {
  28807. (i: number, distance: number): number;
  28808. };
  28809. cap?: number;
  28810. arc?: number;
  28811. updatable?: boolean;
  28812. sideOrientation?: number;
  28813. frontUVs?: Vector4;
  28814. backUVs?: Vector4;
  28815. instance?: Mesh;
  28816. invertUV?: boolean;
  28817. }, scene: Scene): Mesh;
  28818. /**
  28819. * Creates a polyhedron mesh
  28820. * * 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
  28821. * * The parameter `size` (positive float, default 1) sets the polygon size
  28822. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  28823. * * 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`
  28824. * * 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
  28825. * * 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)`)
  28826. * * 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
  28827. * * 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
  28828. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28829. * * 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
  28830. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28831. * @param name defines the name of the mesh
  28832. * @param options defines the options used to create the mesh
  28833. * @param scene defines the hosting scene
  28834. * @returns the polyhedron mesh
  28835. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  28836. */
  28837. static CreatePolyhedron(name: string, options: {
  28838. type?: number;
  28839. size?: number;
  28840. sizeX?: number;
  28841. sizeY?: number;
  28842. sizeZ?: number;
  28843. custom?: any;
  28844. faceUV?: Vector4[];
  28845. faceColors?: Color4[];
  28846. flat?: boolean;
  28847. updatable?: boolean;
  28848. sideOrientation?: number;
  28849. frontUVs?: Vector4;
  28850. backUVs?: Vector4;
  28851. }, scene: Scene): Mesh;
  28852. /**
  28853. * Creates a decal mesh.
  28854. * 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
  28855. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  28856. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  28857. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  28858. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  28859. * @param name defines the name of the mesh
  28860. * @param sourceMesh defines the mesh where the decal must be applied
  28861. * @param options defines the options used to create the mesh
  28862. * @param scene defines the hosting scene
  28863. * @returns the decal mesh
  28864. * @see https://doc.babylonjs.com/how_to/decals
  28865. */
  28866. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  28867. position?: Vector3;
  28868. normal?: Vector3;
  28869. size?: Vector3;
  28870. angle?: number;
  28871. }): Mesh;
  28872. private static _ExtrudeShapeGeneric;
  28873. }
  28874. }
  28875. declare module BABYLON {
  28876. /**
  28877. * Class used to represent a specific level of detail of a mesh
  28878. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  28879. */
  28880. class MeshLODLevel {
  28881. /** Defines the distance where this level should star being displayed */
  28882. distance: number;
  28883. /** Defines the mesh to use to render this level */
  28884. mesh: Nullable<Mesh>;
  28885. /**
  28886. * Creates a new LOD level
  28887. * @param distance defines the distance where this level should star being displayed
  28888. * @param mesh defines the mesh to use to render this level
  28889. */
  28890. constructor(
  28891. /** Defines the distance where this level should star being displayed */
  28892. distance: number,
  28893. /** Defines the mesh to use to render this level */
  28894. mesh: Nullable<Mesh>);
  28895. }
  28896. }
  28897. declare module BABYLON {
  28898. /**
  28899. * A simplifier interface for future simplification implementations
  28900. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28901. */
  28902. interface ISimplifier {
  28903. /**
  28904. * Simplification of a given mesh according to the given settings.
  28905. * Since this requires computation, it is assumed that the function runs async.
  28906. * @param settings The settings of the simplification, including quality and distance
  28907. * @param successCallback A callback that will be called after the mesh was simplified.
  28908. * @param errorCallback in case of an error, this callback will be called. optional.
  28909. */
  28910. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  28911. }
  28912. /**
  28913. * Expected simplification settings.
  28914. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  28915. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28916. */
  28917. interface ISimplificationSettings {
  28918. /**
  28919. * Gets or sets the expected quality
  28920. */
  28921. quality: number;
  28922. /**
  28923. * Gets or sets the distance when this optimized version should be used
  28924. */
  28925. distance: number;
  28926. /**
  28927. * Gets an already optimized mesh
  28928. */
  28929. optimizeMesh?: boolean;
  28930. }
  28931. /**
  28932. * Class used to specify simplification options
  28933. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28934. */
  28935. class SimplificationSettings implements ISimplificationSettings {
  28936. /** expected quality */
  28937. quality: number;
  28938. /** distance when this optimized version should be used */
  28939. distance: number;
  28940. /** already optimized mesh */
  28941. optimizeMesh?: boolean | undefined;
  28942. /**
  28943. * Creates a SimplificationSettings
  28944. * @param quality expected quality
  28945. * @param distance distance when this optimized version should be used
  28946. * @param optimizeMesh already optimized mesh
  28947. */
  28948. constructor(
  28949. /** expected quality */
  28950. quality: number,
  28951. /** distance when this optimized version should be used */
  28952. distance: number,
  28953. /** already optimized mesh */
  28954. optimizeMesh?: boolean | undefined);
  28955. }
  28956. /**
  28957. * Interface used to define a simplification task
  28958. */
  28959. interface ISimplificationTask {
  28960. /**
  28961. * Array of settings
  28962. */
  28963. settings: Array<ISimplificationSettings>;
  28964. /**
  28965. * Simplification type
  28966. */
  28967. simplificationType: SimplificationType;
  28968. /**
  28969. * Mesh to simplify
  28970. */
  28971. mesh: Mesh;
  28972. /**
  28973. * Callback called on success
  28974. */
  28975. successCallback?: () => void;
  28976. /**
  28977. * Defines if parallel processing can be used
  28978. */
  28979. parallelProcessing: boolean;
  28980. }
  28981. /**
  28982. * Queue used to order the simplification tasks
  28983. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28984. */
  28985. class SimplificationQueue {
  28986. private _simplificationArray;
  28987. /**
  28988. * Gets a boolean indicating that the process is still running
  28989. */
  28990. running: boolean;
  28991. /**
  28992. * Creates a new queue
  28993. */
  28994. constructor();
  28995. /**
  28996. * Adds a new simplification task
  28997. * @param task defines a task to add
  28998. */
  28999. addTask(task: ISimplificationTask): void;
  29000. /**
  29001. * Execute next task
  29002. */
  29003. executeNext(): void;
  29004. /**
  29005. * Execute a simplification task
  29006. * @param task defines the task to run
  29007. */
  29008. runSimplification(task: ISimplificationTask): void;
  29009. private getSimplifier;
  29010. }
  29011. /**
  29012. * The implemented types of simplification
  29013. * At the moment only Quadratic Error Decimation is implemented
  29014. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  29015. */
  29016. enum SimplificationType {
  29017. /** Quadratic error decimation */
  29018. QUADRATIC = 0
  29019. }
  29020. }
  29021. declare module BABYLON {
  29022. interface Scene {
  29023. /** @hidden (Backing field) */
  29024. _simplificationQueue: SimplificationQueue;
  29025. /**
  29026. * Gets or sets the simplification queue attached to the scene
  29027. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  29028. */
  29029. simplificationQueue: SimplificationQueue;
  29030. }
  29031. interface Mesh {
  29032. /**
  29033. * Simplify the mesh according to the given array of settings.
  29034. * Function will return immediately and will simplify async
  29035. * @param settings a collection of simplification settings
  29036. * @param parallelProcessing should all levels calculate parallel or one after the other
  29037. * @param simplificationType the type of simplification to run
  29038. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  29039. * @returns the current mesh
  29040. */
  29041. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  29042. }
  29043. /**
  29044. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  29045. * created in a scene
  29046. */
  29047. class SimplicationQueueSceneComponent implements ISceneComponent {
  29048. /**
  29049. * The component name helpfull to identify the component in the list of scene components.
  29050. */
  29051. readonly name: string;
  29052. /**
  29053. * The scene the component belongs to.
  29054. */
  29055. scene: Scene;
  29056. /**
  29057. * Creates a new instance of the component for the given scene
  29058. * @param scene Defines the scene to register the component in
  29059. */
  29060. constructor(scene: Scene);
  29061. /**
  29062. * Registers the component in a given scene
  29063. */
  29064. register(): void;
  29065. /**
  29066. * Rebuilds the elements related to this component in case of
  29067. * context lost for instance.
  29068. */
  29069. rebuild(): void;
  29070. /**
  29071. * Disposes the component and the associated ressources
  29072. */
  29073. dispose(): void;
  29074. private _beforeCameraUpdate;
  29075. }
  29076. }
  29077. declare module BABYLON {
  29078. /**
  29079. * Polygon
  29080. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  29081. */
  29082. class Polygon {
  29083. /**
  29084. * Creates a rectangle
  29085. * @param xmin bottom X coord
  29086. * @param ymin bottom Y coord
  29087. * @param xmax top X coord
  29088. * @param ymax top Y coord
  29089. * @returns points that make the resulting rectation
  29090. */
  29091. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  29092. /**
  29093. * Creates a circle
  29094. * @param radius radius of circle
  29095. * @param cx scale in x
  29096. * @param cy scale in y
  29097. * @param numberOfSides number of sides that make up the circle
  29098. * @returns points that make the resulting circle
  29099. */
  29100. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  29101. /**
  29102. * Creates a polygon from input string
  29103. * @param input Input polygon data
  29104. * @returns the parsed points
  29105. */
  29106. static Parse(input: string): Vector2[];
  29107. /**
  29108. * Starts building a polygon from x and y coordinates
  29109. * @param x x coordinate
  29110. * @param y y coordinate
  29111. * @returns the started path2
  29112. */
  29113. static StartingAt(x: number, y: number): Path2;
  29114. }
  29115. /**
  29116. * Builds a polygon
  29117. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  29118. */
  29119. class PolygonMeshBuilder {
  29120. private _points;
  29121. private _outlinepoints;
  29122. private _holes;
  29123. private _name;
  29124. private _scene;
  29125. private _epoints;
  29126. private _eholes;
  29127. private _addToepoint;
  29128. /**
  29129. * Creates a PolygonMeshBuilder
  29130. * @param name name of the builder
  29131. * @param contours Path of the polygon
  29132. * @param scene scene to add to
  29133. */
  29134. constructor(name: string, contours: Path2 | Vector2[] | any, scene: Scene);
  29135. /**
  29136. * Adds a whole within the polygon
  29137. * @param hole Array of points defining the hole
  29138. * @returns this
  29139. */
  29140. addHole(hole: Vector2[]): PolygonMeshBuilder;
  29141. /**
  29142. * Creates the polygon
  29143. * @param updatable If the mesh should be updatable
  29144. * @param depth The depth of the mesh created
  29145. * @returns the created mesh
  29146. */
  29147. build(updatable?: boolean, depth?: number): Mesh;
  29148. /**
  29149. * Adds a side to the polygon
  29150. * @param positions points that make the polygon
  29151. * @param normals normals of the polygon
  29152. * @param uvs uvs of the polygon
  29153. * @param indices indices of the polygon
  29154. * @param bounds bounds of the polygon
  29155. * @param points points of the polygon
  29156. * @param depth depth of the polygon
  29157. * @param flip flip of the polygon
  29158. */
  29159. private addSide;
  29160. }
  29161. }
  29162. declare module BABYLON {
  29163. /**
  29164. * Base class for submeshes
  29165. */
  29166. class BaseSubMesh {
  29167. /** @hidden */
  29168. _materialDefines: Nullable<MaterialDefines>;
  29169. /** @hidden */
  29170. _materialEffect: Nullable<Effect>;
  29171. /**
  29172. * Gets associated effect
  29173. */
  29174. readonly effect: Nullable<Effect>;
  29175. /**
  29176. * Sets associated effect (effect used to render this submesh)
  29177. * @param effect defines the effect to associate with
  29178. * @param defines defines the set of defines used to compile this effect
  29179. */
  29180. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  29181. }
  29182. /**
  29183. * Defines a subdivision inside a mesh
  29184. */
  29185. class SubMesh extends BaseSubMesh implements ICullable {
  29186. /** the material index to use */
  29187. materialIndex: number;
  29188. /** vertex index start */
  29189. verticesStart: number;
  29190. /** vertices count */
  29191. verticesCount: number;
  29192. /** index start */
  29193. indexStart: number;
  29194. /** indices count */
  29195. indexCount: number;
  29196. /** @hidden */
  29197. _linesIndexCount: number;
  29198. private _mesh;
  29199. private _renderingMesh;
  29200. private _boundingInfo;
  29201. private _linesIndexBuffer;
  29202. /** @hidden */
  29203. _lastColliderWorldVertices: Nullable<Vector3[]>;
  29204. /** @hidden */
  29205. _trianglePlanes: Plane[];
  29206. /** @hidden */
  29207. _lastColliderTransformMatrix: Matrix;
  29208. /** @hidden */
  29209. _renderId: number;
  29210. /** @hidden */
  29211. _alphaIndex: number;
  29212. /** @hidden */
  29213. _distanceToCamera: number;
  29214. /** @hidden */
  29215. _id: number;
  29216. private _currentMaterial;
  29217. /**
  29218. * Add a new submesh to a mesh
  29219. * @param materialIndex defines the material index to use
  29220. * @param verticesStart defines vertex index start
  29221. * @param verticesCount defines vertices count
  29222. * @param indexStart defines index start
  29223. * @param indexCount defines indices count
  29224. * @param mesh defines the parent mesh
  29225. * @param renderingMesh defines an optional rendering mesh
  29226. * @param createBoundingBox defines if bounding box should be created for this submesh
  29227. * @returns the new submesh
  29228. */
  29229. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  29230. /**
  29231. * Creates a new submesh
  29232. * @param materialIndex defines the material index to use
  29233. * @param verticesStart defines vertex index start
  29234. * @param verticesCount defines vertices count
  29235. * @param indexStart defines index start
  29236. * @param indexCount defines indices count
  29237. * @param mesh defines the parent mesh
  29238. * @param renderingMesh defines an optional rendering mesh
  29239. * @param createBoundingBox defines if bounding box should be created for this submesh
  29240. */
  29241. constructor(
  29242. /** the material index to use */
  29243. materialIndex: number,
  29244. /** vertex index start */
  29245. verticesStart: number,
  29246. /** vertices count */
  29247. verticesCount: number,
  29248. /** index start */
  29249. indexStart: number,
  29250. /** indices count */
  29251. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  29252. /**
  29253. * Returns true if this submesh covers the entire parent mesh
  29254. * @ignorenaming
  29255. */
  29256. readonly IsGlobal: boolean;
  29257. /**
  29258. * Returns the submesh BoudingInfo object
  29259. * @returns current bounding info (or mesh's one if the submesh is global)
  29260. */
  29261. getBoundingInfo(): BoundingInfo;
  29262. /**
  29263. * Sets the submesh BoundingInfo
  29264. * @param boundingInfo defines the new bounding info to use
  29265. * @returns the SubMesh
  29266. */
  29267. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  29268. /**
  29269. * Returns the mesh of the current submesh
  29270. * @return the parent mesh
  29271. */
  29272. getMesh(): AbstractMesh;
  29273. /**
  29274. * Returns the rendering mesh of the submesh
  29275. * @returns the rendering mesh (could be different from parent mesh)
  29276. */
  29277. getRenderingMesh(): Mesh;
  29278. /**
  29279. * Returns the submesh material
  29280. * @returns null or the current material
  29281. */
  29282. getMaterial(): Nullable<Material>;
  29283. /**
  29284. * Sets a new updated BoundingInfo object to the submesh
  29285. * @returns the SubMesh
  29286. */
  29287. refreshBoundingInfo(): SubMesh;
  29288. /** @hidden */
  29289. _checkCollision(collider: Collider): boolean;
  29290. /**
  29291. * Updates the submesh BoundingInfo
  29292. * @param world defines the world matrix to use to update the bounding info
  29293. * @returns the submesh
  29294. */
  29295. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  29296. /**
  29297. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  29298. * @param frustumPlanes defines the frustum planes
  29299. * @returns true if the submesh is intersecting with the frustum
  29300. */
  29301. isInFrustum(frustumPlanes: Plane[]): boolean;
  29302. /**
  29303. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  29304. * @param frustumPlanes defines the frustum planes
  29305. * @returns true if the submesh is inside the frustum
  29306. */
  29307. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  29308. /**
  29309. * Renders the submesh
  29310. * @param enableAlphaMode defines if alpha needs to be used
  29311. * @returns the submesh
  29312. */
  29313. render(enableAlphaMode: boolean): SubMesh;
  29314. /**
  29315. * @hidden
  29316. */
  29317. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  29318. /**
  29319. * Checks if the submesh intersects with a ray
  29320. * @param ray defines the ray to test
  29321. * @returns true is the passed ray intersects the submesh bounding box
  29322. */
  29323. canIntersects(ray: Ray): boolean;
  29324. /**
  29325. * Intersects current submesh with a ray
  29326. * @param ray defines the ray to test
  29327. * @param positions defines mesh's positions array
  29328. * @param indices defines mesh's indices array
  29329. * @param fastCheck defines if only bounding info should be used
  29330. * @returns intersection info or null if no intersection
  29331. */
  29332. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  29333. /** @hidden */
  29334. private _intersectLines;
  29335. /** @hidden */
  29336. private _intersectTriangles;
  29337. /** @hidden */
  29338. _rebuild(): void;
  29339. /**
  29340. * Creates a new submesh from the passed mesh
  29341. * @param newMesh defines the new hosting mesh
  29342. * @param newRenderingMesh defines an optional rendering mesh
  29343. * @returns the new submesh
  29344. */
  29345. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  29346. /**
  29347. * Release associated resources
  29348. */
  29349. dispose(): void;
  29350. /**
  29351. * Creates a new submesh from indices data
  29352. * @param materialIndex the index of the main mesh material
  29353. * @param startIndex the index where to start the copy in the mesh indices array
  29354. * @param indexCount the number of indices to copy then from the startIndex
  29355. * @param mesh the main mesh to create the submesh from
  29356. * @param renderingMesh the optional rendering mesh
  29357. * @returns a new submesh
  29358. */
  29359. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  29360. }
  29361. }
  29362. declare module BABYLON {
  29363. /**
  29364. * 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.
  29365. * @see https://doc.babylonjs.com/how_to/transformnode
  29366. */
  29367. class TransformNode extends Node {
  29368. /**
  29369. * Object will not rotate to face the camera
  29370. */
  29371. static BILLBOARDMODE_NONE: number;
  29372. /**
  29373. * Object will rotate to face the camera but only on the x axis
  29374. */
  29375. static BILLBOARDMODE_X: number;
  29376. /**
  29377. * Object will rotate to face the camera but only on the y axis
  29378. */
  29379. static BILLBOARDMODE_Y: number;
  29380. /**
  29381. * Object will rotate to face the camera but only on the z axis
  29382. */
  29383. static BILLBOARDMODE_Z: number;
  29384. /**
  29385. * Object will rotate to face the camera
  29386. */
  29387. static BILLBOARDMODE_ALL: number;
  29388. private _forward;
  29389. private _forwardInverted;
  29390. private _up;
  29391. private _right;
  29392. private _rightInverted;
  29393. private _position;
  29394. private _rotation;
  29395. private _rotationQuaternion;
  29396. protected _scaling: Vector3;
  29397. protected _isDirty: boolean;
  29398. private _transformToBoneReferal;
  29399. /**
  29400. * Set the billboard mode. Default is 0.
  29401. *
  29402. * | Value | Type | Description |
  29403. * | --- | --- | --- |
  29404. * | 0 | BILLBOARDMODE_NONE | |
  29405. * | 1 | BILLBOARDMODE_X | |
  29406. * | 2 | BILLBOARDMODE_Y | |
  29407. * | 4 | BILLBOARDMODE_Z | |
  29408. * | 7 | BILLBOARDMODE_ALL | |
  29409. *
  29410. */
  29411. billboardMode: number;
  29412. /**
  29413. * 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
  29414. */
  29415. scalingDeterminant: number;
  29416. /**
  29417. * Sets the distance of the object to max, often used by skybox
  29418. */
  29419. infiniteDistance: boolean;
  29420. /**
  29421. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  29422. * By default the system will update normals to compensate
  29423. */
  29424. ignoreNonUniformScaling: boolean;
  29425. /** @hidden */
  29426. _poseMatrix: Matrix;
  29427. /** @hidden */
  29428. _localMatrix: Matrix;
  29429. private _absolutePosition;
  29430. private _pivotMatrix;
  29431. private _pivotMatrixInverse;
  29432. protected _postMultiplyPivotMatrix: boolean;
  29433. protected _isWorldMatrixFrozen: boolean;
  29434. /** @hidden */
  29435. _indexInSceneTransformNodesArray: number;
  29436. /**
  29437. * An event triggered after the world matrix is updated
  29438. */
  29439. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  29440. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  29441. /**
  29442. * Gets a string identifying the name of the class
  29443. * @returns "TransformNode" string
  29444. */
  29445. getClassName(): string;
  29446. /**
  29447. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  29448. */
  29449. position: Vector3;
  29450. /**
  29451. * 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)).
  29452. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  29453. */
  29454. rotation: Vector3;
  29455. /**
  29456. * 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)).
  29457. */
  29458. scaling: Vector3;
  29459. /**
  29460. * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (null by default).
  29461. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  29462. */
  29463. rotationQuaternion: Nullable<Quaternion>;
  29464. /**
  29465. * The forward direction of that transform in world space.
  29466. */
  29467. readonly forward: Vector3;
  29468. /**
  29469. * The up direction of that transform in world space.
  29470. */
  29471. readonly up: Vector3;
  29472. /**
  29473. * The right direction of that transform in world space.
  29474. */
  29475. readonly right: Vector3;
  29476. /**
  29477. * Copies the parameter passed Matrix into the mesh Pose matrix.
  29478. * @param matrix the matrix to copy the pose from
  29479. * @returns this TransformNode.
  29480. */
  29481. updatePoseMatrix(matrix: Matrix): TransformNode;
  29482. /**
  29483. * Returns the mesh Pose matrix.
  29484. * @returns the pose matrix
  29485. */
  29486. getPoseMatrix(): Matrix;
  29487. /** @hidden */
  29488. _isSynchronized(): boolean;
  29489. /** @hidden */
  29490. _initCache(): void;
  29491. /**
  29492. * Flag the transform node as dirty (Forcing it to update everything)
  29493. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  29494. * @returns this transform node
  29495. */
  29496. markAsDirty(property: string): TransformNode;
  29497. /**
  29498. * Returns the current mesh absolute position.
  29499. * Returns a Vector3.
  29500. */
  29501. readonly absolutePosition: Vector3;
  29502. /**
  29503. * Sets a new matrix to apply before all other transformation
  29504. * @param matrix defines the transform matrix
  29505. * @returns the current TransformNode
  29506. */
  29507. setPreTransformMatrix(matrix: Matrix): TransformNode;
  29508. /**
  29509. * Sets a new pivot matrix to the current node
  29510. * @param matrix defines the new pivot matrix to use
  29511. * @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
  29512. * @returns the current TransformNode
  29513. */
  29514. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  29515. /**
  29516. * Returns the mesh pivot matrix.
  29517. * Default : Identity.
  29518. * @returns the matrix
  29519. */
  29520. getPivotMatrix(): Matrix;
  29521. /**
  29522. * Prevents the World matrix to be computed any longer.
  29523. * @returns the TransformNode.
  29524. */
  29525. freezeWorldMatrix(): TransformNode;
  29526. /**
  29527. * Allows back the World matrix computation.
  29528. * @returns the TransformNode.
  29529. */
  29530. unfreezeWorldMatrix(): this;
  29531. /**
  29532. * True if the World matrix has been frozen.
  29533. */
  29534. readonly isWorldMatrixFrozen: boolean;
  29535. /**
  29536. * Retuns the mesh absolute position in the World.
  29537. * @returns a Vector3.
  29538. */
  29539. getAbsolutePosition(): Vector3;
  29540. /**
  29541. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  29542. * @param absolutePosition the absolute position to set
  29543. * @returns the TransformNode.
  29544. */
  29545. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  29546. /**
  29547. * Sets the mesh position in its local space.
  29548. * @param vector3 the position to set in localspace
  29549. * @returns the TransformNode.
  29550. */
  29551. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  29552. /**
  29553. * Returns the mesh position in the local space from the current World matrix values.
  29554. * @returns a new Vector3.
  29555. */
  29556. getPositionExpressedInLocalSpace(): Vector3;
  29557. /**
  29558. * Translates the mesh along the passed Vector3 in its local space.
  29559. * @param vector3 the distance to translate in localspace
  29560. * @returns the TransformNode.
  29561. */
  29562. locallyTranslate(vector3: Vector3): TransformNode;
  29563. private static _lookAtVectorCache;
  29564. /**
  29565. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  29566. * @param targetPoint the position (must be in same space as current mesh) to look at
  29567. * @param yawCor optional yaw (y-axis) correction in radians
  29568. * @param pitchCor optional pitch (x-axis) correction in radians
  29569. * @param rollCor optional roll (z-axis) correction in radians
  29570. * @param space the choosen space of the target
  29571. * @returns the TransformNode.
  29572. */
  29573. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  29574. /**
  29575. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  29576. * This Vector3 is expressed in the World space.
  29577. * @param localAxis axis to rotate
  29578. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  29579. */
  29580. getDirection(localAxis: Vector3): Vector3;
  29581. /**
  29582. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  29583. * localAxis is expressed in the mesh local space.
  29584. * result is computed in the Wordl space from the mesh World matrix.
  29585. * @param localAxis axis to rotate
  29586. * @param result the resulting transformnode
  29587. * @returns this TransformNode.
  29588. */
  29589. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  29590. /**
  29591. * Sets this transform node rotation to the given local axis.
  29592. * @param localAxis the axis in local space
  29593. * @param yawCor optional yaw (y-axis) correction in radians
  29594. * @param pitchCor optional pitch (x-axis) correction in radians
  29595. * @param rollCor optional roll (z-axis) correction in radians
  29596. * @returns this TransformNode
  29597. */
  29598. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  29599. /**
  29600. * Sets a new pivot point to the current node
  29601. * @param point defines the new pivot point to use
  29602. * @param space defines if the point is in world or local space (local by default)
  29603. * @returns the current TransformNode
  29604. */
  29605. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  29606. /**
  29607. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  29608. * @returns the pivot point
  29609. */
  29610. getPivotPoint(): Vector3;
  29611. /**
  29612. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  29613. * @param result the vector3 to store the result
  29614. * @returns this TransformNode.
  29615. */
  29616. getPivotPointToRef(result: Vector3): TransformNode;
  29617. /**
  29618. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  29619. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  29620. */
  29621. getAbsolutePivotPoint(): Vector3;
  29622. /**
  29623. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  29624. * @param result vector3 to store the result
  29625. * @returns this TransformNode.
  29626. */
  29627. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  29628. /**
  29629. * Defines the passed node as the parent of the current node.
  29630. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  29631. * @param node the node ot set as the parent
  29632. * @returns this TransformNode.
  29633. */
  29634. setParent(node: Nullable<Node>): TransformNode;
  29635. private _nonUniformScaling;
  29636. /**
  29637. * True if the scaling property of this object is non uniform eg. (1,2,1)
  29638. */
  29639. readonly nonUniformScaling: boolean;
  29640. /** @hidden */
  29641. _updateNonUniformScalingState(value: boolean): boolean;
  29642. /**
  29643. * Attach the current TransformNode to another TransformNode associated with a bone
  29644. * @param bone Bone affecting the TransformNode
  29645. * @param affectedTransformNode TransformNode associated with the bone
  29646. * @returns this object
  29647. */
  29648. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  29649. /**
  29650. * Detach the transform node if its associated with a bone
  29651. * @returns this object
  29652. */
  29653. detachFromBone(): TransformNode;
  29654. private static _rotationAxisCache;
  29655. /**
  29656. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  29657. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  29658. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  29659. * The passed axis is also normalized.
  29660. * @param axis the axis to rotate around
  29661. * @param amount the amount to rotate in radians
  29662. * @param space Space to rotate in (Default: local)
  29663. * @returns the TransformNode.
  29664. */
  29665. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  29666. /**
  29667. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  29668. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  29669. * The passed axis is also normalized. .
  29670. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  29671. * @param point the point to rotate around
  29672. * @param axis the axis to rotate around
  29673. * @param amount the amount to rotate in radians
  29674. * @returns the TransformNode
  29675. */
  29676. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  29677. /**
  29678. * Translates the mesh along the axis vector for the passed distance in the given space.
  29679. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  29680. * @param axis the axis to translate in
  29681. * @param distance the distance to translate
  29682. * @param space Space to rotate in (Default: local)
  29683. * @returns the TransformNode.
  29684. */
  29685. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  29686. /**
  29687. * Adds a rotation step to the mesh current rotation.
  29688. * x, y, z are Euler angles expressed in radians.
  29689. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  29690. * This means this rotation is made in the mesh local space only.
  29691. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  29692. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  29693. * ```javascript
  29694. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  29695. * ```
  29696. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  29697. * 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.
  29698. * @param x Rotation to add
  29699. * @param y Rotation to add
  29700. * @param z Rotation to add
  29701. * @returns the TransformNode.
  29702. */
  29703. addRotation(x: number, y: number, z: number): TransformNode;
  29704. /**
  29705. * Computes the world matrix of the node
  29706. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29707. * @returns the world matrix
  29708. */
  29709. computeWorldMatrix(force?: boolean): Matrix;
  29710. protected _afterComputeWorldMatrix(): void;
  29711. /**
  29712. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  29713. * @param func callback function to add
  29714. *
  29715. * @returns the TransformNode.
  29716. */
  29717. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  29718. /**
  29719. * Removes a registered callback function.
  29720. * @param func callback function to remove
  29721. * @returns the TransformNode.
  29722. */
  29723. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  29724. /**
  29725. * Gets the position of the current mesh in camera space
  29726. * @param camera defines the camera to use
  29727. * @returns a position
  29728. */
  29729. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  29730. /**
  29731. * Returns the distance from the mesh to the active camera
  29732. * @param camera defines the camera to use
  29733. * @returns the distance
  29734. */
  29735. getDistanceToCamera(camera?: Nullable<Camera>): number;
  29736. /**
  29737. * Clone the current transform node
  29738. * @param name Name of the new clone
  29739. * @param newParent New parent for the clone
  29740. * @param doNotCloneChildren Do not clone children hierarchy
  29741. * @returns the new transform node
  29742. */
  29743. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  29744. /**
  29745. * Serializes the objects information.
  29746. * @param currentSerializationObject defines the object to serialize in
  29747. * @returns the serialized object
  29748. */
  29749. serialize(currentSerializationObject?: any): any;
  29750. /**
  29751. * Returns a new TransformNode object parsed from the source provided.
  29752. * @param parsedTransformNode is the source.
  29753. * @param scene the scne the object belongs to
  29754. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  29755. * @returns a new TransformNode object parsed from the source provided.
  29756. */
  29757. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  29758. /**
  29759. * Releases resources associated with this transform node.
  29760. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29761. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29762. */
  29763. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29764. }
  29765. }
  29766. declare module BABYLON {
  29767. /**
  29768. * Specialized buffer used to store vertex data
  29769. */
  29770. class VertexBuffer {
  29771. /** @hidden */
  29772. _buffer: Buffer;
  29773. private _kind;
  29774. private _size;
  29775. private _ownsBuffer;
  29776. private _instanced;
  29777. private _instanceDivisor;
  29778. /**
  29779. * The byte type.
  29780. */
  29781. static readonly BYTE: number;
  29782. /**
  29783. * The unsigned byte type.
  29784. */
  29785. static readonly UNSIGNED_BYTE: number;
  29786. /**
  29787. * The short type.
  29788. */
  29789. static readonly SHORT: number;
  29790. /**
  29791. * The unsigned short type.
  29792. */
  29793. static readonly UNSIGNED_SHORT: number;
  29794. /**
  29795. * The integer type.
  29796. */
  29797. static readonly INT: number;
  29798. /**
  29799. * The unsigned integer type.
  29800. */
  29801. static readonly UNSIGNED_INT: number;
  29802. /**
  29803. * The float type.
  29804. */
  29805. static readonly FLOAT: number;
  29806. /**
  29807. * Gets or sets the instance divisor when in instanced mode
  29808. */
  29809. instanceDivisor: number;
  29810. /**
  29811. * Gets the byte stride.
  29812. */
  29813. readonly byteStride: number;
  29814. /**
  29815. * Gets the byte offset.
  29816. */
  29817. readonly byteOffset: number;
  29818. /**
  29819. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  29820. */
  29821. readonly normalized: boolean;
  29822. /**
  29823. * Gets the data type of each component in the array.
  29824. */
  29825. readonly type: number;
  29826. /**
  29827. * Constructor
  29828. * @param engine the engine
  29829. * @param data the data to use for this vertex buffer
  29830. * @param kind the vertex buffer kind
  29831. * @param updatable whether the data is updatable
  29832. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  29833. * @param stride the stride (optional)
  29834. * @param instanced whether the buffer is instanced (optional)
  29835. * @param offset the offset of the data (optional)
  29836. * @param size the number of components (optional)
  29837. * @param type the type of the component (optional)
  29838. * @param normalized whether the data contains normalized data (optional)
  29839. * @param useBytes set to true if stride and offset are in bytes (optional)
  29840. */
  29841. 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);
  29842. /** @hidden */
  29843. _rebuild(): void;
  29844. /**
  29845. * Returns the kind of the VertexBuffer (string)
  29846. * @returns a string
  29847. */
  29848. getKind(): string;
  29849. /**
  29850. * Gets a boolean indicating if the VertexBuffer is updatable?
  29851. * @returns true if the buffer is updatable
  29852. */
  29853. isUpdatable(): boolean;
  29854. /**
  29855. * Gets current buffer's data
  29856. * @returns a DataArray or null
  29857. */
  29858. getData(): Nullable<DataArray>;
  29859. /**
  29860. * Gets underlying native buffer
  29861. * @returns underlying native buffer
  29862. */
  29863. getBuffer(): Nullable<WebGLBuffer>;
  29864. /**
  29865. * Gets the stride in float32 units (i.e. byte stride / 4).
  29866. * May not be an integer if the byte stride is not divisible by 4.
  29867. * DEPRECATED. Use byteStride instead.
  29868. * @returns the stride in float32 units
  29869. */
  29870. getStrideSize(): number;
  29871. /**
  29872. * Returns the offset as a multiple of the type byte length.
  29873. * DEPRECATED. Use byteOffset instead.
  29874. * @returns the offset in bytes
  29875. */
  29876. getOffset(): number;
  29877. /**
  29878. * Returns the number of components per vertex attribute (integer)
  29879. * @returns the size in float
  29880. */
  29881. getSize(): number;
  29882. /**
  29883. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  29884. * @returns true if this buffer is instanced
  29885. */
  29886. getIsInstanced(): boolean;
  29887. /**
  29888. * Returns the instancing divisor, zero for non-instanced (integer).
  29889. * @returns a number
  29890. */
  29891. getInstanceDivisor(): number;
  29892. /**
  29893. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  29894. * @param data defines the data to store
  29895. */
  29896. create(data?: DataArray): void;
  29897. /**
  29898. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  29899. * This function will create a new buffer if the current one is not updatable
  29900. * @param data defines the data to store
  29901. */
  29902. update(data: DataArray): void;
  29903. /**
  29904. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  29905. * Returns the directly updated WebGLBuffer.
  29906. * @param data the new data
  29907. * @param offset the new offset
  29908. * @param useBytes set to true if the offset is in bytes
  29909. */
  29910. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  29911. /**
  29912. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  29913. */
  29914. dispose(): void;
  29915. /**
  29916. * Enumerates each value of this vertex buffer as numbers.
  29917. * @param count the number of values to enumerate
  29918. * @param callback the callback function called for each value
  29919. */
  29920. forEach(count: number, callback: (value: number, index: number) => void): void;
  29921. /**
  29922. * Positions
  29923. */
  29924. static readonly PositionKind: string;
  29925. /**
  29926. * Normals
  29927. */
  29928. static readonly NormalKind: string;
  29929. /**
  29930. * Tangents
  29931. */
  29932. static readonly TangentKind: string;
  29933. /**
  29934. * Texture coordinates
  29935. */
  29936. static readonly UVKind: string;
  29937. /**
  29938. * Texture coordinates 2
  29939. */
  29940. static readonly UV2Kind: string;
  29941. /**
  29942. * Texture coordinates 3
  29943. */
  29944. static readonly UV3Kind: string;
  29945. /**
  29946. * Texture coordinates 4
  29947. */
  29948. static readonly UV4Kind: string;
  29949. /**
  29950. * Texture coordinates 5
  29951. */
  29952. static readonly UV5Kind: string;
  29953. /**
  29954. * Texture coordinates 6
  29955. */
  29956. static readonly UV6Kind: string;
  29957. /**
  29958. * Colors
  29959. */
  29960. static readonly ColorKind: string;
  29961. /**
  29962. * Matrix indices (for bones)
  29963. */
  29964. static readonly MatricesIndicesKind: string;
  29965. /**
  29966. * Matrix weights (for bones)
  29967. */
  29968. static readonly MatricesWeightsKind: string;
  29969. /**
  29970. * Additional matrix indices (for bones)
  29971. */
  29972. static readonly MatricesIndicesExtraKind: string;
  29973. /**
  29974. * Additional matrix weights (for bones)
  29975. */
  29976. static readonly MatricesWeightsExtraKind: string;
  29977. /**
  29978. * Deduces the stride given a kind.
  29979. * @param kind The kind string to deduce
  29980. * @returns The deduced stride
  29981. */
  29982. static DeduceStride(kind: string): number;
  29983. /**
  29984. * Gets the byte length of the given type.
  29985. * @param type the type
  29986. * @returns the number of bytes
  29987. */
  29988. static GetTypeByteLength(type: number): number;
  29989. /**
  29990. * Enumerates each value of the given parameters as numbers.
  29991. * @param data the data to enumerate
  29992. * @param byteOffset the byte offset of the data
  29993. * @param byteStride the byte stride of the data
  29994. * @param componentCount the number of components per element
  29995. * @param componentType the type of the component
  29996. * @param count the total number of components
  29997. * @param normalized whether the data is normalized
  29998. * @param callback the callback function called for each value
  29999. */
  30000. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  30001. private static _GetFloatValue;
  30002. }
  30003. }
  30004. declare module BABYLON {
  30005. /**
  30006. * Defines a target to use with MorphTargetManager
  30007. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  30008. */
  30009. class MorphTarget implements IAnimatable {
  30010. /** defines the name of the target */
  30011. name: string;
  30012. /**
  30013. * Gets or sets the list of animations
  30014. */
  30015. animations: Animation[];
  30016. private _scene;
  30017. private _positions;
  30018. private _normals;
  30019. private _tangents;
  30020. private _influence;
  30021. /**
  30022. * Observable raised when the influence changes
  30023. */
  30024. onInfluenceChanged: Observable<boolean>;
  30025. /** @hidden */
  30026. _onDataLayoutChanged: Observable<void>;
  30027. /**
  30028. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  30029. */
  30030. influence: number;
  30031. /**
  30032. * Gets or sets the id of the morph Target
  30033. */
  30034. id: string;
  30035. private _animationPropertiesOverride;
  30036. /**
  30037. * Gets or sets the animation properties override
  30038. */
  30039. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  30040. /**
  30041. * Creates a new MorphTarget
  30042. * @param name defines the name of the target
  30043. * @param influence defines the influence to use
  30044. */
  30045. constructor(
  30046. /** defines the name of the target */
  30047. name: string, influence?: number, scene?: Nullable<Scene>);
  30048. /**
  30049. * Gets a boolean defining if the target contains position data
  30050. */
  30051. readonly hasPositions: boolean;
  30052. /**
  30053. * Gets a boolean defining if the target contains normal data
  30054. */
  30055. readonly hasNormals: boolean;
  30056. /**
  30057. * Gets a boolean defining if the target contains tangent data
  30058. */
  30059. readonly hasTangents: boolean;
  30060. /**
  30061. * Affects position data to this target
  30062. * @param data defines the position data to use
  30063. */
  30064. setPositions(data: Nullable<FloatArray>): void;
  30065. /**
  30066. * Gets the position data stored in this target
  30067. * @returns a FloatArray containing the position data (or null if not present)
  30068. */
  30069. getPositions(): Nullable<FloatArray>;
  30070. /**
  30071. * Affects normal data to this target
  30072. * @param data defines the normal data to use
  30073. */
  30074. setNormals(data: Nullable<FloatArray>): void;
  30075. /**
  30076. * Gets the normal data stored in this target
  30077. * @returns a FloatArray containing the normal data (or null if not present)
  30078. */
  30079. getNormals(): Nullable<FloatArray>;
  30080. /**
  30081. * Affects tangent data to this target
  30082. * @param data defines the tangent data to use
  30083. */
  30084. setTangents(data: Nullable<FloatArray>): void;
  30085. /**
  30086. * Gets the tangent data stored in this target
  30087. * @returns a FloatArray containing the tangent data (or null if not present)
  30088. */
  30089. getTangents(): Nullable<FloatArray>;
  30090. /**
  30091. * Serializes the current target into a Serialization object
  30092. * @returns the serialized object
  30093. */
  30094. serialize(): any;
  30095. /**
  30096. * Returns the string "MorphTarget"
  30097. * @returns "MorphTarget"
  30098. */
  30099. getClassName(): string;
  30100. /**
  30101. * Creates a new target from serialized data
  30102. * @param serializationObject defines the serialized data to use
  30103. * @returns a new MorphTarget
  30104. */
  30105. static Parse(serializationObject: any): MorphTarget;
  30106. /**
  30107. * Creates a MorphTarget from mesh data
  30108. * @param mesh defines the source mesh
  30109. * @param name defines the name to use for the new target
  30110. * @param influence defines the influence to attach to the target
  30111. * @returns a new MorphTarget
  30112. */
  30113. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  30114. }
  30115. }
  30116. declare module BABYLON {
  30117. /**
  30118. * This class is used to deform meshes using morphing between different targets
  30119. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  30120. */
  30121. class MorphTargetManager {
  30122. private _targets;
  30123. private _targetInfluenceChangedObservers;
  30124. private _targetDataLayoutChangedObservers;
  30125. private _activeTargets;
  30126. private _scene;
  30127. private _influences;
  30128. private _supportsNormals;
  30129. private _supportsTangents;
  30130. private _vertexCount;
  30131. private _uniqueId;
  30132. private _tempInfluences;
  30133. /**
  30134. * Creates a new MorphTargetManager
  30135. * @param scene defines the current scene
  30136. */
  30137. constructor(scene?: Nullable<Scene>);
  30138. /**
  30139. * Gets the unique ID of this manager
  30140. */
  30141. readonly uniqueId: number;
  30142. /**
  30143. * Gets the number of vertices handled by this manager
  30144. */
  30145. readonly vertexCount: number;
  30146. /**
  30147. * Gets a boolean indicating if this manager supports morphing of normals
  30148. */
  30149. readonly supportsNormals: boolean;
  30150. /**
  30151. * Gets a boolean indicating if this manager supports morphing of tangents
  30152. */
  30153. readonly supportsTangents: boolean;
  30154. /**
  30155. * Gets the number of targets stored in this manager
  30156. */
  30157. readonly numTargets: number;
  30158. /**
  30159. * Gets the number of influencers (ie. the number of targets with influences > 0)
  30160. */
  30161. readonly numInfluencers: number;
  30162. /**
  30163. * Gets the list of influences (one per target)
  30164. */
  30165. readonly influences: Float32Array;
  30166. /**
  30167. * Gets the active target at specified index. An active target is a target with an influence > 0
  30168. * @param index defines the index to check
  30169. * @returns the requested target
  30170. */
  30171. getActiveTarget(index: number): MorphTarget;
  30172. /**
  30173. * Gets the target at specified index
  30174. * @param index defines the index to check
  30175. * @returns the requested target
  30176. */
  30177. getTarget(index: number): MorphTarget;
  30178. /**
  30179. * Add a new target to this manager
  30180. * @param target defines the target to add
  30181. */
  30182. addTarget(target: MorphTarget): void;
  30183. /**
  30184. * Removes a target from the manager
  30185. * @param target defines the target to remove
  30186. */
  30187. removeTarget(target: MorphTarget): void;
  30188. /**
  30189. * Serializes the current manager into a Serialization object
  30190. * @returns the serialized object
  30191. */
  30192. serialize(): any;
  30193. private _syncActiveTargets;
  30194. /**
  30195. * Syncrhonize the targets with all the meshes using this morph target manager
  30196. */
  30197. synchronize(): void;
  30198. /**
  30199. * Creates a new MorphTargetManager from serialized data
  30200. * @param serializationObject defines the serialized data
  30201. * @param scene defines the hosting scene
  30202. * @returns the new MorphTargetManager
  30203. */
  30204. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  30205. }
  30206. }
  30207. declare module BABYLON {
  30208. /**
  30209. * Class used to enable access to IndexedDB
  30210. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  30211. */
  30212. class Database implements IOfflineProvider {
  30213. private _callbackManifestChecked;
  30214. private _currentSceneUrl;
  30215. private _db;
  30216. private _enableSceneOffline;
  30217. private _enableTexturesOffline;
  30218. private _manifestVersionFound;
  30219. private _mustUpdateRessources;
  30220. private _hasReachedQuota;
  30221. private _isSupported;
  30222. private _idbFactory;
  30223. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  30224. private static IsUASupportingBlobStorage;
  30225. /**
  30226. * Gets a boolean indicating if Database storate is enabled (off by default)
  30227. */
  30228. static IDBStorageEnabled: boolean;
  30229. /**
  30230. * Gets a boolean indicating if scene must be saved in the database
  30231. */
  30232. readonly enableSceneOffline: boolean;
  30233. /**
  30234. * Gets a boolean indicating if textures must be saved in the database
  30235. */
  30236. readonly enableTexturesOffline: boolean;
  30237. /**
  30238. * Creates a new Database
  30239. * @param urlToScene defines the url to load the scene
  30240. * @param callbackManifestChecked defines the callback to use when manifest is checked
  30241. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  30242. */
  30243. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  30244. private static _ParseURL;
  30245. private static _ReturnFullUrlLocation;
  30246. private _checkManifestFile;
  30247. /**
  30248. * Open the database and make it available
  30249. * @param successCallback defines the callback to call on success
  30250. * @param errorCallback defines the callback to call on error
  30251. */
  30252. open(successCallback: () => void, errorCallback: () => void): void;
  30253. /**
  30254. * Loads an image from the database
  30255. * @param url defines the url to load from
  30256. * @param image defines the target DOM image
  30257. */
  30258. loadImage(url: string, image: HTMLImageElement): void;
  30259. private _loadImageFromDBAsync;
  30260. private _saveImageIntoDBAsync;
  30261. private _checkVersionFromDB;
  30262. private _loadVersionFromDBAsync;
  30263. private _saveVersionIntoDBAsync;
  30264. /**
  30265. * Loads a file from database
  30266. * @param url defines the URL to load from
  30267. * @param sceneLoaded defines a callback to call on success
  30268. * @param progressCallBack defines a callback to call when progress changed
  30269. * @param errorCallback defines a callback to call on error
  30270. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  30271. */
  30272. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  30273. private _loadFileAsync;
  30274. private _saveFileAsync;
  30275. }
  30276. }
  30277. declare module BABYLON {
  30278. /**
  30279. * Class used to enable access to offline support
  30280. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  30281. */
  30282. interface IOfflineProvider {
  30283. /**
  30284. * Gets a boolean indicating if scene must be saved in the database
  30285. */
  30286. enableSceneOffline: boolean;
  30287. /**
  30288. * Gets a boolean indicating if textures must be saved in the database
  30289. */
  30290. enableTexturesOffline: boolean;
  30291. /**
  30292. * Open the offline support and make it available
  30293. * @param successCallback defines the callback to call on success
  30294. * @param errorCallback defines the callback to call on error
  30295. */
  30296. open(successCallback: () => void, errorCallback: () => void): void;
  30297. /**
  30298. * Loads an image from the offline support
  30299. * @param url defines the url to load from
  30300. * @param image defines the target DOM image
  30301. */
  30302. loadImage(url: string, image: HTMLImageElement): void;
  30303. /**
  30304. * Loads a file from offline support
  30305. * @param url defines the URL to load from
  30306. * @param sceneLoaded defines a callback to call on success
  30307. * @param progressCallBack defines a callback to call when progress changed
  30308. * @param errorCallback defines a callback to call on error
  30309. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  30310. */
  30311. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  30312. }
  30313. }
  30314. declare module BABYLON {
  30315. /**
  30316. * Interface used to describe a physics joint
  30317. */
  30318. interface PhysicsImpostorJoint {
  30319. /** Defines the main impostor to which the joint is linked */
  30320. mainImpostor: PhysicsImpostor;
  30321. /** Defines the impostor that is connected to the main impostor using this joint */
  30322. connectedImpostor: PhysicsImpostor;
  30323. /** Defines the joint itself */
  30324. joint: PhysicsJoint;
  30325. }
  30326. /** @hidden */
  30327. interface IPhysicsEnginePlugin {
  30328. world: any;
  30329. name: string;
  30330. setGravity(gravity: Vector3): void;
  30331. setTimeStep(timeStep: number): void;
  30332. getTimeStep(): number;
  30333. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  30334. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  30335. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  30336. generatePhysicsBody(impostor: PhysicsImpostor): void;
  30337. removePhysicsBody(impostor: PhysicsImpostor): void;
  30338. generateJoint(joint: PhysicsImpostorJoint): void;
  30339. removeJoint(joint: PhysicsImpostorJoint): void;
  30340. isSupported(): boolean;
  30341. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  30342. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  30343. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  30344. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  30345. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  30346. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  30347. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  30348. getBodyMass(impostor: PhysicsImpostor): number;
  30349. getBodyFriction(impostor: PhysicsImpostor): number;
  30350. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  30351. getBodyRestitution(impostor: PhysicsImpostor): number;
  30352. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  30353. sleepBody(impostor: PhysicsImpostor): void;
  30354. wakeUpBody(impostor: PhysicsImpostor): void;
  30355. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  30356. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  30357. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  30358. getRadius(impostor: PhysicsImpostor): number;
  30359. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  30360. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  30361. dispose(): void;
  30362. }
  30363. /**
  30364. * Interface used to define a physics engine
  30365. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  30366. */
  30367. interface IPhysicsEngine {
  30368. /**
  30369. * Gets the gravity vector used by the simulation
  30370. */
  30371. gravity: Vector3;
  30372. /**
  30373. * Sets the gravity vector used by the simulation
  30374. * @param gravity defines the gravity vector to use
  30375. */
  30376. setGravity(gravity: Vector3): void;
  30377. /**
  30378. * Set the time step of the physics engine.
  30379. * Default is 1/60.
  30380. * To slow it down, enter 1/600 for example.
  30381. * To speed it up, 1/30
  30382. * @param newTimeStep the new timestep to apply to this world.
  30383. */
  30384. setTimeStep(newTimeStep: number): void;
  30385. /**
  30386. * Get the time step of the physics engine.
  30387. * @returns the current time step
  30388. */
  30389. getTimeStep(): number;
  30390. /**
  30391. * Release all resources
  30392. */
  30393. dispose(): void;
  30394. /**
  30395. * Gets the name of the current physics plugin
  30396. * @returns the name of the plugin
  30397. */
  30398. getPhysicsPluginName(): string;
  30399. /**
  30400. * Adding a new impostor for the impostor tracking.
  30401. * This will be done by the impostor itself.
  30402. * @param impostor the impostor to add
  30403. */
  30404. addImpostor(impostor: PhysicsImpostor): void;
  30405. /**
  30406. * Remove an impostor from the engine.
  30407. * This impostor and its mesh will not longer be updated by the physics engine.
  30408. * @param impostor the impostor to remove
  30409. */
  30410. removeImpostor(impostor: PhysicsImpostor): void;
  30411. /**
  30412. * Add a joint to the physics engine
  30413. * @param mainImpostor defines the main impostor to which the joint is added.
  30414. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  30415. * @param joint defines the joint that will connect both impostors.
  30416. */
  30417. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  30418. /**
  30419. * Removes a joint from the simulation
  30420. * @param mainImpostor defines the impostor used with the joint
  30421. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  30422. * @param joint defines the joint to remove
  30423. */
  30424. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  30425. /**
  30426. * Gets the current plugin used to run the simulation
  30427. * @returns current plugin
  30428. */
  30429. getPhysicsPlugin(): IPhysicsEnginePlugin;
  30430. /**
  30431. * Gets the list of physic impostors
  30432. * @returns an array of PhysicsImpostor
  30433. */
  30434. getImpostors(): Array<PhysicsImpostor>;
  30435. /**
  30436. * Gets the impostor for a physics enabled object
  30437. * @param object defines the object impersonated by the impostor
  30438. * @returns the PhysicsImpostor or null if not found
  30439. */
  30440. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  30441. /**
  30442. * Gets the impostor for a physics body object
  30443. * @param body defines physics body used by the impostor
  30444. * @returns the PhysicsImpostor or null if not found
  30445. */
  30446. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  30447. /**
  30448. * Called by the scene. No need to call it.
  30449. * @param delta defines the timespam between frames
  30450. */
  30451. _step(delta: number): void;
  30452. }
  30453. }
  30454. declare module BABYLON {
  30455. /**
  30456. * Class used to control physics engine
  30457. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  30458. */
  30459. class PhysicsEngine implements IPhysicsEngine {
  30460. private _physicsPlugin;
  30461. /**
  30462. * Global value used to control the smallest number supported by the simulation
  30463. */
  30464. static Epsilon: number;
  30465. private _impostors;
  30466. private _joints;
  30467. /**
  30468. * Gets the gravity vector used by the simulation
  30469. */
  30470. gravity: Vector3;
  30471. /**
  30472. * Creates a new Physics Engine
  30473. * @param gravity defines the gravity vector used by the simulation
  30474. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  30475. */
  30476. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  30477. /**
  30478. * Sets the gravity vector used by the simulation
  30479. * @param gravity defines the gravity vector to use
  30480. */
  30481. setGravity(gravity: Vector3): void;
  30482. /**
  30483. * Set the time step of the physics engine.
  30484. * Default is 1/60.
  30485. * To slow it down, enter 1/600 for example.
  30486. * To speed it up, 1/30
  30487. * @param newTimeStep defines the new timestep to apply to this world.
  30488. */
  30489. setTimeStep(newTimeStep?: number): void;
  30490. /**
  30491. * Get the time step of the physics engine.
  30492. * @returns the current time step
  30493. */
  30494. getTimeStep(): number;
  30495. /**
  30496. * Release all resources
  30497. */
  30498. dispose(): void;
  30499. /**
  30500. * Gets the name of the current physics plugin
  30501. * @returns the name of the plugin
  30502. */
  30503. getPhysicsPluginName(): string;
  30504. /**
  30505. * Adding a new impostor for the impostor tracking.
  30506. * This will be done by the impostor itself.
  30507. * @param impostor the impostor to add
  30508. */
  30509. addImpostor(impostor: PhysicsImpostor): void;
  30510. /**
  30511. * Remove an impostor from the engine.
  30512. * This impostor and its mesh will not longer be updated by the physics engine.
  30513. * @param impostor the impostor to remove
  30514. */
  30515. removeImpostor(impostor: PhysicsImpostor): void;
  30516. /**
  30517. * Add a joint to the physics engine
  30518. * @param mainImpostor defines the main impostor to which the joint is added.
  30519. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  30520. * @param joint defines the joint that will connect both impostors.
  30521. */
  30522. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  30523. /**
  30524. * Removes a joint from the simulation
  30525. * @param mainImpostor defines the impostor used with the joint
  30526. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  30527. * @param joint defines the joint to remove
  30528. */
  30529. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  30530. /**
  30531. * Called by the scene. No need to call it.
  30532. * @param delta defines the timespam between frames
  30533. */
  30534. _step(delta: number): void;
  30535. /**
  30536. * Gets the current plugin used to run the simulation
  30537. * @returns current plugin
  30538. */
  30539. getPhysicsPlugin(): IPhysicsEnginePlugin;
  30540. /**
  30541. * Gets the list of physic impostors
  30542. * @returns an array of PhysicsImpostor
  30543. */
  30544. getImpostors(): Array<PhysicsImpostor>;
  30545. /**
  30546. * Gets the impostor for a physics enabled object
  30547. * @param object defines the object impersonated by the impostor
  30548. * @returns the PhysicsImpostor or null if not found
  30549. */
  30550. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  30551. /**
  30552. * Gets the impostor for a physics body object
  30553. * @param body defines physics body used by the impostor
  30554. * @returns the PhysicsImpostor or null if not found
  30555. */
  30556. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  30557. }
  30558. }
  30559. declare module BABYLON {
  30560. interface Scene {
  30561. /** @hidden (Backing field) */
  30562. _physicsEngine: Nullable<IPhysicsEngine>;
  30563. /**
  30564. * Gets the current physics engine
  30565. * @returns a IPhysicsEngine or null if none attached
  30566. */
  30567. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  30568. /**
  30569. * Enables physics to the current scene
  30570. * @param gravity defines the scene's gravity for the physics engine
  30571. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  30572. * @return a boolean indicating if the physics engine was initialized
  30573. */
  30574. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  30575. /**
  30576. * Disables and disposes the physics engine associated with the scene
  30577. */
  30578. disablePhysicsEngine(): void;
  30579. /**
  30580. * Gets a boolean indicating if there is an active physics engine
  30581. * @returns a boolean indicating if there is an active physics engine
  30582. */
  30583. isPhysicsEnabled(): boolean;
  30584. /**
  30585. * Deletes a physics compound impostor
  30586. * @param compound defines the compound to delete
  30587. */
  30588. deleteCompoundImpostor(compound: any): void;
  30589. /**
  30590. * An event triggered when physic simulation is about to be run
  30591. */
  30592. onBeforePhysicsObservable: Observable<Scene>;
  30593. /**
  30594. * An event triggered when physic simulation has been done
  30595. */
  30596. onAfterPhysicsObservable: Observable<Scene>;
  30597. }
  30598. interface AbstractMesh {
  30599. /** @hidden */
  30600. _physicsImpostor: Nullable<PhysicsImpostor>;
  30601. /**
  30602. * Gets or sets impostor used for physic simulation
  30603. * @see http://doc.babylonjs.com/features/physics_engine
  30604. */
  30605. physicsImpostor: Nullable<PhysicsImpostor>;
  30606. /**
  30607. * Gets the current physics impostor
  30608. * @see http://doc.babylonjs.com/features/physics_engine
  30609. * @returns a physics impostor or null
  30610. */
  30611. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  30612. /** Apply a physic impulse to the mesh
  30613. * @param force defines the force to apply
  30614. * @param contactPoint defines where to apply the force
  30615. * @returns the current mesh
  30616. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  30617. */
  30618. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  30619. /**
  30620. * Creates a physic joint between two meshes
  30621. * @param otherMesh defines the other mesh to use
  30622. * @param pivot1 defines the pivot to use on this mesh
  30623. * @param pivot2 defines the pivot to use on the other mesh
  30624. * @param options defines additional options (can be plugin dependent)
  30625. * @returns the current mesh
  30626. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  30627. */
  30628. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  30629. /** @hidden */
  30630. _disposePhysicsObserver: Nullable<Observer<Node>>;
  30631. }
  30632. /**
  30633. * Defines the physics engine scene component responsible to manage a physics engine
  30634. */
  30635. class PhysicsEngineSceneComponent implements ISceneComponent {
  30636. /**
  30637. * The component name helpful to identify the component in the list of scene components.
  30638. */
  30639. readonly name: string;
  30640. /**
  30641. * The scene the component belongs to.
  30642. */
  30643. scene: Scene;
  30644. /**
  30645. * Creates a new instance of the component for the given scene
  30646. * @param scene Defines the scene to register the component in
  30647. */
  30648. constructor(scene: Scene);
  30649. /**
  30650. * Registers the component in a given scene
  30651. */
  30652. register(): void;
  30653. /**
  30654. * Rebuilds the elements related to this component in case of
  30655. * context lost for instance.
  30656. */
  30657. rebuild(): void;
  30658. /**
  30659. * Disposes the component and the associated ressources
  30660. */
  30661. dispose(): void;
  30662. }
  30663. }
  30664. declare module BABYLON {
  30665. /**
  30666. * A helper for physics simulations
  30667. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  30668. */
  30669. class PhysicsHelper {
  30670. private _scene;
  30671. private _physicsEngine;
  30672. /**
  30673. * Initializes the Physics helper
  30674. * @param scene Babylon.js scene
  30675. */
  30676. constructor(scene: Scene);
  30677. /**
  30678. * Applies a radial explosion impulse
  30679. * @param origin the origin of the explosion
  30680. * @param radius the explosion radius
  30681. * @param strength the explosion strength
  30682. * @param falloff possible options: Constant & Linear. Defaults to Constant
  30683. * @returns A physics radial explosion event, or null
  30684. */
  30685. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  30686. /**
  30687. * Applies a radial explosion force
  30688. * @param origin the origin of the explosion
  30689. * @param radius the explosion radius
  30690. * @param strength the explosion strength
  30691. * @param falloff possible options: Constant & Linear. Defaults to Constant
  30692. * @returns A physics radial explosion event, or null
  30693. */
  30694. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  30695. /**
  30696. * Creates a gravitational field
  30697. * @param origin the origin of the explosion
  30698. * @param radius the explosion radius
  30699. * @param strength the explosion strength
  30700. * @param falloff possible options: Constant & Linear. Defaults to Constant
  30701. * @returns A physics gravitational field event, or null
  30702. */
  30703. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  30704. /**
  30705. * Creates a physics updraft event
  30706. * @param origin the origin of the updraft
  30707. * @param radius the radius of the updraft
  30708. * @param strength the strength of the updraft
  30709. * @param height the height of the updraft
  30710. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  30711. * @returns A physics updraft event, or null
  30712. */
  30713. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  30714. /**
  30715. * Creates a physics vortex event
  30716. * @param origin the of the vortex
  30717. * @param radius the radius of the vortex
  30718. * @param strength the strength of the vortex
  30719. * @param height the height of the vortex
  30720. * @returns a Physics vortex event, or null
  30721. * A physics vortex event or null
  30722. */
  30723. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  30724. }
  30725. /**
  30726. * Represents a physics radial explosion event
  30727. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  30728. */
  30729. class PhysicsRadialExplosionEvent {
  30730. private _scene;
  30731. private _sphere;
  30732. private _sphereOptions;
  30733. private _rays;
  30734. private _dataFetched;
  30735. /**
  30736. * Initializes a radial explosioin event
  30737. * @param scene BabylonJS scene
  30738. */
  30739. constructor(scene: Scene);
  30740. /**
  30741. * Returns the data related to the radial explosion event (sphere & rays).
  30742. * @returns The radial explosion event data
  30743. */
  30744. getData(): PhysicsRadialExplosionEventData;
  30745. /**
  30746. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  30747. * @param impostor A physics imposter
  30748. * @param origin the origin of the explosion
  30749. * @param radius the explosion radius
  30750. * @param strength the explosion strength
  30751. * @param falloff possible options: Constant & Linear
  30752. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  30753. */
  30754. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  30755. /**
  30756. * Disposes the sphere.
  30757. * @param force Specifies if the sphere should be disposed by force
  30758. */
  30759. dispose(force?: boolean): void;
  30760. /*** Helpers ***/
  30761. private _prepareSphere;
  30762. private _intersectsWithSphere;
  30763. }
  30764. /**
  30765. * Represents a gravitational field event
  30766. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  30767. */
  30768. class PhysicsGravitationalFieldEvent {
  30769. private _physicsHelper;
  30770. private _scene;
  30771. private _origin;
  30772. private _radius;
  30773. private _strength;
  30774. private _falloff;
  30775. private _tickCallback;
  30776. private _sphere;
  30777. private _dataFetched;
  30778. /**
  30779. * Initializes the physics gravitational field event
  30780. * @param physicsHelper A physics helper
  30781. * @param scene BabylonJS scene
  30782. * @param origin The origin position of the gravitational field event
  30783. * @param radius The radius of the gravitational field event
  30784. * @param strength The strength of the gravitational field event
  30785. * @param falloff The falloff for the gravitational field event
  30786. */
  30787. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  30788. /**
  30789. * Returns the data related to the gravitational field event (sphere).
  30790. * @returns A gravitational field event
  30791. */
  30792. getData(): PhysicsGravitationalFieldEventData;
  30793. /**
  30794. * Enables the gravitational field.
  30795. */
  30796. enable(): void;
  30797. /**
  30798. * Disables the gravitational field.
  30799. */
  30800. disable(): void;
  30801. /**
  30802. * Disposes the sphere.
  30803. * @param force The force to dispose from the gravitational field event
  30804. */
  30805. dispose(force?: boolean): void;
  30806. private _tick;
  30807. }
  30808. /**
  30809. * Represents a physics updraft event
  30810. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  30811. */
  30812. class PhysicsUpdraftEvent {
  30813. private _scene;
  30814. private _origin;
  30815. private _radius;
  30816. private _strength;
  30817. private _height;
  30818. private _updraftMode;
  30819. private _physicsEngine;
  30820. private _originTop;
  30821. private _originDirection;
  30822. private _tickCallback;
  30823. private _cylinder;
  30824. private _cylinderPosition;
  30825. private _dataFetched;
  30826. /**
  30827. * Initializes the physics updraft event
  30828. * @param _scene BabylonJS scene
  30829. * @param _origin The origin position of the updraft
  30830. * @param _radius The radius of the updraft
  30831. * @param _strength The strength of the updraft
  30832. * @param _height The height of the updraft
  30833. * @param _updraftMode The mode of the updraft
  30834. */
  30835. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  30836. /**
  30837. * Returns the data related to the updraft event (cylinder).
  30838. * @returns A physics updraft event
  30839. */
  30840. getData(): PhysicsUpdraftEventData;
  30841. /**
  30842. * Enables the updraft.
  30843. */
  30844. enable(): void;
  30845. /**
  30846. * Disables the cortex.
  30847. */
  30848. disable(): void;
  30849. /**
  30850. * Disposes the sphere.
  30851. * @param force Specifies if the updraft should be disposed by force
  30852. */
  30853. dispose(force?: boolean): void;
  30854. private getImpostorForceAndContactPoint;
  30855. private _tick;
  30856. /*** Helpers ***/
  30857. private _prepareCylinder;
  30858. private _intersectsWithCylinder;
  30859. }
  30860. /**
  30861. * Represents a physics vortex event
  30862. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  30863. */
  30864. class PhysicsVortexEvent {
  30865. private _scene;
  30866. private _origin;
  30867. private _radius;
  30868. private _strength;
  30869. private _height;
  30870. private _physicsEngine;
  30871. private _originTop;
  30872. private _centripetalForceThreshold;
  30873. private _updraftMultiplier;
  30874. private _tickCallback;
  30875. private _cylinder;
  30876. private _cylinderPosition;
  30877. private _dataFetched;
  30878. /**
  30879. * Initializes the physics vortex event
  30880. * @param _scene The BabylonJS scene
  30881. * @param _origin The origin position of the vortex
  30882. * @param _radius The radius of the vortex
  30883. * @param _strength The strength of the vortex
  30884. * @param _height The height of the vortex
  30885. */
  30886. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  30887. /**
  30888. * Returns the data related to the vortex event (cylinder).
  30889. * @returns The physics vortex event data
  30890. */
  30891. getData(): PhysicsVortexEventData;
  30892. /**
  30893. * Enables the vortex.
  30894. */
  30895. enable(): void;
  30896. /**
  30897. * Disables the cortex.
  30898. */
  30899. disable(): void;
  30900. /**
  30901. * Disposes the sphere.
  30902. * @param force
  30903. */
  30904. dispose(force?: boolean): void;
  30905. private getImpostorForceAndContactPoint;
  30906. private _tick;
  30907. /*** Helpers ***/
  30908. private _prepareCylinder;
  30909. private _intersectsWithCylinder;
  30910. }
  30911. /**
  30912. * The strenght of the force in correspondence to the distance of the affected object
  30913. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  30914. */
  30915. enum PhysicsRadialImpulseFalloff {
  30916. /** Defines that impulse is constant in strength across it's whole radius */
  30917. Constant = 0,
  30918. /** DEfines that impulse gets weaker if it's further from the origin */
  30919. Linear = 1
  30920. }
  30921. /**
  30922. * The strength of the force in correspondence to the distance of the affected object
  30923. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  30924. */
  30925. enum PhysicsUpdraftMode {
  30926. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  30927. Center = 0,
  30928. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  30929. Perpendicular = 1
  30930. }
  30931. /**
  30932. * Interface for a physics force and contact point
  30933. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  30934. */
  30935. interface PhysicsForceAndContactPoint {
  30936. /**
  30937. * The force applied at the contact point
  30938. */
  30939. force: Vector3;
  30940. /**
  30941. * The contact point
  30942. */
  30943. contactPoint: Vector3;
  30944. }
  30945. /**
  30946. * Interface for radial explosion event data
  30947. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  30948. */
  30949. interface PhysicsRadialExplosionEventData {
  30950. /**
  30951. * A sphere used for the radial explosion event
  30952. */
  30953. sphere: Mesh;
  30954. /**
  30955. * An array of rays for the radial explosion event
  30956. */
  30957. rays: Array<Ray>;
  30958. }
  30959. /**
  30960. * Interface for gravitational field event data
  30961. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  30962. */
  30963. interface PhysicsGravitationalFieldEventData {
  30964. /**
  30965. * A sphere mesh used for the gravitational field event
  30966. */
  30967. sphere: Mesh;
  30968. }
  30969. /**
  30970. * Interface for updraft event data
  30971. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  30972. */
  30973. interface PhysicsUpdraftEventData {
  30974. /**
  30975. * A cylinder used for the updraft event
  30976. */
  30977. cylinder: Mesh;
  30978. }
  30979. /**
  30980. * Interface for vortex event data
  30981. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  30982. */
  30983. interface PhysicsVortexEventData {
  30984. /**
  30985. * A cylinder used for the vortex event
  30986. */
  30987. cylinder: Mesh;
  30988. }
  30989. }
  30990. declare module BABYLON {
  30991. /**
  30992. * The interface for the physics imposter parameters
  30993. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  30994. */
  30995. interface PhysicsImpostorParameters {
  30996. /**
  30997. * The mass of the physics imposter
  30998. */
  30999. mass: number;
  31000. /**
  31001. * The friction of the physics imposter
  31002. */
  31003. friction?: number;
  31004. /**
  31005. * The coefficient of restitution of the physics imposter
  31006. */
  31007. restitution?: number;
  31008. /**
  31009. * The native options of the physics imposter
  31010. */
  31011. nativeOptions?: any;
  31012. /**
  31013. * Specifies if the parent should be ignored
  31014. */
  31015. ignoreParent?: boolean;
  31016. /**
  31017. * Specifies if bi-directional transformations should be disabled
  31018. */
  31019. disableBidirectionalTransformation?: boolean;
  31020. }
  31021. /**
  31022. * Interface for a physics-enabled object
  31023. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31024. */
  31025. interface IPhysicsEnabledObject {
  31026. /**
  31027. * The position of the physics-enabled object
  31028. */
  31029. position: Vector3;
  31030. /**
  31031. * The rotation of the physics-enabled object
  31032. */
  31033. rotationQuaternion: Nullable<Quaternion>;
  31034. /**
  31035. * The scale of the physics-enabled object
  31036. */
  31037. scaling: Vector3;
  31038. /**
  31039. * The rotation of the physics-enabled object
  31040. */
  31041. rotation?: Vector3;
  31042. /**
  31043. * The parent of the physics-enabled object
  31044. */
  31045. parent?: any;
  31046. /**
  31047. * The bounding info of the physics-enabled object
  31048. * @returns The bounding info of the physics-enabled object
  31049. */
  31050. getBoundingInfo(): BoundingInfo;
  31051. /**
  31052. * Computes the world matrix
  31053. * @param force Specifies if the world matrix should be computed by force
  31054. * @returns A world matrix
  31055. */
  31056. computeWorldMatrix(force: boolean): Matrix;
  31057. /**
  31058. * Gets the world matrix
  31059. * @returns A world matrix
  31060. */
  31061. getWorldMatrix?(): Matrix;
  31062. /**
  31063. * Gets the child meshes
  31064. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  31065. * @returns An array of abstract meshes
  31066. */
  31067. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  31068. /**
  31069. * Gets the vertex data
  31070. * @param kind The type of vertex data
  31071. * @returns A nullable array of numbers, or a float32 array
  31072. */
  31073. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  31074. /**
  31075. * Gets the indices from the mesh
  31076. * @returns A nullable array of index arrays
  31077. */
  31078. getIndices?(): Nullable<IndicesArray>;
  31079. /**
  31080. * Gets the scene from the mesh
  31081. * @returns the indices array or null
  31082. */
  31083. getScene?(): Scene;
  31084. /**
  31085. * Gets the absolute position from the mesh
  31086. * @returns the absolute position
  31087. */
  31088. getAbsolutePosition(): Vector3;
  31089. /**
  31090. * Gets the absolute pivot point from the mesh
  31091. * @returns the absolute pivot point
  31092. */
  31093. getAbsolutePivotPoint(): Vector3;
  31094. /**
  31095. * Rotates the mesh
  31096. * @param axis The axis of rotation
  31097. * @param amount The amount of rotation
  31098. * @param space The space of the rotation
  31099. * @returns The rotation transform node
  31100. */
  31101. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  31102. /**
  31103. * Translates the mesh
  31104. * @param axis The axis of translation
  31105. * @param distance The distance of translation
  31106. * @param space The space of the translation
  31107. * @returns The transform node
  31108. */
  31109. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  31110. /**
  31111. * Sets the absolute position of the mesh
  31112. * @param absolutePosition The absolute position of the mesh
  31113. * @returns The transform node
  31114. */
  31115. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  31116. /**
  31117. * Gets the class name of the mesh
  31118. * @returns The class name
  31119. */
  31120. getClassName(): string;
  31121. }
  31122. /**
  31123. * Represents a physics imposter
  31124. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31125. */
  31126. class PhysicsImpostor {
  31127. /**
  31128. * The physics-enabled object used as the physics imposter
  31129. */
  31130. object: IPhysicsEnabledObject;
  31131. /**
  31132. * The type of the physics imposter
  31133. */
  31134. type: number;
  31135. private _options;
  31136. private _scene?;
  31137. /**
  31138. * The default object size of the imposter
  31139. */
  31140. static DEFAULT_OBJECT_SIZE: Vector3;
  31141. /**
  31142. * The identity quaternion of the imposter
  31143. */
  31144. static IDENTITY_QUATERNION: Quaternion;
  31145. /** @hidden */
  31146. _pluginData: any;
  31147. private _physicsEngine;
  31148. private _physicsBody;
  31149. private _bodyUpdateRequired;
  31150. private _onBeforePhysicsStepCallbacks;
  31151. private _onAfterPhysicsStepCallbacks;
  31152. /** @hidden */
  31153. _onPhysicsCollideCallbacks: Array<{
  31154. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  31155. otherImpostors: Array<PhysicsImpostor>;
  31156. }>;
  31157. private _deltaPosition;
  31158. private _deltaRotation;
  31159. private _deltaRotationConjugated;
  31160. private _parent;
  31161. private _isDisposed;
  31162. private static _tmpVecs;
  31163. private static _tmpQuat;
  31164. /**
  31165. * Specifies if the physics imposter is disposed
  31166. */
  31167. readonly isDisposed: boolean;
  31168. /**
  31169. * Gets the mass of the physics imposter
  31170. */
  31171. mass: number;
  31172. /**
  31173. * Gets the coefficient of friction
  31174. */
  31175. /**
  31176. * Sets the coefficient of friction
  31177. */
  31178. friction: number;
  31179. /**
  31180. * Gets the coefficient of restitution
  31181. */
  31182. /**
  31183. * Sets the coefficient of restitution
  31184. */
  31185. restitution: number;
  31186. /**
  31187. * The unique id of the physics imposter
  31188. * set by the physics engine when adding this impostor to the array
  31189. */
  31190. uniqueId: number;
  31191. private _joints;
  31192. /**
  31193. * Initializes the physics imposter
  31194. * @param object The physics-enabled object used as the physics imposter
  31195. * @param type The type of the physics imposter
  31196. * @param _options The options for the physics imposter
  31197. * @param _scene The Babylon scene
  31198. */
  31199. constructor(
  31200. /**
  31201. * The physics-enabled object used as the physics imposter
  31202. */
  31203. object: IPhysicsEnabledObject,
  31204. /**
  31205. * The type of the physics imposter
  31206. */
  31207. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  31208. /**
  31209. * This function will completly initialize this impostor.
  31210. * It will create a new body - but only if this mesh has no parent.
  31211. * If it has, this impostor will not be used other than to define the impostor
  31212. * of the child mesh.
  31213. * @hidden
  31214. */
  31215. _init(): void;
  31216. private _getPhysicsParent;
  31217. /**
  31218. * Should a new body be generated.
  31219. * @returns boolean specifying if body initialization is required
  31220. */
  31221. isBodyInitRequired(): boolean;
  31222. /**
  31223. * Sets the updated scaling
  31224. * @param updated Specifies if the scaling is updated
  31225. */
  31226. setScalingUpdated(updated: boolean): void;
  31227. /**
  31228. * Force a regeneration of this or the parent's impostor's body.
  31229. * Use under cautious - This will remove all joints already implemented.
  31230. */
  31231. forceUpdate(): void;
  31232. /**
  31233. * Gets the body that holds this impostor. Either its own, or its parent.
  31234. */
  31235. /**
  31236. * Set the physics body. Used mainly by the physics engine/plugin
  31237. */
  31238. physicsBody: any;
  31239. /**
  31240. * Get the parent of the physics imposter
  31241. * @returns Physics imposter or null
  31242. */
  31243. /**
  31244. * Sets the parent of the physics imposter
  31245. */
  31246. parent: Nullable<PhysicsImpostor>;
  31247. /**
  31248. * Resets the update flags
  31249. */
  31250. resetUpdateFlags(): void;
  31251. /**
  31252. * Gets the object extend size
  31253. * @returns the object extend size
  31254. */
  31255. getObjectExtendSize(): Vector3;
  31256. /**
  31257. * Gets the object center
  31258. * @returns The object center
  31259. */
  31260. getObjectCenter(): Vector3;
  31261. /**
  31262. * Get a specific parametes from the options parameter
  31263. * @param paramName The object parameter name
  31264. * @returns The object parameter
  31265. */
  31266. getParam(paramName: string): any;
  31267. /**
  31268. * Sets a specific parameter in the options given to the physics plugin
  31269. * @param paramName The parameter name
  31270. * @param value The value of the parameter
  31271. */
  31272. setParam(paramName: string, value: number): void;
  31273. /**
  31274. * Specifically change the body's mass option. Won't recreate the physics body object
  31275. * @param mass The mass of the physics imposter
  31276. */
  31277. setMass(mass: number): void;
  31278. /**
  31279. * Gets the linear velocity
  31280. * @returns linear velocity or null
  31281. */
  31282. getLinearVelocity(): Nullable<Vector3>;
  31283. /**
  31284. * Sets the linear velocity
  31285. * @param velocity linear velocity or null
  31286. */
  31287. setLinearVelocity(velocity: Nullable<Vector3>): void;
  31288. /**
  31289. * Gets the angular velocity
  31290. * @returns angular velocity or null
  31291. */
  31292. getAngularVelocity(): Nullable<Vector3>;
  31293. /**
  31294. * Sets the angular velocity
  31295. * @param velocity The velocity or null
  31296. */
  31297. setAngularVelocity(velocity: Nullable<Vector3>): void;
  31298. /**
  31299. * Execute a function with the physics plugin native code
  31300. * Provide a function the will have two variables - the world object and the physics body object
  31301. * @param func The function to execute with the physics plugin native code
  31302. */
  31303. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  31304. /**
  31305. * Register a function that will be executed before the physics world is stepping forward
  31306. * @param func The function to execute before the physics world is stepped forward
  31307. */
  31308. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  31309. /**
  31310. * Unregister a function that will be executed before the physics world is stepping forward
  31311. * @param func The function to execute before the physics world is stepped forward
  31312. */
  31313. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  31314. /**
  31315. * Register a function that will be executed after the physics step
  31316. * @param func The function to execute after physics step
  31317. */
  31318. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  31319. /**
  31320. * Unregisters a function that will be executed after the physics step
  31321. * @param func The function to execute after physics step
  31322. */
  31323. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  31324. /**
  31325. * register a function that will be executed when this impostor collides against a different body
  31326. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  31327. * @param func Callback that is executed on collision
  31328. */
  31329. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  31330. /**
  31331. * Unregisters the physics imposter on contact
  31332. * @param collideAgainst The physics object to collide against
  31333. * @param func Callback to execute on collision
  31334. */
  31335. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  31336. private _tmpQuat;
  31337. private _tmpQuat2;
  31338. /**
  31339. * Get the parent rotation
  31340. * @returns The parent rotation
  31341. */
  31342. getParentsRotation(): Quaternion;
  31343. /**
  31344. * this function is executed by the physics engine.
  31345. */
  31346. beforeStep: () => void;
  31347. /**
  31348. * this function is executed by the physics engine
  31349. */
  31350. afterStep: () => void;
  31351. /**
  31352. * Legacy collision detection event support
  31353. */
  31354. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  31355. /**
  31356. * event and body object due to cannon's event-based architecture.
  31357. */
  31358. onCollide: (e: {
  31359. body: any;
  31360. }) => void;
  31361. /**
  31362. * Apply a force
  31363. * @param force The force to apply
  31364. * @param contactPoint The contact point for the force
  31365. * @returns The physics imposter
  31366. */
  31367. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  31368. /**
  31369. * Apply an impulse
  31370. * @param force The impulse force
  31371. * @param contactPoint The contact point for the impulse force
  31372. * @returns The physics imposter
  31373. */
  31374. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  31375. /**
  31376. * A help function to create a joint
  31377. * @param otherImpostor A physics imposter used to create a joint
  31378. * @param jointType The type of joint
  31379. * @param jointData The data for the joint
  31380. * @returns The physics imposter
  31381. */
  31382. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  31383. /**
  31384. * Add a joint to this impostor with a different impostor
  31385. * @param otherImpostor A physics imposter used to add a joint
  31386. * @param joint The joint to add
  31387. * @returns The physics imposter
  31388. */
  31389. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  31390. /**
  31391. * Will keep this body still, in a sleep mode.
  31392. * @returns the physics imposter
  31393. */
  31394. sleep(): PhysicsImpostor;
  31395. /**
  31396. * Wake the body up.
  31397. * @returns The physics imposter
  31398. */
  31399. wakeUp(): PhysicsImpostor;
  31400. /**
  31401. * Clones the physics imposter
  31402. * @param newObject The physics imposter clones to this physics-enabled object
  31403. * @returns A nullable physics imposter
  31404. */
  31405. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  31406. /**
  31407. * Disposes the physics imposter
  31408. */
  31409. dispose(): void;
  31410. /**
  31411. * Sets the delta position
  31412. * @param position The delta position amount
  31413. */
  31414. setDeltaPosition(position: Vector3): void;
  31415. /**
  31416. * Sets the delta rotation
  31417. * @param rotation The delta rotation amount
  31418. */
  31419. setDeltaRotation(rotation: Quaternion): void;
  31420. /**
  31421. * Gets the box size of the physics imposter and stores the result in the input parameter
  31422. * @param result Stores the box size
  31423. * @returns The physics imposter
  31424. */
  31425. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  31426. /**
  31427. * Gets the radius of the physics imposter
  31428. * @returns Radius of the physics imposter
  31429. */
  31430. getRadius(): number;
  31431. /**
  31432. * Sync a bone with this impostor
  31433. * @param bone The bone to sync to the impostor.
  31434. * @param boneMesh The mesh that the bone is influencing.
  31435. * @param jointPivot The pivot of the joint / bone in local space.
  31436. * @param distToJoint Optional distance from the impostor to the joint.
  31437. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  31438. */
  31439. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  31440. /**
  31441. * Sync impostor to a bone
  31442. * @param bone The bone that the impostor will be synced to.
  31443. * @param boneMesh The mesh that the bone is influencing.
  31444. * @param jointPivot The pivot of the joint / bone in local space.
  31445. * @param distToJoint Optional distance from the impostor to the joint.
  31446. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  31447. * @param boneAxis Optional vector3 axis the bone is aligned with
  31448. */
  31449. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  31450. /**
  31451. * No-Imposter type
  31452. */
  31453. static NoImpostor: number;
  31454. /**
  31455. * Sphere-Imposter type
  31456. */
  31457. static SphereImpostor: number;
  31458. /**
  31459. * Box-Imposter type
  31460. */
  31461. static BoxImpostor: number;
  31462. /**
  31463. * Plane-Imposter type
  31464. */
  31465. static PlaneImpostor: number;
  31466. /**
  31467. * Mesh-imposter type
  31468. */
  31469. static MeshImpostor: number;
  31470. /**
  31471. * Cylinder-Imposter type
  31472. */
  31473. static CylinderImpostor: number;
  31474. /**
  31475. * Particle-Imposter type
  31476. */
  31477. static ParticleImpostor: number;
  31478. /**
  31479. * Heightmap-Imposter type
  31480. */
  31481. static HeightmapImpostor: number;
  31482. }
  31483. }
  31484. declare module BABYLON {
  31485. /**
  31486. * Interface for Physics-Joint data
  31487. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31488. */
  31489. interface PhysicsJointData {
  31490. /**
  31491. * The main pivot of the joint
  31492. */
  31493. mainPivot?: Vector3;
  31494. /**
  31495. * The connected pivot of the joint
  31496. */
  31497. connectedPivot?: Vector3;
  31498. /**
  31499. * The main axis of the joint
  31500. */
  31501. mainAxis?: Vector3;
  31502. /**
  31503. * The connected axis of the joint
  31504. */
  31505. connectedAxis?: Vector3;
  31506. /**
  31507. * The collision of the joint
  31508. */
  31509. collision?: boolean;
  31510. /**
  31511. * Native Oimo/Cannon/Energy data
  31512. */
  31513. nativeParams?: any;
  31514. }
  31515. /**
  31516. * This is a holder class for the physics joint created by the physics plugin
  31517. * It holds a set of functions to control the underlying joint
  31518. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31519. */
  31520. class PhysicsJoint {
  31521. /**
  31522. * The type of the physics joint
  31523. */
  31524. type: number;
  31525. /**
  31526. * The data for the physics joint
  31527. */
  31528. jointData: PhysicsJointData;
  31529. private _physicsJoint;
  31530. protected _physicsPlugin: IPhysicsEnginePlugin;
  31531. /**
  31532. * Initializes the physics joint
  31533. * @param type The type of the physics joint
  31534. * @param jointData The data for the physics joint
  31535. */
  31536. constructor(
  31537. /**
  31538. * The type of the physics joint
  31539. */
  31540. type: number,
  31541. /**
  31542. * The data for the physics joint
  31543. */
  31544. jointData: PhysicsJointData);
  31545. /**
  31546. * Gets the physics joint
  31547. */
  31548. /**
  31549. * Sets the physics joint
  31550. */
  31551. physicsJoint: any;
  31552. /**
  31553. * Sets the physics plugin
  31554. */
  31555. physicsPlugin: IPhysicsEnginePlugin;
  31556. /**
  31557. * Execute a function that is physics-plugin specific.
  31558. * @param {Function} func the function that will be executed.
  31559. * It accepts two parameters: the physics world and the physics joint
  31560. */
  31561. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  31562. /**
  31563. * Distance-Joint type
  31564. */
  31565. static DistanceJoint: number;
  31566. /**
  31567. * Hinge-Joint type
  31568. */
  31569. static HingeJoint: number;
  31570. /**
  31571. * Ball-and-Socket joint type
  31572. */
  31573. static BallAndSocketJoint: number;
  31574. /**
  31575. * Wheel-Joint type
  31576. */
  31577. static WheelJoint: number;
  31578. /**
  31579. * Slider-Joint type
  31580. */
  31581. static SliderJoint: number;
  31582. /**
  31583. * Prismatic-Joint type
  31584. */
  31585. static PrismaticJoint: number;
  31586. /**
  31587. * Universal-Joint type
  31588. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  31589. */
  31590. static UniversalJoint: number;
  31591. /**
  31592. * Hinge-Joint 2 type
  31593. */
  31594. static Hinge2Joint: number;
  31595. /**
  31596. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  31597. */
  31598. static PointToPointJoint: number;
  31599. /**
  31600. * Spring-Joint type
  31601. */
  31602. static SpringJoint: number;
  31603. /**
  31604. * Lock-Joint type
  31605. */
  31606. static LockJoint: number;
  31607. }
  31608. /**
  31609. * A class representing a physics distance joint
  31610. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31611. */
  31612. class DistanceJoint extends PhysicsJoint {
  31613. /**
  31614. *
  31615. * @param jointData The data for the Distance-Joint
  31616. */
  31617. constructor(jointData: DistanceJointData);
  31618. /**
  31619. * Update the predefined distance.
  31620. * @param maxDistance The maximum preferred distance
  31621. * @param minDistance The minimum preferred distance
  31622. */
  31623. updateDistance(maxDistance: number, minDistance?: number): void;
  31624. }
  31625. /**
  31626. * Represents a Motor-Enabled Joint
  31627. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31628. */
  31629. class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  31630. /**
  31631. * Initializes the Motor-Enabled Joint
  31632. * @param type The type of the joint
  31633. * @param jointData The physica joint data for the joint
  31634. */
  31635. constructor(type: number, jointData: PhysicsJointData);
  31636. /**
  31637. * Set the motor values.
  31638. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31639. * @param force the force to apply
  31640. * @param maxForce max force for this motor.
  31641. */
  31642. setMotor(force?: number, maxForce?: number): void;
  31643. /**
  31644. * Set the motor's limits.
  31645. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31646. * @param upperLimit The upper limit of the motor
  31647. * @param lowerLimit The lower limit of the motor
  31648. */
  31649. setLimit(upperLimit: number, lowerLimit?: number): void;
  31650. }
  31651. /**
  31652. * This class represents a single physics Hinge-Joint
  31653. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31654. */
  31655. class HingeJoint extends MotorEnabledJoint {
  31656. /**
  31657. * Initializes the Hinge-Joint
  31658. * @param jointData The joint data for the Hinge-Joint
  31659. */
  31660. constructor(jointData: PhysicsJointData);
  31661. /**
  31662. * Set the motor values.
  31663. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31664. * @param {number} force the force to apply
  31665. * @param {number} maxForce max force for this motor.
  31666. */
  31667. setMotor(force?: number, maxForce?: number): void;
  31668. /**
  31669. * Set the motor's limits.
  31670. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31671. * @param upperLimit The upper limit of the motor
  31672. * @param lowerLimit The lower limit of the motor
  31673. */
  31674. setLimit(upperLimit: number, lowerLimit?: number): void;
  31675. }
  31676. /**
  31677. * This class represents a dual hinge physics joint (same as wheel joint)
  31678. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31679. */
  31680. class Hinge2Joint extends MotorEnabledJoint {
  31681. /**
  31682. * Initializes the Hinge2-Joint
  31683. * @param jointData The joint data for the Hinge2-Joint
  31684. */
  31685. constructor(jointData: PhysicsJointData);
  31686. /**
  31687. * Set the motor values.
  31688. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31689. * @param {number} force the force to apply
  31690. * @param {number} maxForce max force for this motor.
  31691. * @param {motorIndex} the motor's index, 0 or 1.
  31692. */
  31693. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  31694. /**
  31695. * Set the motor limits.
  31696. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31697. * @param {number} upperLimit the upper limit
  31698. * @param {number} lowerLimit lower limit
  31699. * @param {motorIndex} the motor's index, 0 or 1.
  31700. */
  31701. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  31702. }
  31703. /**
  31704. * Interface for a motor enabled joint
  31705. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31706. */
  31707. interface IMotorEnabledJoint {
  31708. /**
  31709. * Physics joint
  31710. */
  31711. physicsJoint: any;
  31712. /**
  31713. * Sets the motor of the motor-enabled joint
  31714. * @param force The force of the motor
  31715. * @param maxForce The maximum force of the motor
  31716. * @param motorIndex The index of the motor
  31717. */
  31718. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  31719. /**
  31720. * Sets the limit of the motor
  31721. * @param upperLimit The upper limit of the motor
  31722. * @param lowerLimit The lower limit of the motor
  31723. * @param motorIndex The index of the motor
  31724. */
  31725. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  31726. }
  31727. /**
  31728. * Joint data for a Distance-Joint
  31729. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31730. */
  31731. interface DistanceJointData extends PhysicsJointData {
  31732. /**
  31733. * Max distance the 2 joint objects can be apart
  31734. */
  31735. maxDistance: number;
  31736. }
  31737. /**
  31738. * Joint data from a spring joint
  31739. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31740. */
  31741. interface SpringJointData extends PhysicsJointData {
  31742. /**
  31743. * Length of the spring
  31744. */
  31745. length: number;
  31746. /**
  31747. * Stiffness of the spring
  31748. */
  31749. stiffness: number;
  31750. /**
  31751. * Damping of the spring
  31752. */
  31753. damping: number;
  31754. /** this callback will be called when applying the force to the impostors. */
  31755. forceApplicationCallback: () => void;
  31756. }
  31757. }
  31758. declare module BABYLON {
  31759. /**
  31760. * This represents the base class for particle system in Babylon.
  31761. * 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.
  31762. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  31763. * @example https://doc.babylonjs.com/babylon101/particles
  31764. */
  31765. class BaseParticleSystem {
  31766. /**
  31767. * Source color is added to the destination color without alpha affecting the result
  31768. */
  31769. static BLENDMODE_ONEONE: number;
  31770. /**
  31771. * Blend current color and particle color using particle’s alpha
  31772. */
  31773. static BLENDMODE_STANDARD: number;
  31774. /**
  31775. * Add current color and particle color multiplied by particle’s alpha
  31776. */
  31777. static BLENDMODE_ADD: number;
  31778. /**
  31779. * Multiply current color with particle color
  31780. */
  31781. static BLENDMODE_MULTIPLY: number;
  31782. /**
  31783. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  31784. */
  31785. static BLENDMODE_MULTIPLYADD: number;
  31786. /**
  31787. * List of animations used by the particle system.
  31788. */
  31789. animations: Animation[];
  31790. /**
  31791. * The id of the Particle system.
  31792. */
  31793. id: string;
  31794. /**
  31795. * The friendly name of the Particle system.
  31796. */
  31797. name: string;
  31798. /**
  31799. * The rendering group used by the Particle system to chose when to render.
  31800. */
  31801. renderingGroupId: number;
  31802. /**
  31803. * The emitter represents the Mesh or position we are attaching the particle system to.
  31804. */
  31805. emitter: Nullable<AbstractMesh | Vector3>;
  31806. /**
  31807. * The maximum number of particles to emit per frame
  31808. */
  31809. emitRate: number;
  31810. /**
  31811. * If you want to launch only a few particles at once, that can be done, as well.
  31812. */
  31813. manualEmitCount: number;
  31814. /**
  31815. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  31816. */
  31817. updateSpeed: number;
  31818. /**
  31819. * The amount of time the particle system is running (depends of the overall update speed).
  31820. */
  31821. targetStopDuration: number;
  31822. /**
  31823. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  31824. */
  31825. disposeOnStop: boolean;
  31826. /**
  31827. * Minimum power of emitting particles.
  31828. */
  31829. minEmitPower: number;
  31830. /**
  31831. * Maximum power of emitting particles.
  31832. */
  31833. maxEmitPower: number;
  31834. /**
  31835. * Minimum life time of emitting particles.
  31836. */
  31837. minLifeTime: number;
  31838. /**
  31839. * Maximum life time of emitting particles.
  31840. */
  31841. maxLifeTime: number;
  31842. /**
  31843. * Minimum Size of emitting particles.
  31844. */
  31845. minSize: number;
  31846. /**
  31847. * Maximum Size of emitting particles.
  31848. */
  31849. maxSize: number;
  31850. /**
  31851. * Minimum scale of emitting particles on X axis.
  31852. */
  31853. minScaleX: number;
  31854. /**
  31855. * Maximum scale of emitting particles on X axis.
  31856. */
  31857. maxScaleX: number;
  31858. /**
  31859. * Minimum scale of emitting particles on Y axis.
  31860. */
  31861. minScaleY: number;
  31862. /**
  31863. * Maximum scale of emitting particles on Y axis.
  31864. */
  31865. maxScaleY: number;
  31866. /**
  31867. * Gets or sets the minimal initial rotation in radians.
  31868. */
  31869. minInitialRotation: number;
  31870. /**
  31871. * Gets or sets the maximal initial rotation in radians.
  31872. */
  31873. maxInitialRotation: number;
  31874. /**
  31875. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  31876. */
  31877. minAngularSpeed: number;
  31878. /**
  31879. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  31880. */
  31881. maxAngularSpeed: number;
  31882. /**
  31883. * The texture used to render each particle. (this can be a spritesheet)
  31884. */
  31885. particleTexture: Nullable<Texture>;
  31886. /**
  31887. * The layer mask we are rendering the particles through.
  31888. */
  31889. layerMask: number;
  31890. /**
  31891. * This can help using your own shader to render the particle system.
  31892. * The according effect will be created
  31893. */
  31894. customShader: any;
  31895. /**
  31896. * By default particle system starts as soon as they are created. This prevents the
  31897. * automatic start to happen and let you decide when to start emitting particles.
  31898. */
  31899. preventAutoStart: boolean;
  31900. private _noiseTexture;
  31901. /**
  31902. * Gets or sets a texture used to add random noise to particle positions
  31903. */
  31904. noiseTexture: Nullable<ProceduralTexture>;
  31905. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  31906. noiseStrength: Vector3;
  31907. /**
  31908. * Callback triggered when the particle animation is ending.
  31909. */
  31910. onAnimationEnd: Nullable<() => void>;
  31911. /**
  31912. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  31913. */
  31914. blendMode: number;
  31915. /**
  31916. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  31917. * to override the particles.
  31918. */
  31919. forceDepthWrite: boolean;
  31920. /** 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 */
  31921. preWarmCycles: number;
  31922. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  31923. preWarmStepOffset: number;
  31924. /**
  31925. * 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)
  31926. */
  31927. spriteCellChangeSpeed: number;
  31928. /**
  31929. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  31930. */
  31931. startSpriteCellID: number;
  31932. /**
  31933. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  31934. */
  31935. endSpriteCellID: number;
  31936. /**
  31937. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  31938. */
  31939. spriteCellWidth: number;
  31940. /**
  31941. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  31942. */
  31943. spriteCellHeight: number;
  31944. /**
  31945. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  31946. */
  31947. spriteRandomStartCell: boolean;
  31948. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  31949. translationPivot: Vector2;
  31950. /** @hidden */
  31951. protected _isAnimationSheetEnabled: boolean;
  31952. /**
  31953. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  31954. */
  31955. beginAnimationOnStart: boolean;
  31956. /**
  31957. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  31958. */
  31959. beginAnimationFrom: number;
  31960. /**
  31961. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  31962. */
  31963. beginAnimationTo: number;
  31964. /**
  31965. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  31966. */
  31967. beginAnimationLoop: boolean;
  31968. /**
  31969. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  31970. */
  31971. isAnimationSheetEnabled: boolean;
  31972. /**
  31973. * Get hosting scene
  31974. * @returns the scene
  31975. */
  31976. getScene(): Scene;
  31977. /**
  31978. * You can use gravity if you want to give an orientation to your particles.
  31979. */
  31980. gravity: Vector3;
  31981. protected _colorGradients: Nullable<Array<ColorGradient>>;
  31982. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  31983. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  31984. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  31985. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  31986. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  31987. protected _dragGradients: Nullable<Array<FactorGradient>>;
  31988. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  31989. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  31990. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  31991. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  31992. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  31993. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  31994. /**
  31995. * Defines the delay in milliseconds before starting the system (0 by default)
  31996. */
  31997. startDelay: number;
  31998. /**
  31999. * Gets the current list of drag gradients.
  32000. * You must use addDragGradient and removeDragGradient to udpate this list
  32001. * @returns the list of drag gradients
  32002. */
  32003. getDragGradients(): Nullable<Array<FactorGradient>>;
  32004. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  32005. limitVelocityDamping: number;
  32006. /**
  32007. * Gets the current list of limit velocity gradients.
  32008. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  32009. * @returns the list of limit velocity gradients
  32010. */
  32011. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  32012. /**
  32013. * Gets the current list of color gradients.
  32014. * You must use addColorGradient and removeColorGradient to udpate this list
  32015. * @returns the list of color gradients
  32016. */
  32017. getColorGradients(): Nullable<Array<ColorGradient>>;
  32018. /**
  32019. * Gets the current list of size gradients.
  32020. * You must use addSizeGradient and removeSizeGradient to udpate this list
  32021. * @returns the list of size gradients
  32022. */
  32023. getSizeGradients(): Nullable<Array<FactorGradient>>;
  32024. /**
  32025. * Gets the current list of color remap gradients.
  32026. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  32027. * @returns the list of color remap gradients
  32028. */
  32029. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  32030. /**
  32031. * Gets the current list of alpha remap gradients.
  32032. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  32033. * @returns the list of alpha remap gradients
  32034. */
  32035. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  32036. /**
  32037. * Gets the current list of life time gradients.
  32038. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  32039. * @returns the list of life time gradients
  32040. */
  32041. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  32042. /**
  32043. * Gets the current list of angular speed gradients.
  32044. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  32045. * @returns the list of angular speed gradients
  32046. */
  32047. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  32048. /**
  32049. * Gets the current list of velocity gradients.
  32050. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  32051. * @returns the list of velocity gradients
  32052. */
  32053. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  32054. /**
  32055. * Gets the current list of start size gradients.
  32056. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  32057. * @returns the list of start size gradients
  32058. */
  32059. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  32060. /**
  32061. * Gets the current list of emit rate gradients.
  32062. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  32063. * @returns the list of emit rate gradients
  32064. */
  32065. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  32066. /**
  32067. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  32068. * This only works when particleEmitterTyps is a BoxParticleEmitter
  32069. */
  32070. direction1: Vector3;
  32071. /**
  32072. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  32073. * This only works when particleEmitterTyps is a BoxParticleEmitter
  32074. */
  32075. direction2: Vector3;
  32076. /**
  32077. * 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.
  32078. * This only works when particleEmitterTyps is a BoxParticleEmitter
  32079. */
  32080. minEmitBox: Vector3;
  32081. /**
  32082. * 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.
  32083. * This only works when particleEmitterTyps is a BoxParticleEmitter
  32084. */
  32085. maxEmitBox: Vector3;
  32086. /**
  32087. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  32088. */
  32089. color1: Color4;
  32090. /**
  32091. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  32092. */
  32093. color2: Color4;
  32094. /**
  32095. * Color the particle will have at the end of its lifetime
  32096. */
  32097. colorDead: Color4;
  32098. /**
  32099. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  32100. */
  32101. textureMask: Color4;
  32102. /**
  32103. * The particle emitter type defines the emitter used by the particle system.
  32104. * It can be for example box, sphere, or cone...
  32105. */
  32106. particleEmitterType: IParticleEmitterType;
  32107. /** @hidden */
  32108. _isSubEmitter: boolean;
  32109. /**
  32110. * Gets or sets the billboard mode to use when isBillboardBased = true.
  32111. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  32112. */
  32113. billboardMode: number;
  32114. protected _isBillboardBased: boolean;
  32115. /**
  32116. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  32117. */
  32118. isBillboardBased: boolean;
  32119. /**
  32120. * The scene the particle system belongs to.
  32121. */
  32122. protected _scene: Scene;
  32123. /**
  32124. * Local cache of defines for image processing.
  32125. */
  32126. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  32127. /**
  32128. * Default configuration related to image processing available in the standard Material.
  32129. */
  32130. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32131. /**
  32132. * Gets the image processing configuration used either in this material.
  32133. */
  32134. /**
  32135. * Sets the Default image processing configuration used either in the this material.
  32136. *
  32137. * If sets to null, the scene one is in use.
  32138. */
  32139. imageProcessingConfiguration: ImageProcessingConfiguration;
  32140. /**
  32141. * Attaches a new image processing configuration to the Standard Material.
  32142. * @param configuration
  32143. */
  32144. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  32145. /** @hidden */
  32146. protected _reset(): void;
  32147. /** @hidden */
  32148. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  32149. /**
  32150. * Instantiates a particle system.
  32151. * 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.
  32152. * @param name The name of the particle system
  32153. */
  32154. constructor(name: string);
  32155. /**
  32156. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  32157. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  32158. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  32159. * @returns the emitter
  32160. */
  32161. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  32162. /**
  32163. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  32164. * @param radius The radius of the hemisphere to emit from
  32165. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  32166. * @returns the emitter
  32167. */
  32168. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  32169. /**
  32170. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  32171. * @param radius The radius of the sphere to emit from
  32172. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  32173. * @returns the emitter
  32174. */
  32175. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  32176. /**
  32177. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  32178. * @param radius The radius of the sphere to emit from
  32179. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  32180. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  32181. * @returns the emitter
  32182. */
  32183. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  32184. /**
  32185. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  32186. * @param radius The radius of the emission cylinder
  32187. * @param height The height of the emission cylinder
  32188. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  32189. * @param directionRandomizer How much to randomize the particle direction [0-1]
  32190. * @returns the emitter
  32191. */
  32192. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  32193. /**
  32194. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  32195. * @param radius The radius of the cylinder to emit from
  32196. * @param height The height of the emission cylinder
  32197. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  32198. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  32199. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  32200. * @returns the emitter
  32201. */
  32202. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  32203. /**
  32204. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  32205. * @param radius The radius of the cone to emit from
  32206. * @param angle The base angle of the cone
  32207. * @returns the emitter
  32208. */
  32209. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  32210. /**
  32211. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  32212. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  32213. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  32214. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  32215. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  32216. * @returns the emitter
  32217. */
  32218. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  32219. }
  32220. }
  32221. declare module BABYLON {
  32222. /**
  32223. * This represents a GPU particle system in Babylon
  32224. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  32225. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  32226. */
  32227. class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  32228. /**
  32229. * The layer mask we are rendering the particles through.
  32230. */
  32231. layerMask: number;
  32232. private _capacity;
  32233. private _activeCount;
  32234. private _currentActiveCount;
  32235. private _accumulatedCount;
  32236. private _renderEffect;
  32237. private _updateEffect;
  32238. private _buffer0;
  32239. private _buffer1;
  32240. private _spriteBuffer;
  32241. private _updateVAO;
  32242. private _renderVAO;
  32243. private _targetIndex;
  32244. private _sourceBuffer;
  32245. private _targetBuffer;
  32246. private _engine;
  32247. private _currentRenderId;
  32248. private _started;
  32249. private _stopped;
  32250. private _timeDelta;
  32251. private _randomTexture;
  32252. private _randomTexture2;
  32253. private _attributesStrideSize;
  32254. private _updateEffectOptions;
  32255. private _randomTextureSize;
  32256. private _actualFrame;
  32257. private readonly _rawTextureWidth;
  32258. /**
  32259. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  32260. */
  32261. static readonly IsSupported: boolean;
  32262. /**
  32263. * An event triggered when the system is disposed.
  32264. */
  32265. onDisposeObservable: Observable<GPUParticleSystem>;
  32266. /**
  32267. * Gets the maximum number of particles active at the same time.
  32268. * @returns The max number of active particles.
  32269. */
  32270. getCapacity(): number;
  32271. /**
  32272. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  32273. * to override the particles.
  32274. */
  32275. forceDepthWrite: boolean;
  32276. /**
  32277. * Gets or set the number of active particles
  32278. */
  32279. activeParticleCount: number;
  32280. private _preWarmDone;
  32281. /**
  32282. * Is this system ready to be used/rendered
  32283. * @return true if the system is ready
  32284. */
  32285. isReady(): boolean;
  32286. /**
  32287. * Gets if the system has been started. (Note: this will still be true after stop is called)
  32288. * @returns True if it has been started, otherwise false.
  32289. */
  32290. isStarted(): boolean;
  32291. /**
  32292. * Starts the particle system and begins to emit
  32293. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  32294. */
  32295. start(delay?: number): void;
  32296. /**
  32297. * Stops the particle system.
  32298. */
  32299. stop(): void;
  32300. /**
  32301. * Remove all active particles
  32302. */
  32303. reset(): void;
  32304. /**
  32305. * Returns the string "GPUParticleSystem"
  32306. * @returns a string containing the class name
  32307. */
  32308. getClassName(): string;
  32309. private _colorGradientsTexture;
  32310. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  32311. /**
  32312. * Adds a new color gradient
  32313. * @param gradient defines the gradient to use (between 0 and 1)
  32314. * @param color1 defines the color to affect to the specified gradient
  32315. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  32316. * @returns the current particle system
  32317. */
  32318. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  32319. /**
  32320. * Remove a specific color gradient
  32321. * @param gradient defines the gradient to remove
  32322. * @returns the current particle system
  32323. */
  32324. removeColorGradient(gradient: number): GPUParticleSystem;
  32325. private _angularSpeedGradientsTexture;
  32326. private _sizeGradientsTexture;
  32327. private _velocityGradientsTexture;
  32328. private _limitVelocityGradientsTexture;
  32329. private _dragGradientsTexture;
  32330. private _addFactorGradient;
  32331. /**
  32332. * Adds a new size gradient
  32333. * @param gradient defines the gradient to use (between 0 and 1)
  32334. * @param factor defines the size factor to affect to the specified gradient
  32335. * @returns the current particle system
  32336. */
  32337. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  32338. /**
  32339. * Remove a specific size gradient
  32340. * @param gradient defines the gradient to remove
  32341. * @returns the current particle system
  32342. */
  32343. removeSizeGradient(gradient: number): GPUParticleSystem;
  32344. /**
  32345. * Adds a new angular speed gradient
  32346. * @param gradient defines the gradient to use (between 0 and 1)
  32347. * @param factor defines the angular speed to affect to the specified gradient
  32348. * @returns the current particle system
  32349. */
  32350. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  32351. /**
  32352. * Remove a specific angular speed gradient
  32353. * @param gradient defines the gradient to remove
  32354. * @returns the current particle system
  32355. */
  32356. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  32357. /**
  32358. * Adds a new velocity gradient
  32359. * @param gradient defines the gradient to use (between 0 and 1)
  32360. * @param factor defines the velocity to affect to the specified gradient
  32361. * @returns the current particle system
  32362. */
  32363. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  32364. /**
  32365. * Remove a specific velocity gradient
  32366. * @param gradient defines the gradient to remove
  32367. * @returns the current particle system
  32368. */
  32369. removeVelocityGradient(gradient: number): GPUParticleSystem;
  32370. /**
  32371. * Adds a new limit velocity gradient
  32372. * @param gradient defines the gradient to use (between 0 and 1)
  32373. * @param factor defines the limit velocity value to affect to the specified gradient
  32374. * @returns the current particle system
  32375. */
  32376. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  32377. /**
  32378. * Remove a specific limit velocity gradient
  32379. * @param gradient defines the gradient to remove
  32380. * @returns the current particle system
  32381. */
  32382. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  32383. /**
  32384. * Adds a new drag gradient
  32385. * @param gradient defines the gradient to use (between 0 and 1)
  32386. * @param factor defines the drag value to affect to the specified gradient
  32387. * @returns the current particle system
  32388. */
  32389. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  32390. /**
  32391. * Remove a specific drag gradient
  32392. * @param gradient defines the gradient to remove
  32393. * @returns the current particle system
  32394. */
  32395. removeDragGradient(gradient: number): GPUParticleSystem;
  32396. /**
  32397. * Not supported by GPUParticleSystem
  32398. * @param gradient defines the gradient to use (between 0 and 1)
  32399. * @param factor defines the emit rate value to affect to the specified gradient
  32400. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32401. * @returns the current particle system
  32402. */
  32403. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32404. /**
  32405. * Not supported by GPUParticleSystem
  32406. * @param gradient defines the gradient to remove
  32407. * @returns the current particle system
  32408. */
  32409. removeEmitRateGradient(gradient: number): IParticleSystem;
  32410. /**
  32411. * Not supported by GPUParticleSystem
  32412. * @param gradient defines the gradient to use (between 0 and 1)
  32413. * @param factor defines the start size value to affect to the specified gradient
  32414. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32415. * @returns the current particle system
  32416. */
  32417. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32418. /**
  32419. * Not supported by GPUParticleSystem
  32420. * @param gradient defines the gradient to remove
  32421. * @returns the current particle system
  32422. */
  32423. removeStartSizeGradient(gradient: number): IParticleSystem;
  32424. /**
  32425. * Not supported by GPUParticleSystem
  32426. * @param gradient defines the gradient to use (between 0 and 1)
  32427. * @param min defines the color remap minimal range
  32428. * @param max defines the color remap maximal range
  32429. * @returns the current particle system
  32430. */
  32431. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  32432. /**
  32433. * Not supported by GPUParticleSystem
  32434. * @param gradient defines the gradient to remove
  32435. * @returns the current particle system
  32436. */
  32437. removeColorRemapGradient(gradient: number): IParticleSystem;
  32438. /**
  32439. * Not supported by GPUParticleSystem
  32440. * @param gradient defines the gradient to use (between 0 and 1)
  32441. * @param min defines the alpha remap minimal range
  32442. * @param max defines the alpha remap maximal range
  32443. * @returns the current particle system
  32444. */
  32445. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  32446. /**
  32447. * Not supported by GPUParticleSystem
  32448. * @param gradient defines the gradient to remove
  32449. * @returns the current particle system
  32450. */
  32451. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  32452. /**
  32453. * Not supported by GPUParticleSystem
  32454. * @param gradient defines the gradient to use (between 0 and 1)
  32455. * @param color defines the color to affect to the specified gradient
  32456. * @returns the current particle system
  32457. */
  32458. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  32459. /**
  32460. * Not supported by GPUParticleSystem
  32461. * @param gradient defines the gradient to remove
  32462. * @returns the current particle system
  32463. */
  32464. removeRampGradient(gradient: number): IParticleSystem;
  32465. /**
  32466. * Not supported by GPUParticleSystem
  32467. * @returns the list of ramp gradients
  32468. */
  32469. getRampGradients(): Nullable<Array<Color3Gradient>>;
  32470. /**
  32471. * Not supported by GPUParticleSystem
  32472. * Gets or sets a boolean indicating that ramp gradients must be used
  32473. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  32474. */
  32475. useRampGradients: boolean;
  32476. /**
  32477. * Not supported by GPUParticleSystem
  32478. * @param gradient defines the gradient to use (between 0 and 1)
  32479. * @param factor defines the life time factor to affect to the specified gradient
  32480. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32481. * @returns the current particle system
  32482. */
  32483. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32484. /**
  32485. * Not supported by GPUParticleSystem
  32486. * @param gradient defines the gradient to remove
  32487. * @returns the current particle system
  32488. */
  32489. removeLifeTimeGradient(gradient: number): IParticleSystem;
  32490. /**
  32491. * Instantiates a GPU particle system.
  32492. * 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.
  32493. * @param name The name of the particle system
  32494. * @param options The options used to create the system
  32495. * @param scene The scene the particle system belongs to
  32496. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  32497. */
  32498. constructor(name: string, options: Partial<{
  32499. capacity: number;
  32500. randomTextureSize: number;
  32501. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  32502. protected _reset(): void;
  32503. private _createUpdateVAO;
  32504. private _createRenderVAO;
  32505. private _initialize;
  32506. /** @hidden */
  32507. _recreateUpdateEffect(): void;
  32508. /** @hidden */
  32509. _recreateRenderEffect(): void;
  32510. /**
  32511. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  32512. * @param preWarm defines if we are in the pre-warmimg phase
  32513. */
  32514. animate(preWarm?: boolean): void;
  32515. private _createFactorGradientTexture;
  32516. private _createSizeGradientTexture;
  32517. private _createAngularSpeedGradientTexture;
  32518. private _createVelocityGradientTexture;
  32519. private _createLimitVelocityGradientTexture;
  32520. private _createDragGradientTexture;
  32521. private _createColorGradientTexture;
  32522. /**
  32523. * Renders the particle system in its current state
  32524. * @param preWarm defines if the system should only update the particles but not render them
  32525. * @returns the current number of particles
  32526. */
  32527. render(preWarm?: boolean): number;
  32528. /**
  32529. * Rebuilds the particle system
  32530. */
  32531. rebuild(): void;
  32532. private _releaseBuffers;
  32533. private _releaseVAOs;
  32534. /**
  32535. * Disposes the particle system and free the associated resources
  32536. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  32537. */
  32538. dispose(disposeTexture?: boolean): void;
  32539. /**
  32540. * Clones the particle system.
  32541. * @param name The name of the cloned object
  32542. * @param newEmitter The new emitter to use
  32543. * @returns the cloned particle system
  32544. */
  32545. clone(name: string, newEmitter: any): GPUParticleSystem;
  32546. /**
  32547. * Serializes the particle system to a JSON object.
  32548. * @returns the JSON object
  32549. */
  32550. serialize(): any;
  32551. /**
  32552. * Parses a JSON object to create a GPU particle system.
  32553. * @param parsedParticleSystem The JSON object to parse
  32554. * @param scene The scene to create the particle system in
  32555. * @param rootUrl The root url to use to load external dependencies like texture
  32556. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  32557. * @returns the parsed GPU particle system
  32558. */
  32559. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  32560. }
  32561. }
  32562. declare module BABYLON {
  32563. /**
  32564. * Interface representing a particle system in Babylon.js.
  32565. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  32566. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  32567. */
  32568. interface IParticleSystem {
  32569. /**
  32570. * List of animations used by the particle system.
  32571. */
  32572. animations: Animation[];
  32573. /**
  32574. * The id of the Particle system.
  32575. */
  32576. id: string;
  32577. /**
  32578. * The name of the Particle system.
  32579. */
  32580. name: string;
  32581. /**
  32582. * The emitter represents the Mesh or position we are attaching the particle system to.
  32583. */
  32584. emitter: Nullable<AbstractMesh | Vector3>;
  32585. /**
  32586. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  32587. */
  32588. isBillboardBased: boolean;
  32589. /**
  32590. * The rendering group used by the Particle system to chose when to render.
  32591. */
  32592. renderingGroupId: number;
  32593. /**
  32594. * The layer mask we are rendering the particles through.
  32595. */
  32596. layerMask: number;
  32597. /**
  32598. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  32599. */
  32600. updateSpeed: number;
  32601. /**
  32602. * The amount of time the particle system is running (depends of the overall update speed).
  32603. */
  32604. targetStopDuration: number;
  32605. /**
  32606. * The texture used to render each particle. (this can be a spritesheet)
  32607. */
  32608. particleTexture: Nullable<Texture>;
  32609. /**
  32610. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  32611. */
  32612. blendMode: number;
  32613. /**
  32614. * Minimum life time of emitting particles.
  32615. */
  32616. minLifeTime: number;
  32617. /**
  32618. * Maximum life time of emitting particles.
  32619. */
  32620. maxLifeTime: number;
  32621. /**
  32622. * Minimum Size of emitting particles.
  32623. */
  32624. minSize: number;
  32625. /**
  32626. * Maximum Size of emitting particles.
  32627. */
  32628. maxSize: number;
  32629. /**
  32630. * Minimum scale of emitting particles on X axis.
  32631. */
  32632. minScaleX: number;
  32633. /**
  32634. * Maximum scale of emitting particles on X axis.
  32635. */
  32636. maxScaleX: number;
  32637. /**
  32638. * Minimum scale of emitting particles on Y axis.
  32639. */
  32640. minScaleY: number;
  32641. /**
  32642. * Maximum scale of emitting particles on Y axis.
  32643. */
  32644. maxScaleY: number;
  32645. /**
  32646. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  32647. */
  32648. color1: Color4;
  32649. /**
  32650. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  32651. */
  32652. color2: Color4;
  32653. /**
  32654. * Color the particle will have at the end of its lifetime.
  32655. */
  32656. colorDead: Color4;
  32657. /**
  32658. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  32659. */
  32660. emitRate: number;
  32661. /**
  32662. * You can use gravity if you want to give an orientation to your particles.
  32663. */
  32664. gravity: Vector3;
  32665. /**
  32666. * Minimum power of emitting particles.
  32667. */
  32668. minEmitPower: number;
  32669. /**
  32670. * Maximum power of emitting particles.
  32671. */
  32672. maxEmitPower: number;
  32673. /**
  32674. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  32675. */
  32676. minAngularSpeed: number;
  32677. /**
  32678. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  32679. */
  32680. maxAngularSpeed: number;
  32681. /**
  32682. * Gets or sets the minimal initial rotation in radians.
  32683. */
  32684. minInitialRotation: number;
  32685. /**
  32686. * Gets or sets the maximal initial rotation in radians.
  32687. */
  32688. maxInitialRotation: number;
  32689. /**
  32690. * The particle emitter type defines the emitter used by the particle system.
  32691. * It can be for example box, sphere, or cone...
  32692. */
  32693. particleEmitterType: Nullable<IParticleEmitterType>;
  32694. /**
  32695. * Defines the delay in milliseconds before starting the system (0 by default)
  32696. */
  32697. startDelay: number;
  32698. /**
  32699. * 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
  32700. */
  32701. preWarmCycles: number;
  32702. /**
  32703. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  32704. */
  32705. preWarmStepOffset: number;
  32706. /**
  32707. * 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)
  32708. */
  32709. spriteCellChangeSpeed: number;
  32710. /**
  32711. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  32712. */
  32713. startSpriteCellID: number;
  32714. /**
  32715. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  32716. */
  32717. endSpriteCellID: number;
  32718. /**
  32719. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  32720. */
  32721. spriteCellWidth: number;
  32722. /**
  32723. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  32724. */
  32725. spriteCellHeight: number;
  32726. /**
  32727. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  32728. */
  32729. spriteRandomStartCell: boolean;
  32730. /**
  32731. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  32732. */
  32733. isAnimationSheetEnabled: boolean;
  32734. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  32735. translationPivot: Vector2;
  32736. /**
  32737. * Gets or sets a texture used to add random noise to particle positions
  32738. */
  32739. noiseTexture: Nullable<BaseTexture>;
  32740. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  32741. noiseStrength: Vector3;
  32742. /**
  32743. * Gets or sets the billboard mode to use when isBillboardBased = true.
  32744. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  32745. */
  32746. billboardMode: number;
  32747. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  32748. limitVelocityDamping: number;
  32749. /**
  32750. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  32751. */
  32752. beginAnimationOnStart: boolean;
  32753. /**
  32754. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  32755. */
  32756. beginAnimationFrom: number;
  32757. /**
  32758. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  32759. */
  32760. beginAnimationTo: number;
  32761. /**
  32762. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  32763. */
  32764. beginAnimationLoop: boolean;
  32765. /**
  32766. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  32767. */
  32768. disposeOnStop: boolean;
  32769. /**
  32770. * Gets the maximum number of particles active at the same time.
  32771. * @returns The max number of active particles.
  32772. */
  32773. getCapacity(): number;
  32774. /**
  32775. * Gets if the system has been started. (Note: this will still be true after stop is called)
  32776. * @returns True if it has been started, otherwise false.
  32777. */
  32778. isStarted(): boolean;
  32779. /**
  32780. * Animates the particle system for this frame.
  32781. */
  32782. animate(): void;
  32783. /**
  32784. * Renders the particle system in its current state.
  32785. * @returns the current number of particles
  32786. */
  32787. render(): number;
  32788. /**
  32789. * Dispose the particle system and frees its associated resources.
  32790. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  32791. */
  32792. dispose(disposeTexture?: boolean): void;
  32793. /**
  32794. * Clones the particle system.
  32795. * @param name The name of the cloned object
  32796. * @param newEmitter The new emitter to use
  32797. * @returns the cloned particle system
  32798. */
  32799. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  32800. /**
  32801. * Serializes the particle system to a JSON object.
  32802. * @returns the JSON object
  32803. */
  32804. serialize(): any;
  32805. /**
  32806. * Rebuild the particle system
  32807. */
  32808. rebuild(): void;
  32809. /**
  32810. * Starts the particle system and begins to emit
  32811. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  32812. */
  32813. start(delay?: number): void;
  32814. /**
  32815. * Stops the particle system.
  32816. */
  32817. stop(): void;
  32818. /**
  32819. * Remove all active particles
  32820. */
  32821. reset(): void;
  32822. /**
  32823. * Is this system ready to be used/rendered
  32824. * @return true if the system is ready
  32825. */
  32826. isReady(): boolean;
  32827. /**
  32828. * Adds a new color gradient
  32829. * @param gradient defines the gradient to use (between 0 and 1)
  32830. * @param color1 defines the color to affect to the specified gradient
  32831. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  32832. * @returns the current particle system
  32833. */
  32834. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  32835. /**
  32836. * Remove a specific color gradient
  32837. * @param gradient defines the gradient to remove
  32838. * @returns the current particle system
  32839. */
  32840. removeColorGradient(gradient: number): IParticleSystem;
  32841. /**
  32842. * Adds a new size gradient
  32843. * @param gradient defines the gradient to use (between 0 and 1)
  32844. * @param factor defines the size factor to affect to the specified gradient
  32845. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32846. * @returns the current particle system
  32847. */
  32848. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32849. /**
  32850. * Remove a specific size gradient
  32851. * @param gradient defines the gradient to remove
  32852. * @returns the current particle system
  32853. */
  32854. removeSizeGradient(gradient: number): IParticleSystem;
  32855. /**
  32856. * Gets the current list of color gradients.
  32857. * You must use addColorGradient and removeColorGradient to udpate this list
  32858. * @returns the list of color gradients
  32859. */
  32860. getColorGradients(): Nullable<Array<ColorGradient>>;
  32861. /**
  32862. * Gets the current list of size gradients.
  32863. * You must use addSizeGradient and removeSizeGradient to udpate this list
  32864. * @returns the list of size gradients
  32865. */
  32866. getSizeGradients(): Nullable<Array<FactorGradient>>;
  32867. /**
  32868. * Gets the current list of angular speed gradients.
  32869. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  32870. * @returns the list of angular speed gradients
  32871. */
  32872. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  32873. /**
  32874. * Adds a new angular speed gradient
  32875. * @param gradient defines the gradient to use (between 0 and 1)
  32876. * @param factor defines the angular speed to affect to the specified gradient
  32877. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32878. * @returns the current particle system
  32879. */
  32880. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32881. /**
  32882. * Remove a specific angular speed gradient
  32883. * @param gradient defines the gradient to remove
  32884. * @returns the current particle system
  32885. */
  32886. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  32887. /**
  32888. * Gets the current list of velocity gradients.
  32889. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  32890. * @returns the list of velocity gradients
  32891. */
  32892. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  32893. /**
  32894. * Adds a new velocity gradient
  32895. * @param gradient defines the gradient to use (between 0 and 1)
  32896. * @param factor defines the velocity to affect to the specified gradient
  32897. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32898. * @returns the current particle system
  32899. */
  32900. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32901. /**
  32902. * Remove a specific velocity gradient
  32903. * @param gradient defines the gradient to remove
  32904. * @returns the current particle system
  32905. */
  32906. removeVelocityGradient(gradient: number): IParticleSystem;
  32907. /**
  32908. * Gets the current list of limit velocity gradients.
  32909. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  32910. * @returns the list of limit velocity gradients
  32911. */
  32912. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  32913. /**
  32914. * Adds a new limit velocity gradient
  32915. * @param gradient defines the gradient to use (between 0 and 1)
  32916. * @param factor defines the limit velocity to affect to the specified gradient
  32917. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32918. * @returns the current particle system
  32919. */
  32920. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32921. /**
  32922. * Remove a specific limit velocity gradient
  32923. * @param gradient defines the gradient to remove
  32924. * @returns the current particle system
  32925. */
  32926. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  32927. /**
  32928. * Adds a new drag gradient
  32929. * @param gradient defines the gradient to use (between 0 and 1)
  32930. * @param factor defines the drag to affect to the specified gradient
  32931. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32932. * @returns the current particle system
  32933. */
  32934. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32935. /**
  32936. * Remove a specific drag gradient
  32937. * @param gradient defines the gradient to remove
  32938. * @returns the current particle system
  32939. */
  32940. removeDragGradient(gradient: number): IParticleSystem;
  32941. /**
  32942. * Gets the current list of drag gradients.
  32943. * You must use addDragGradient and removeDragGradient to udpate this list
  32944. * @returns the list of drag gradients
  32945. */
  32946. getDragGradients(): Nullable<Array<FactorGradient>>;
  32947. /**
  32948. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  32949. * @param gradient defines the gradient to use (between 0 and 1)
  32950. * @param factor defines the emit rate to affect to the specified gradient
  32951. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32952. * @returns the current particle system
  32953. */
  32954. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32955. /**
  32956. * Remove a specific emit rate gradient
  32957. * @param gradient defines the gradient to remove
  32958. * @returns the current particle system
  32959. */
  32960. removeEmitRateGradient(gradient: number): IParticleSystem;
  32961. /**
  32962. * Gets the current list of emit rate gradients.
  32963. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  32964. * @returns the list of emit rate gradients
  32965. */
  32966. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  32967. /**
  32968. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  32969. * @param gradient defines the gradient to use (between 0 and 1)
  32970. * @param factor defines the start size to affect to the specified gradient
  32971. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32972. * @returns the current particle system
  32973. */
  32974. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32975. /**
  32976. * Remove a specific start size gradient
  32977. * @param gradient defines the gradient to remove
  32978. * @returns the current particle system
  32979. */
  32980. removeStartSizeGradient(gradient: number): IParticleSystem;
  32981. /**
  32982. * Gets the current list of start size gradients.
  32983. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  32984. * @returns the list of start size gradients
  32985. */
  32986. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  32987. /**
  32988. * Adds a new life time gradient
  32989. * @param gradient defines the gradient to use (between 0 and 1)
  32990. * @param factor defines the life time factor to affect to the specified gradient
  32991. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32992. * @returns the current particle system
  32993. */
  32994. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32995. /**
  32996. * Remove a specific life time gradient
  32997. * @param gradient defines the gradient to remove
  32998. * @returns the current particle system
  32999. */
  33000. removeLifeTimeGradient(gradient: number): IParticleSystem;
  33001. /**
  33002. * Gets the current list of life time gradients.
  33003. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  33004. * @returns the list of life time gradients
  33005. */
  33006. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  33007. /**
  33008. * Gets the current list of color gradients.
  33009. * You must use addColorGradient and removeColorGradient to udpate this list
  33010. * @returns the list of color gradients
  33011. */
  33012. getColorGradients(): Nullable<Array<ColorGradient>>;
  33013. /**
  33014. * Adds a new ramp gradient used to remap particle colors
  33015. * @param gradient defines the gradient to use (between 0 and 1)
  33016. * @param color defines the color to affect to the specified gradient
  33017. * @returns the current particle system
  33018. */
  33019. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  33020. /**
  33021. * Gets the current list of ramp gradients.
  33022. * You must use addRampGradient and removeRampGradient to udpate this list
  33023. * @returns the list of ramp gradients
  33024. */
  33025. getRampGradients(): Nullable<Array<Color3Gradient>>;
  33026. /** Gets or sets a boolean indicating that ramp gradients must be used
  33027. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  33028. */
  33029. useRampGradients: boolean;
  33030. /**
  33031. * Adds a new color remap gradient
  33032. * @param gradient defines the gradient to use (between 0 and 1)
  33033. * @param min defines the color remap minimal range
  33034. * @param max defines the color remap maximal range
  33035. * @returns the current particle system
  33036. */
  33037. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  33038. /**
  33039. * Gets the current list of color remap gradients.
  33040. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  33041. * @returns the list of color remap gradients
  33042. */
  33043. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  33044. /**
  33045. * Adds a new alpha remap gradient
  33046. * @param gradient defines the gradient to use (between 0 and 1)
  33047. * @param min defines the alpha remap minimal range
  33048. * @param max defines the alpha remap maximal range
  33049. * @returns the current particle system
  33050. */
  33051. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  33052. /**
  33053. * Gets the current list of alpha remap gradients.
  33054. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  33055. * @returns the list of alpha remap gradients
  33056. */
  33057. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  33058. /**
  33059. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  33060. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  33061. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  33062. * @returns the emitter
  33063. */
  33064. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  33065. /**
  33066. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  33067. * @param radius The radius of the hemisphere to emit from
  33068. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  33069. * @returns the emitter
  33070. */
  33071. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  33072. /**
  33073. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  33074. * @param radius The radius of the sphere to emit from
  33075. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  33076. * @returns the emitter
  33077. */
  33078. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  33079. /**
  33080. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  33081. * @param radius The radius of the sphere to emit from
  33082. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  33083. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  33084. * @returns the emitter
  33085. */
  33086. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  33087. /**
  33088. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  33089. * @param radius The radius of the emission cylinder
  33090. * @param height The height of the emission cylinder
  33091. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  33092. * @param directionRandomizer How much to randomize the particle direction [0-1]
  33093. * @returns the emitter
  33094. */
  33095. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  33096. /**
  33097. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  33098. * @param radius The radius of the cylinder to emit from
  33099. * @param height The height of the emission cylinder
  33100. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  33101. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  33102. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  33103. * @returns the emitter
  33104. */
  33105. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  33106. /**
  33107. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  33108. * @param radius The radius of the cone to emit from
  33109. * @param angle The base angle of the cone
  33110. * @returns the emitter
  33111. */
  33112. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  33113. /**
  33114. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  33115. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  33116. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  33117. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  33118. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  33119. * @returns the emitter
  33120. */
  33121. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  33122. /**
  33123. * Get hosting scene
  33124. * @returns the scene
  33125. */
  33126. getScene(): Scene;
  33127. }
  33128. }
  33129. declare module BABYLON {
  33130. /**
  33131. * A particle represents one of the element emitted by a particle system.
  33132. * This is mainly define by its coordinates, direction, velocity and age.
  33133. */
  33134. class Particle {
  33135. /**
  33136. * The particle system the particle belongs to.
  33137. */
  33138. particleSystem: ParticleSystem;
  33139. private static _Count;
  33140. /**
  33141. * Unique ID of the particle
  33142. */
  33143. id: number;
  33144. /**
  33145. * The world position of the particle in the scene.
  33146. */
  33147. position: Vector3;
  33148. /**
  33149. * The world direction of the particle in the scene.
  33150. */
  33151. direction: Vector3;
  33152. /**
  33153. * The color of the particle.
  33154. */
  33155. color: Color4;
  33156. /**
  33157. * The color change of the particle per step.
  33158. */
  33159. colorStep: Color4;
  33160. /**
  33161. * Defines how long will the life of the particle be.
  33162. */
  33163. lifeTime: number;
  33164. /**
  33165. * The current age of the particle.
  33166. */
  33167. age: number;
  33168. /**
  33169. * The current size of the particle.
  33170. */
  33171. size: number;
  33172. /**
  33173. * The current scale of the particle.
  33174. */
  33175. scale: Vector2;
  33176. /**
  33177. * The current angle of the particle.
  33178. */
  33179. angle: number;
  33180. /**
  33181. * Defines how fast is the angle changing.
  33182. */
  33183. angularSpeed: number;
  33184. /**
  33185. * Defines the cell index used by the particle to be rendered from a sprite.
  33186. */
  33187. cellIndex: number;
  33188. /**
  33189. * The information required to support color remapping
  33190. */
  33191. remapData: Vector4;
  33192. /** @hidden */
  33193. _randomCellOffset?: number;
  33194. /** @hidden */
  33195. _initialDirection: Nullable<Vector3>;
  33196. /** @hidden */
  33197. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  33198. /** @hidden */
  33199. _initialStartSpriteCellID: number;
  33200. /** @hidden */
  33201. _initialEndSpriteCellID: number;
  33202. /** @hidden */
  33203. _currentColorGradient: Nullable<ColorGradient>;
  33204. /** @hidden */
  33205. _currentColor1: Color4;
  33206. /** @hidden */
  33207. _currentColor2: Color4;
  33208. /** @hidden */
  33209. _currentSizeGradient: Nullable<FactorGradient>;
  33210. /** @hidden */
  33211. _currentSize1: number;
  33212. /** @hidden */
  33213. _currentSize2: number;
  33214. /** @hidden */
  33215. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  33216. /** @hidden */
  33217. _currentAngularSpeed1: number;
  33218. /** @hidden */
  33219. _currentAngularSpeed2: number;
  33220. /** @hidden */
  33221. _currentVelocityGradient: Nullable<FactorGradient>;
  33222. /** @hidden */
  33223. _currentVelocity1: number;
  33224. /** @hidden */
  33225. _currentVelocity2: number;
  33226. /** @hidden */
  33227. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  33228. /** @hidden */
  33229. _currentLimitVelocity1: number;
  33230. /** @hidden */
  33231. _currentLimitVelocity2: number;
  33232. /** @hidden */
  33233. _currentDragGradient: Nullable<FactorGradient>;
  33234. /** @hidden */
  33235. _currentDrag1: number;
  33236. /** @hidden */
  33237. _currentDrag2: number;
  33238. /** @hidden */
  33239. _randomNoiseCoordinates1: Vector3;
  33240. /** @hidden */
  33241. _randomNoiseCoordinates2: Vector3;
  33242. /**
  33243. * Creates a new instance Particle
  33244. * @param particleSystem the particle system the particle belongs to
  33245. */
  33246. constructor(
  33247. /**
  33248. * The particle system the particle belongs to.
  33249. */
  33250. particleSystem: ParticleSystem);
  33251. private updateCellInfoFromSystem;
  33252. /**
  33253. * Defines how the sprite cell index is updated for the particle
  33254. */
  33255. updateCellIndex(): void;
  33256. /** @hidden */
  33257. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  33258. /** @hidden */
  33259. _inheritParticleInfoToSubEmitters(): void;
  33260. /** @hidden */
  33261. _reset(): void;
  33262. /**
  33263. * Copy the properties of particle to another one.
  33264. * @param other the particle to copy the information to.
  33265. */
  33266. copyTo(other: Particle): void;
  33267. }
  33268. }
  33269. declare module BABYLON {
  33270. /**
  33271. * This class is made for on one-liner static method to help creating particle system set.
  33272. */
  33273. class ParticleHelper {
  33274. /**
  33275. * Gets or sets base Assets URL
  33276. */
  33277. static BaseAssetsUrl: string;
  33278. /**
  33279. * Create a default particle system that you can tweak
  33280. * @param emitter defines the emitter to use
  33281. * @param capacity defines the system capacity (default is 500 particles)
  33282. * @param scene defines the hosting scene
  33283. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  33284. * @returns the new Particle system
  33285. */
  33286. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  33287. /**
  33288. * This is the main static method (one-liner) of this helper to create different particle systems
  33289. * @param type This string represents the type to the particle system to create
  33290. * @param scene The scene where the particle system should live
  33291. * @param gpu If the system will use gpu
  33292. * @returns the ParticleSystemSet created
  33293. */
  33294. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  33295. /**
  33296. * Static function used to export a particle system to a ParticleSystemSet variable.
  33297. * Please note that the emitter shape is not exported
  33298. * @param systems defines the particle systems to export
  33299. * @returns the created particle system set
  33300. */
  33301. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  33302. }
  33303. }
  33304. declare module BABYLON {
  33305. /**
  33306. * This represents a particle system in Babylon.
  33307. * 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.
  33308. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  33309. * @example https://doc.babylonjs.com/babylon101/particles
  33310. */
  33311. class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  33312. /**
  33313. * Billboard mode will only apply to Y axis
  33314. */
  33315. static readonly BILLBOARDMODE_Y: number;
  33316. /**
  33317. * Billboard mode will apply to all axes
  33318. */
  33319. static readonly BILLBOARDMODE_ALL: number;
  33320. /**
  33321. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  33322. */
  33323. static readonly BILLBOARDMODE_STRETCHED: number;
  33324. /**
  33325. * This function can be defined to provide custom update for active particles.
  33326. * This function will be called instead of regular update (age, position, color, etc.).
  33327. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  33328. */
  33329. updateFunction: (particles: Particle[]) => void;
  33330. private _emitterWorldMatrix;
  33331. /**
  33332. * This function can be defined to specify initial direction for every new particle.
  33333. * It by default use the emitterType defined function
  33334. */
  33335. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  33336. /**
  33337. * This function can be defined to specify initial position for every new particle.
  33338. * It by default use the emitterType defined function
  33339. */
  33340. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  33341. /**
  33342. * @hidden
  33343. */
  33344. _inheritedVelocityOffset: Vector3;
  33345. /**
  33346. * An event triggered when the system is disposed
  33347. */
  33348. onDisposeObservable: Observable<ParticleSystem>;
  33349. private _onDisposeObserver;
  33350. /**
  33351. * Sets a callback that will be triggered when the system is disposed
  33352. */
  33353. onDispose: () => void;
  33354. private _particles;
  33355. private _epsilon;
  33356. private _capacity;
  33357. private _stockParticles;
  33358. private _newPartsExcess;
  33359. private _vertexData;
  33360. private _vertexBuffer;
  33361. private _vertexBuffers;
  33362. private _spriteBuffer;
  33363. private _indexBuffer;
  33364. private _effect;
  33365. private _customEffect;
  33366. private _cachedDefines;
  33367. private _scaledColorStep;
  33368. private _colorDiff;
  33369. private _scaledDirection;
  33370. private _scaledGravity;
  33371. private _currentRenderId;
  33372. private _alive;
  33373. private _useInstancing;
  33374. private _started;
  33375. private _stopped;
  33376. private _actualFrame;
  33377. private _scaledUpdateSpeed;
  33378. private _vertexBufferSize;
  33379. /** @hidden */
  33380. _currentEmitRateGradient: Nullable<FactorGradient>;
  33381. /** @hidden */
  33382. _currentEmitRate1: number;
  33383. /** @hidden */
  33384. _currentEmitRate2: number;
  33385. /** @hidden */
  33386. _currentStartSizeGradient: Nullable<FactorGradient>;
  33387. /** @hidden */
  33388. _currentStartSize1: number;
  33389. /** @hidden */
  33390. _currentStartSize2: number;
  33391. private readonly _rawTextureWidth;
  33392. private _rampGradientsTexture;
  33393. private _useRampGradients;
  33394. /** Gets or sets a boolean indicating that ramp gradients must be used
  33395. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  33396. */
  33397. useRampGradients: boolean;
  33398. /**
  33399. * 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.
  33400. * 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: [])
  33401. */
  33402. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  33403. private _subEmitters;
  33404. /**
  33405. * @hidden
  33406. * If the particle systems emitter should be disposed when the particle system is disposed
  33407. */
  33408. _disposeEmitterOnDispose: boolean;
  33409. /**
  33410. * The current active Sub-systems, this property is used by the root particle system only.
  33411. */
  33412. activeSubSystems: Array<ParticleSystem>;
  33413. private _rootParticleSystem;
  33414. /**
  33415. * Gets the current list of active particles
  33416. */
  33417. readonly particles: Particle[];
  33418. /**
  33419. * Returns the string "ParticleSystem"
  33420. * @returns a string containing the class name
  33421. */
  33422. getClassName(): string;
  33423. /**
  33424. * Instantiates a particle system.
  33425. * 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.
  33426. * @param name The name of the particle system
  33427. * @param capacity The max number of particles alive at the same time
  33428. * @param scene The scene the particle system belongs to
  33429. * @param customEffect a custom effect used to change the way particles are rendered by default
  33430. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  33431. * @param epsilon Offset used to render the particles
  33432. */
  33433. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  33434. private _addFactorGradient;
  33435. private _removeFactorGradient;
  33436. /**
  33437. * Adds a new life time gradient
  33438. * @param gradient defines the gradient to use (between 0 and 1)
  33439. * @param factor defines the life time factor to affect to the specified gradient
  33440. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  33441. * @returns the current particle system
  33442. */
  33443. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  33444. /**
  33445. * Remove a specific life time gradient
  33446. * @param gradient defines the gradient to remove
  33447. * @returns the current particle system
  33448. */
  33449. removeLifeTimeGradient(gradient: number): IParticleSystem;
  33450. /**
  33451. * Adds a new size gradient
  33452. * @param gradient defines the gradient to use (between 0 and 1)
  33453. * @param factor defines the size factor to affect to the specified gradient
  33454. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  33455. * @returns the current particle system
  33456. */
  33457. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  33458. /**
  33459. * Remove a specific size gradient
  33460. * @param gradient defines the gradient to remove
  33461. * @returns the current particle system
  33462. */
  33463. removeSizeGradient(gradient: number): IParticleSystem;
  33464. /**
  33465. * Adds a new color remap gradient
  33466. * @param gradient defines the gradient to use (between 0 and 1)
  33467. * @param min defines the color remap minimal range
  33468. * @param max defines the color remap maximal range
  33469. * @returns the current particle system
  33470. */
  33471. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  33472. /**
  33473. * Remove a specific color remap gradient
  33474. * @param gradient defines the gradient to remove
  33475. * @returns the current particle system
  33476. */
  33477. removeColorRemapGradient(gradient: number): IParticleSystem;
  33478. /**
  33479. * Adds a new alpha remap gradient
  33480. * @param gradient defines the gradient to use (between 0 and 1)
  33481. * @param min defines the alpha remap minimal range
  33482. * @param max defines the alpha remap maximal range
  33483. * @returns the current particle system
  33484. */
  33485. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  33486. /**
  33487. * Remove a specific alpha remap gradient
  33488. * @param gradient defines the gradient to remove
  33489. * @returns the current particle system
  33490. */
  33491. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  33492. /**
  33493. * Adds a new angular speed gradient
  33494. * @param gradient defines the gradient to use (between 0 and 1)
  33495. * @param factor defines the angular speed to affect to the specified gradient
  33496. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  33497. * @returns the current particle system
  33498. */
  33499. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  33500. /**
  33501. * Remove a specific angular speed gradient
  33502. * @param gradient defines the gradient to remove
  33503. * @returns the current particle system
  33504. */
  33505. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  33506. /**
  33507. * Adds a new velocity gradient
  33508. * @param gradient defines the gradient to use (between 0 and 1)
  33509. * @param factor defines the velocity to affect to the specified gradient
  33510. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  33511. * @returns the current particle system
  33512. */
  33513. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  33514. /**
  33515. * Remove a specific velocity gradient
  33516. * @param gradient defines the gradient to remove
  33517. * @returns the current particle system
  33518. */
  33519. removeVelocityGradient(gradient: number): IParticleSystem;
  33520. /**
  33521. * Adds a new limit velocity gradient
  33522. * @param gradient defines the gradient to use (between 0 and 1)
  33523. * @param factor defines the limit velocity value to affect to the specified gradient
  33524. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  33525. * @returns the current particle system
  33526. */
  33527. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  33528. /**
  33529. * Remove a specific limit velocity gradient
  33530. * @param gradient defines the gradient to remove
  33531. * @returns the current particle system
  33532. */
  33533. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  33534. /**
  33535. * Adds a new drag gradient
  33536. * @param gradient defines the gradient to use (between 0 and 1)
  33537. * @param factor defines the drag value to affect to the specified gradient
  33538. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  33539. * @returns the current particle system
  33540. */
  33541. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  33542. /**
  33543. * Remove a specific drag gradient
  33544. * @param gradient defines the gradient to remove
  33545. * @returns the current particle system
  33546. */
  33547. removeDragGradient(gradient: number): IParticleSystem;
  33548. /**
  33549. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  33550. * @param gradient defines the gradient to use (between 0 and 1)
  33551. * @param factor defines the emit rate value to affect to the specified gradient
  33552. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  33553. * @returns the current particle system
  33554. */
  33555. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  33556. /**
  33557. * Remove a specific emit rate gradient
  33558. * @param gradient defines the gradient to remove
  33559. * @returns the current particle system
  33560. */
  33561. removeEmitRateGradient(gradient: number): IParticleSystem;
  33562. /**
  33563. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  33564. * @param gradient defines the gradient to use (between 0 and 1)
  33565. * @param factor defines the start size value to affect to the specified gradient
  33566. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  33567. * @returns the current particle system
  33568. */
  33569. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  33570. /**
  33571. * Remove a specific start size gradient
  33572. * @param gradient defines the gradient to remove
  33573. * @returns the current particle system
  33574. */
  33575. removeStartSizeGradient(gradient: number): IParticleSystem;
  33576. private _createRampGradientTexture;
  33577. /**
  33578. * Gets the current list of ramp gradients.
  33579. * You must use addRampGradient and removeRampGradient to udpate this list
  33580. * @returns the list of ramp gradients
  33581. */
  33582. getRampGradients(): Nullable<Array<Color3Gradient>>;
  33583. /**
  33584. * Adds a new ramp gradient used to remap particle colors
  33585. * @param gradient defines the gradient to use (between 0 and 1)
  33586. * @param color defines the color to affect to the specified gradient
  33587. * @returns the current particle system
  33588. */
  33589. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  33590. /**
  33591. * Remove a specific ramp gradient
  33592. * @param gradient defines the gradient to remove
  33593. * @returns the current particle system
  33594. */
  33595. removeRampGradient(gradient: number): ParticleSystem;
  33596. /**
  33597. * Adds a new color gradient
  33598. * @param gradient defines the gradient to use (between 0 and 1)
  33599. * @param color1 defines the color to affect to the specified gradient
  33600. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  33601. * @returns this particle system
  33602. */
  33603. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  33604. /**
  33605. * Remove a specific color gradient
  33606. * @param gradient defines the gradient to remove
  33607. * @returns this particle system
  33608. */
  33609. removeColorGradient(gradient: number): IParticleSystem;
  33610. private _fetchR;
  33611. protected _reset(): void;
  33612. private _resetEffect;
  33613. private _createVertexBuffers;
  33614. private _createIndexBuffer;
  33615. /**
  33616. * Gets the maximum number of particles active at the same time.
  33617. * @returns The max number of active particles.
  33618. */
  33619. getCapacity(): number;
  33620. /**
  33621. * Gets whether there are still active particles in the system.
  33622. * @returns True if it is alive, otherwise false.
  33623. */
  33624. isAlive(): boolean;
  33625. /**
  33626. * Gets if the system has been started. (Note: this will still be true after stop is called)
  33627. * @returns True if it has been started, otherwise false.
  33628. */
  33629. isStarted(): boolean;
  33630. private _prepareSubEmitterInternalArray;
  33631. /**
  33632. * Starts the particle system and begins to emit
  33633. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  33634. */
  33635. start(delay?: number): void;
  33636. /**
  33637. * Stops the particle system.
  33638. * @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.
  33639. */
  33640. stop(stopSubEmitters?: boolean): void;
  33641. /**
  33642. * Remove all active particles
  33643. */
  33644. reset(): void;
  33645. /**
  33646. * @hidden (for internal use only)
  33647. */
  33648. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  33649. /**
  33650. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  33651. * Its lifetime will start back at 0.
  33652. */
  33653. recycleParticle: (particle: Particle) => void;
  33654. private _stopSubEmitters;
  33655. private _createParticle;
  33656. private _removeFromRoot;
  33657. private _emitFromParticle;
  33658. private _update;
  33659. /** @hidden */
  33660. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  33661. /** @hidden */
  33662. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  33663. /** @hidden */
  33664. private _getEffect;
  33665. /**
  33666. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  33667. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  33668. */
  33669. animate(preWarmOnly?: boolean): void;
  33670. private _appendParticleVertices;
  33671. /**
  33672. * Rebuilds the particle system.
  33673. */
  33674. rebuild(): void;
  33675. /**
  33676. * Is this system ready to be used/rendered
  33677. * @return true if the system is ready
  33678. */
  33679. isReady(): boolean;
  33680. private _render;
  33681. /**
  33682. * Renders the particle system in its current state.
  33683. * @returns the current number of particles
  33684. */
  33685. render(): number;
  33686. /**
  33687. * Disposes the particle system and free the associated resources
  33688. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  33689. */
  33690. dispose(disposeTexture?: boolean): void;
  33691. /**
  33692. * Clones the particle system.
  33693. * @param name The name of the cloned object
  33694. * @param newEmitter The new emitter to use
  33695. * @returns the cloned particle system
  33696. */
  33697. clone(name: string, newEmitter: any): ParticleSystem;
  33698. /**
  33699. * Serializes the particle system to a JSON object.
  33700. * @returns the JSON object
  33701. */
  33702. serialize(): any;
  33703. /** @hidden */
  33704. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  33705. /** @hidden */
  33706. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  33707. /**
  33708. * Parses a JSON object to create a particle system.
  33709. * @param parsedParticleSystem The JSON object to parse
  33710. * @param scene The scene to create the particle system in
  33711. * @param rootUrl The root url to use to load external dependencies like texture
  33712. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  33713. * @returns the Parsed particle system
  33714. */
  33715. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  33716. }
  33717. }
  33718. declare module BABYLON {
  33719. interface Engine {
  33720. /**
  33721. * Create an effect to use with particle systems.
  33722. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  33723. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  33724. * @param uniformsNames defines a list of attribute names
  33725. * @param samplers defines an array of string used to represent textures
  33726. * @param defines defines the string containing the defines to use to compile the shaders
  33727. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  33728. * @param onCompiled defines a function to call when the effect creation is successful
  33729. * @param onError defines a function to call when the effect creation has failed
  33730. * @returns the new Effect
  33731. */
  33732. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  33733. }
  33734. interface Mesh {
  33735. /**
  33736. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  33737. * @returns an array of IParticleSystem
  33738. */
  33739. getEmittedParticleSystems(): IParticleSystem[];
  33740. /**
  33741. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  33742. * @returns an array of IParticleSystem
  33743. */
  33744. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  33745. }
  33746. }
  33747. declare module BABYLON {
  33748. /**
  33749. * Represents a set of particle systems working together to create a specific effect
  33750. */
  33751. class ParticleSystemSet implements IDisposable {
  33752. private _emitterCreationOptions;
  33753. private _emitterNode;
  33754. /**
  33755. * Gets the particle system list
  33756. */
  33757. systems: IParticleSystem[];
  33758. /**
  33759. * Gets the emitter node used with this set
  33760. */
  33761. readonly emitterNode: Nullable<TransformNode>;
  33762. /**
  33763. * Creates a new emitter mesh as a sphere
  33764. * @param options defines the options used to create the sphere
  33765. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  33766. * @param scene defines the hosting scene
  33767. */
  33768. setEmitterAsSphere(options: {
  33769. diameter: number;
  33770. segments: number;
  33771. color: Color3;
  33772. }, renderingGroupId: number, scene: Scene): void;
  33773. /**
  33774. * Starts all particle systems of the set
  33775. * @param emitter defines an optional mesh to use as emitter for the particle systems
  33776. */
  33777. start(emitter?: AbstractMesh): void;
  33778. /**
  33779. * Release all associated resources
  33780. */
  33781. dispose(): void;
  33782. /**
  33783. * Serialize the set into a JSON compatible object
  33784. * @returns a JSON compatible representation of the set
  33785. */
  33786. serialize(): any;
  33787. /**
  33788. * Parse a new ParticleSystemSet from a serialized source
  33789. * @param data defines a JSON compatible representation of the set
  33790. * @param scene defines the hosting scene
  33791. * @param gpu defines if we want GPU particles or CPU particles
  33792. * @returns a new ParticleSystemSet
  33793. */
  33794. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  33795. }
  33796. }
  33797. declare module BABYLON {
  33798. /**
  33799. * Represents one particle of a solid particle system.
  33800. */
  33801. class SolidParticle {
  33802. /**
  33803. * particle global index
  33804. */
  33805. idx: number;
  33806. /**
  33807. * The color of the particle
  33808. */
  33809. color: Nullable<Color4>;
  33810. /**
  33811. * The world space position of the particle.
  33812. */
  33813. position: Vector3;
  33814. /**
  33815. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  33816. */
  33817. rotation: Vector3;
  33818. /**
  33819. * The world space rotation quaternion of the particle.
  33820. */
  33821. rotationQuaternion: Nullable<Quaternion>;
  33822. /**
  33823. * The scaling of the particle.
  33824. */
  33825. scaling: Vector3;
  33826. /**
  33827. * The uvs of the particle.
  33828. */
  33829. uvs: Vector4;
  33830. /**
  33831. * The current speed of the particle.
  33832. */
  33833. velocity: Vector3;
  33834. /**
  33835. * The pivot point in the particle local space.
  33836. */
  33837. pivot: Vector3;
  33838. /**
  33839. * Must the particle be translated from its pivot point in its local space ?
  33840. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  33841. * Default : false
  33842. */
  33843. translateFromPivot: boolean;
  33844. /**
  33845. * Is the particle active or not ?
  33846. */
  33847. alive: boolean;
  33848. /**
  33849. * Is the particle visible or not ?
  33850. */
  33851. isVisible: boolean;
  33852. /**
  33853. * Index of this particle in the global "positions" array (Internal use)
  33854. * @hidden
  33855. */
  33856. _pos: number;
  33857. /**
  33858. * @hidden Index of this particle in the global "indices" array (Internal use)
  33859. */
  33860. _ind: number;
  33861. /**
  33862. * @hidden ModelShape of this particle (Internal use)
  33863. */
  33864. _model: ModelShape;
  33865. /**
  33866. * ModelShape id of this particle
  33867. */
  33868. shapeId: number;
  33869. /**
  33870. * Index of the particle in its shape id (Internal use)
  33871. */
  33872. idxInShape: number;
  33873. /**
  33874. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  33875. */
  33876. _modelBoundingInfo: BoundingInfo;
  33877. /**
  33878. * @hidden Particle BoundingInfo object (Internal use)
  33879. */
  33880. _boundingInfo: BoundingInfo;
  33881. /**
  33882. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  33883. */
  33884. _sps: SolidParticleSystem;
  33885. /**
  33886. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  33887. */
  33888. _stillInvisible: boolean;
  33889. /**
  33890. * @hidden Last computed particle rotation matrix
  33891. */
  33892. _rotationMatrix: number[];
  33893. /**
  33894. * Parent particle Id, if any.
  33895. * Default null.
  33896. */
  33897. parentId: Nullable<number>;
  33898. /**
  33899. * @hidden Internal global position in the SPS.
  33900. */
  33901. _globalPosition: Vector3;
  33902. /**
  33903. * Creates a Solid Particle object.
  33904. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  33905. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  33906. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  33907. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  33908. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  33909. * @param shapeId (integer) is the model shape identifier in the SPS.
  33910. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  33911. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  33912. */
  33913. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  33914. /**
  33915. * Legacy support, changed scale to scaling
  33916. */
  33917. /**
  33918. * Legacy support, changed scale to scaling
  33919. */
  33920. scale: Vector3;
  33921. /**
  33922. * Legacy support, changed quaternion to rotationQuaternion
  33923. */
  33924. /**
  33925. * Legacy support, changed quaternion to rotationQuaternion
  33926. */
  33927. quaternion: Nullable<Quaternion>;
  33928. /**
  33929. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  33930. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  33931. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  33932. * @returns true if it intersects
  33933. */
  33934. intersectsMesh(target: Mesh | SolidParticle): boolean;
  33935. /**
  33936. * get the rotation matrix of the particle
  33937. * @hidden
  33938. */
  33939. getRotationMatrix(m: Matrix): void;
  33940. }
  33941. /**
  33942. * Represents the shape of the model used by one particle of a solid particle system.
  33943. * SPS internal tool, don't use it manually.
  33944. */
  33945. class ModelShape {
  33946. /**
  33947. * The shape id
  33948. * @hidden
  33949. */
  33950. shapeID: number;
  33951. /**
  33952. * flat array of model positions (internal use)
  33953. * @hidden
  33954. */
  33955. _shape: Vector3[];
  33956. /**
  33957. * flat array of model UVs (internal use)
  33958. * @hidden
  33959. */
  33960. _shapeUV: number[];
  33961. /**
  33962. * length of the shape in the model indices array (internal use)
  33963. * @hidden
  33964. */
  33965. _indicesLength: number;
  33966. /**
  33967. * Custom position function (internal use)
  33968. * @hidden
  33969. */
  33970. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  33971. /**
  33972. * Custom vertex function (internal use)
  33973. * @hidden
  33974. */
  33975. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  33976. /**
  33977. * 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.
  33978. * SPS internal tool, don't use it manually.
  33979. * @hidden
  33980. */
  33981. 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>);
  33982. }
  33983. /**
  33984. * Represents a Depth Sorted Particle in the solid particle system.
  33985. */
  33986. class DepthSortedParticle {
  33987. /**
  33988. * Index of the particle in the "indices" array
  33989. */
  33990. ind: number;
  33991. /**
  33992. * Length of the particle shape in the "indices" array
  33993. */
  33994. indicesLength: number;
  33995. /**
  33996. * Squared distance from the particle to the camera
  33997. */
  33998. sqDistance: number;
  33999. }
  34000. }
  34001. declare module BABYLON {
  34002. /**
  34003. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  34004. *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.
  34005. * The SPS is also a particle system. It provides some methods to manage the particles.
  34006. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  34007. *
  34008. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  34009. */
  34010. class SolidParticleSystem implements IDisposable {
  34011. /**
  34012. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  34013. * Example : var p = SPS.particles[i];
  34014. */
  34015. particles: SolidParticle[];
  34016. /**
  34017. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  34018. */
  34019. nbParticles: number;
  34020. /**
  34021. * If the particles must ever face the camera (default false). Useful for planar particles.
  34022. */
  34023. billboard: boolean;
  34024. /**
  34025. * Recompute normals when adding a shape
  34026. */
  34027. recomputeNormals: boolean;
  34028. /**
  34029. * This a counter ofr your own usage. It's not set by any SPS functions.
  34030. */
  34031. counter: number;
  34032. /**
  34033. * The SPS name. This name is also given to the underlying mesh.
  34034. */
  34035. name: string;
  34036. /**
  34037. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  34038. */
  34039. mesh: Mesh;
  34040. /**
  34041. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  34042. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  34043. */
  34044. vars: any;
  34045. /**
  34046. * This array is populated when the SPS is set as 'pickable'.
  34047. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  34048. * Each element of this array is an object `{idx: int, faceId: int}`.
  34049. * `idx` is the picked particle index in the `SPS.particles` array
  34050. * `faceId` is the picked face index counted within this particle.
  34051. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  34052. */
  34053. pickedParticles: {
  34054. idx: number;
  34055. faceId: number;
  34056. }[];
  34057. /**
  34058. * This array is populated when `enableDepthSort` is set to true.
  34059. * Each element of this array is an instance of the class DepthSortedParticle.
  34060. */
  34061. depthSortedParticles: DepthSortedParticle[];
  34062. /**
  34063. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  34064. * @hidden
  34065. */
  34066. _bSphereOnly: boolean;
  34067. /**
  34068. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  34069. * @hidden
  34070. */
  34071. _bSphereRadiusFactor: number;
  34072. private _scene;
  34073. private _positions;
  34074. private _indices;
  34075. private _normals;
  34076. private _colors;
  34077. private _uvs;
  34078. private _indices32;
  34079. private _positions32;
  34080. private _normals32;
  34081. private _fixedNormal32;
  34082. private _colors32;
  34083. private _uvs32;
  34084. private _index;
  34085. private _updatable;
  34086. private _pickable;
  34087. private _isVisibilityBoxLocked;
  34088. private _alwaysVisible;
  34089. private _depthSort;
  34090. private _shapeCounter;
  34091. private _copy;
  34092. private _color;
  34093. private _computeParticleColor;
  34094. private _computeParticleTexture;
  34095. private _computeParticleRotation;
  34096. private _computeParticleVertex;
  34097. private _computeBoundingBox;
  34098. private _depthSortParticles;
  34099. private _camera;
  34100. private _mustUnrotateFixedNormals;
  34101. private _particlesIntersect;
  34102. private _needs32Bits;
  34103. /**
  34104. * Creates a SPS (Solid Particle System) object.
  34105. * @param name (String) is the SPS name, this will be the underlying mesh name.
  34106. * @param scene (Scene) is the scene in which the SPS is added.
  34107. * @param updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  34108. * @param isPickable (optional boolean, default false) : if the solid particles must be pickable.
  34109. * @param enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  34110. * @param particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  34111. * @param boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  34112. * @param bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  34113. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  34114. */
  34115. constructor(name: string, scene: Scene, options?: {
  34116. updatable?: boolean;
  34117. isPickable?: boolean;
  34118. enableDepthSort?: boolean;
  34119. particleIntersection?: boolean;
  34120. boundingSphereOnly?: boolean;
  34121. bSphereRadiusFactor?: number;
  34122. });
  34123. /**
  34124. * Builds the SPS underlying mesh. Returns a standard Mesh.
  34125. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  34126. * @returns the created mesh
  34127. */
  34128. buildMesh(): Mesh;
  34129. /**
  34130. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  34131. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  34132. * Thus the particles generated from `digest()` have their property `position` set yet.
  34133. * @param mesh ( Mesh ) is the mesh to be digested
  34134. * @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
  34135. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  34136. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  34137. * @returns the current SPS
  34138. */
  34139. digest(mesh: Mesh, options?: {
  34140. facetNb?: number;
  34141. number?: number;
  34142. delta?: number;
  34143. }): SolidParticleSystem;
  34144. private _unrotateFixedNormals;
  34145. private _resetCopy;
  34146. private _meshBuilder;
  34147. private _posToShape;
  34148. private _uvsToShapeUV;
  34149. private _addParticle;
  34150. /**
  34151. * Adds some particles to the SPS from the model shape. Returns the shape id.
  34152. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  34153. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  34154. * @param nb (positive integer) the number of particles to be created from this model
  34155. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  34156. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  34157. * @returns the number of shapes in the system
  34158. */
  34159. addShape(mesh: Mesh, nb: number, options?: {
  34160. positionFunction?: any;
  34161. vertexFunction?: any;
  34162. }): number;
  34163. private _rebuildParticle;
  34164. /**
  34165. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  34166. * @returns the SPS.
  34167. */
  34168. rebuildMesh(): SolidParticleSystem;
  34169. /**
  34170. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  34171. * This method calls `updateParticle()` for each particle of the SPS.
  34172. * For an animated SPS, it is usually called within the render loop.
  34173. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  34174. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  34175. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  34176. * @returns the SPS.
  34177. */
  34178. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  34179. /**
  34180. * Disposes the SPS.
  34181. */
  34182. dispose(): void;
  34183. /**
  34184. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  34185. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  34186. * @returns the SPS.
  34187. */
  34188. refreshVisibleSize(): SolidParticleSystem;
  34189. /**
  34190. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  34191. * @param size the size (float) of the visibility box
  34192. * note : this doesn't lock the SPS mesh bounding box.
  34193. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  34194. */
  34195. setVisibilityBox(size: number): void;
  34196. /**
  34197. * Gets whether the SPS as always visible or not
  34198. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  34199. */
  34200. /**
  34201. * Sets the SPS as always visible or not
  34202. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  34203. */
  34204. isAlwaysVisible: boolean;
  34205. /**
  34206. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  34207. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  34208. */
  34209. /**
  34210. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  34211. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  34212. */
  34213. isVisibilityBoxLocked: boolean;
  34214. /**
  34215. * Tells to `setParticles()` to compute the particle rotations or not.
  34216. * Default value : true. The SPS is faster when it's set to false.
  34217. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  34218. */
  34219. /**
  34220. * Gets if `setParticles()` computes the particle rotations or not.
  34221. * Default value : true. The SPS is faster when it's set to false.
  34222. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  34223. */
  34224. computeParticleRotation: boolean;
  34225. /**
  34226. * Tells to `setParticles()` to compute the particle colors or not.
  34227. * Default value : true. The SPS is faster when it's set to false.
  34228. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  34229. */
  34230. /**
  34231. * Gets if `setParticles()` computes the particle colors or not.
  34232. * Default value : true. The SPS is faster when it's set to false.
  34233. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  34234. */
  34235. computeParticleColor: boolean;
  34236. /**
  34237. * Gets if `setParticles()` computes the particle textures or not.
  34238. * Default value : true. The SPS is faster when it's set to false.
  34239. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  34240. */
  34241. computeParticleTexture: boolean;
  34242. /**
  34243. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  34244. * Default value : false. The SPS is faster when it's set to false.
  34245. * Note : the particle custom vertex positions aren't stored values.
  34246. */
  34247. /**
  34248. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  34249. * Default value : false. The SPS is faster when it's set to false.
  34250. * Note : the particle custom vertex positions aren't stored values.
  34251. */
  34252. computeParticleVertex: boolean;
  34253. /**
  34254. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  34255. */
  34256. /**
  34257. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  34258. */
  34259. computeBoundingBox: boolean;
  34260. /**
  34261. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  34262. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  34263. * Default : `true`
  34264. */
  34265. /**
  34266. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  34267. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  34268. * Default : `true`
  34269. */
  34270. depthSortParticles: boolean;
  34271. /**
  34272. * This function does nothing. It may be overwritten to set all the particle first values.
  34273. * The SPS doesn't call this function, you may have to call it by your own.
  34274. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  34275. */
  34276. initParticles(): void;
  34277. /**
  34278. * This function does nothing. It may be overwritten to recycle a particle.
  34279. * The SPS doesn't call this function, you may have to call it by your own.
  34280. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  34281. * @param particle The particle to recycle
  34282. * @returns the recycled particle
  34283. */
  34284. recycleParticle(particle: SolidParticle): SolidParticle;
  34285. /**
  34286. * Updates a particle : this function should be overwritten by the user.
  34287. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  34288. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  34289. * @example : just set a particle position or velocity and recycle conditions
  34290. * @param particle The particle to update
  34291. * @returns the updated particle
  34292. */
  34293. updateParticle(particle: SolidParticle): SolidParticle;
  34294. /**
  34295. * Updates a vertex of a particle : it can be overwritten by the user.
  34296. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  34297. * @param particle the current particle
  34298. * @param vertex the current index of the current particle
  34299. * @param pt the index of the current vertex in the particle shape
  34300. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  34301. * @example : just set a vertex particle position
  34302. * @returns the updated vertex
  34303. */
  34304. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  34305. /**
  34306. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  34307. * This does nothing and may be overwritten by the user.
  34308. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  34309. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  34310. * @param update the boolean update value actually passed to setParticles()
  34311. */
  34312. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  34313. /**
  34314. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  34315. * This will be passed three parameters.
  34316. * This does nothing and may be overwritten by the user.
  34317. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  34318. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  34319. * @param update the boolean update value actually passed to setParticles()
  34320. */
  34321. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  34322. }
  34323. }
  34324. declare module BABYLON {
  34325. /**
  34326. * Type of sub emitter
  34327. */
  34328. enum SubEmitterType {
  34329. /**
  34330. * Attached to the particle over it's lifetime
  34331. */
  34332. ATTACHED = 0,
  34333. /**
  34334. * Created when the particle dies
  34335. */
  34336. END = 1
  34337. }
  34338. /**
  34339. * Sub emitter class used to emit particles from an existing particle
  34340. */
  34341. class SubEmitter {
  34342. /**
  34343. * the particle system to be used by the sub emitter
  34344. */
  34345. particleSystem: ParticleSystem;
  34346. /**
  34347. * Type of the submitter (Default: END)
  34348. */
  34349. type: SubEmitterType;
  34350. /**
  34351. * 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)
  34352. * Note: This only is supported when using an emitter of type Mesh
  34353. */
  34354. inheritDirection: boolean;
  34355. /**
  34356. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  34357. */
  34358. inheritedVelocityAmount: number;
  34359. /**
  34360. * Creates a sub emitter
  34361. * @param particleSystem the particle system to be used by the sub emitter
  34362. */
  34363. constructor(
  34364. /**
  34365. * the particle system to be used by the sub emitter
  34366. */
  34367. particleSystem: ParticleSystem);
  34368. /**
  34369. * Clones the sub emitter
  34370. * @returns the cloned sub emitter
  34371. */
  34372. clone(): SubEmitter;
  34373. /**
  34374. * Serialize current object to a JSON object
  34375. * @returns the serialized object
  34376. */
  34377. serialize(): any;
  34378. /**
  34379. * Creates a new SubEmitter from a serialized JSON version
  34380. * @param serializationObject defines the JSON object to read from
  34381. * @param scene defines the hosting scene
  34382. * @param rootUrl defines the rootUrl for data loading
  34383. * @returns a new SubEmitter
  34384. */
  34385. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  34386. /** Release associated resources */
  34387. dispose(): void;
  34388. }
  34389. }
  34390. declare module BABYLON {
  34391. interface AbstractScene {
  34392. /**
  34393. * The list of reflection probes added to the scene
  34394. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  34395. */
  34396. reflectionProbes: Array<ReflectionProbe>;
  34397. /**
  34398. * Removes the given reflection probe from this scene.
  34399. * @param toRemove The reflection probe to remove
  34400. * @returns The index of the removed reflection probe
  34401. */
  34402. removeReflectionProbe(toRemove: ReflectionProbe): number;
  34403. /**
  34404. * Adds the given reflection probe to this scene.
  34405. * @param newReflectionProbe The reflection probe to add
  34406. */
  34407. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  34408. }
  34409. /**
  34410. * Class used to generate realtime reflection / refraction cube textures
  34411. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  34412. */
  34413. class ReflectionProbe {
  34414. /** defines the name of the probe */
  34415. name: string;
  34416. private _scene;
  34417. private _renderTargetTexture;
  34418. private _projectionMatrix;
  34419. private _viewMatrix;
  34420. private _target;
  34421. private _add;
  34422. private _attachedMesh;
  34423. private _invertYAxis;
  34424. /** Gets or sets probe position (center of the cube map) */
  34425. position: Vector3;
  34426. /**
  34427. * Creates a new reflection probe
  34428. * @param name defines the name of the probe
  34429. * @param size defines the texture resolution (for each face)
  34430. * @param scene defines the hosting scene
  34431. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  34432. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  34433. */
  34434. constructor(
  34435. /** defines the name of the probe */
  34436. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  34437. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  34438. samples: number;
  34439. /** Gets or sets the refresh rate to use (on every frame by default) */
  34440. refreshRate: number;
  34441. /**
  34442. * Gets the hosting scene
  34443. * @returns a Scene
  34444. */
  34445. getScene(): Scene;
  34446. /** Gets the internal CubeTexture used to render to */
  34447. readonly cubeTexture: RenderTargetTexture;
  34448. /** Gets the list of meshes to render */
  34449. readonly renderList: Nullable<AbstractMesh[]>;
  34450. /**
  34451. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  34452. * @param mesh defines the mesh to attach to
  34453. */
  34454. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  34455. /**
  34456. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  34457. * @param renderingGroupId The rendering group id corresponding to its index
  34458. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34459. */
  34460. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  34461. /**
  34462. * Clean all associated resources
  34463. */
  34464. dispose(): void;
  34465. /**
  34466. * Converts the reflection probe information to a readable string for debug purpose.
  34467. * @param fullDetails Supports for multiple levels of logging within scene loading
  34468. * @returns the human readable reflection probe info
  34469. */
  34470. toString(fullDetails?: boolean): string;
  34471. /**
  34472. * Get the class name of the relfection probe.
  34473. * @returns "ReflectionProbe"
  34474. */
  34475. getClassName(): string;
  34476. /**
  34477. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  34478. * @returns The JSON representation of the texture
  34479. */
  34480. serialize(): any;
  34481. /**
  34482. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  34483. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  34484. * @param scene Define the scene the parsed reflection probe should be instantiated in
  34485. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  34486. * @returns The parsed reflection probe if successful
  34487. */
  34488. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  34489. }
  34490. }
  34491. declare module BABYLON {
  34492. interface Scene {
  34493. /** @hidden (Backing field) */
  34494. _boundingBoxRenderer: BoundingBoxRenderer;
  34495. /** @hidden (Backing field) */
  34496. _forceShowBoundingBoxes: boolean;
  34497. /**
  34498. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  34499. */
  34500. forceShowBoundingBoxes: boolean;
  34501. /**
  34502. * Gets the bounding box renderer associated with the scene
  34503. * @returns a BoundingBoxRenderer
  34504. */
  34505. getBoundingBoxRenderer(): BoundingBoxRenderer;
  34506. }
  34507. interface AbstractMesh {
  34508. /** @hidden (Backing field) */
  34509. _showBoundingBox: boolean;
  34510. /**
  34511. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  34512. */
  34513. showBoundingBox: boolean;
  34514. }
  34515. /**
  34516. * Component responsible of rendering the bounding box of the meshes in a scene.
  34517. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  34518. */
  34519. class BoundingBoxRenderer implements ISceneComponent {
  34520. /**
  34521. * The component name helpfull to identify the component in the list of scene components.
  34522. */
  34523. readonly name: string;
  34524. /**
  34525. * The scene the component belongs to.
  34526. */
  34527. scene: Scene;
  34528. /**
  34529. * Color of the bounding box lines placed in front of an object
  34530. */
  34531. frontColor: Color3;
  34532. /**
  34533. * Color of the bounding box lines placed behind an object
  34534. */
  34535. backColor: Color3;
  34536. /**
  34537. * Defines if the renderer should show the back lines or not
  34538. */
  34539. showBackLines: boolean;
  34540. /**
  34541. * @hidden
  34542. */
  34543. renderList: SmartArray<BoundingBox>;
  34544. private _colorShader;
  34545. private _vertexBuffers;
  34546. private _indexBuffer;
  34547. /**
  34548. * Instantiates a new bounding box renderer in a scene.
  34549. * @param scene the scene the renderer renders in
  34550. */
  34551. constructor(scene: Scene);
  34552. /**
  34553. * Registers the component in a given scene
  34554. */
  34555. register(): void;
  34556. private _evaluateSubMesh;
  34557. private _activeMesh;
  34558. private _prepareRessources;
  34559. private _createIndexBuffer;
  34560. /**
  34561. * Rebuilds the elements related to this component in case of
  34562. * context lost for instance.
  34563. */
  34564. rebuild(): void;
  34565. /**
  34566. * @hidden
  34567. */
  34568. reset(): void;
  34569. /**
  34570. * Render the bounding boxes of a specific rendering group
  34571. * @param renderingGroupId defines the rendering group to render
  34572. */
  34573. render(renderingGroupId: number): void;
  34574. /**
  34575. * In case of occlusion queries, we can render the occlusion bounding box through this method
  34576. * @param mesh Define the mesh to render the occlusion bounding box for
  34577. */
  34578. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  34579. /**
  34580. * Dispose and release the resources attached to this renderer.
  34581. */
  34582. dispose(): void;
  34583. }
  34584. }
  34585. declare module BABYLON {
  34586. /**
  34587. * This represents a depth renderer in Babylon.
  34588. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  34589. */
  34590. class DepthRenderer {
  34591. private _scene;
  34592. private _depthMap;
  34593. private _effect;
  34594. private _cachedDefines;
  34595. private _camera;
  34596. /**
  34597. * Specifiess that the depth renderer will only be used within
  34598. * the camera it is created for.
  34599. * This can help forcing its rendering during the camera processing.
  34600. */
  34601. useOnlyInActiveCamera: boolean;
  34602. /**
  34603. * Instantiates a depth renderer
  34604. * @param scene The scene the renderer belongs to
  34605. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  34606. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  34607. */
  34608. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  34609. /**
  34610. * Creates the depth rendering effect and checks if the effect is ready.
  34611. * @param subMesh The submesh to be used to render the depth map of
  34612. * @param useInstances If multiple world instances should be used
  34613. * @returns if the depth renderer is ready to render the depth map
  34614. */
  34615. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  34616. /**
  34617. * Gets the texture which the depth map will be written to.
  34618. * @returns The depth map texture
  34619. */
  34620. getDepthMap(): RenderTargetTexture;
  34621. /**
  34622. * Disposes of the depth renderer.
  34623. */
  34624. dispose(): void;
  34625. }
  34626. }
  34627. declare module BABYLON {
  34628. interface Scene {
  34629. /** @hidden (Backing field) */
  34630. _depthRenderer: {
  34631. [id: string]: DepthRenderer;
  34632. };
  34633. /**
  34634. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  34635. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  34636. * @returns the created depth renderer
  34637. */
  34638. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  34639. /**
  34640. * Disables a depth renderer for a given camera
  34641. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  34642. */
  34643. disableDepthRenderer(camera?: Nullable<Camera>): void;
  34644. }
  34645. /**
  34646. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  34647. * in several rendering techniques.
  34648. */
  34649. class DepthRendererSceneComponent implements ISceneComponent {
  34650. /**
  34651. * The component name helpfull to identify the component in the list of scene components.
  34652. */
  34653. readonly name: string;
  34654. /**
  34655. * The scene the component belongs to.
  34656. */
  34657. scene: Scene;
  34658. /**
  34659. * Creates a new instance of the component for the given scene
  34660. * @param scene Defines the scene to register the component in
  34661. */
  34662. constructor(scene: Scene);
  34663. /**
  34664. * Registers the component in a given scene
  34665. */
  34666. register(): void;
  34667. /**
  34668. * Rebuilds the elements related to this component in case of
  34669. * context lost for instance.
  34670. */
  34671. rebuild(): void;
  34672. /**
  34673. * Disposes the component and the associated ressources
  34674. */
  34675. dispose(): void;
  34676. private _gatherRenderTargets;
  34677. private _gatherActiveCameraRenderTargets;
  34678. }
  34679. }
  34680. declare module BABYLON {
  34681. interface AbstractMesh {
  34682. /**
  34683. * Disables the mesh edge rendering mode
  34684. * @returns the currentAbstractMesh
  34685. */
  34686. disableEdgesRendering(): AbstractMesh;
  34687. /**
  34688. * Enables the edge rendering mode on the mesh.
  34689. * This mode makes the mesh edges visible
  34690. * @param epsilon defines the maximal distance between two angles to detect a face
  34691. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  34692. * @returns the currentAbstractMesh
  34693. * @see https://www.babylonjs-playground.com/#19O9TU#0
  34694. */
  34695. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  34696. /**
  34697. * Gets the edgesRenderer associated with the mesh
  34698. */
  34699. edgesRenderer: Nullable<EdgesRenderer>;
  34700. }
  34701. interface LinesMesh {
  34702. /**
  34703. * Enables the edge rendering mode on the mesh.
  34704. * This mode makes the mesh edges visible
  34705. * @param epsilon defines the maximal distance between two angles to detect a face
  34706. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  34707. * @returns the currentAbstractMesh
  34708. * @see https://www.babylonjs-playground.com/#19O9TU#0
  34709. */
  34710. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  34711. }
  34712. interface InstancedLinesMesh {
  34713. /**
  34714. * Enables the edge rendering mode on the mesh.
  34715. * This mode makes the mesh edges visible
  34716. * @param epsilon defines the maximal distance between two angles to detect a face
  34717. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  34718. * @returns the current InstancedLinesMesh
  34719. * @see https://www.babylonjs-playground.com/#19O9TU#0
  34720. */
  34721. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  34722. }
  34723. /**
  34724. * Defines the minimum contract an Edges renderer should follow.
  34725. */
  34726. interface IEdgesRenderer extends IDisposable {
  34727. /**
  34728. * Gets or sets a boolean indicating if the edgesRenderer is active
  34729. */
  34730. isEnabled: boolean;
  34731. /**
  34732. * Renders the edges of the attached mesh,
  34733. */
  34734. render(): void;
  34735. /**
  34736. * Checks wether or not the edges renderer is ready to render.
  34737. * @return true if ready, otherwise false.
  34738. */
  34739. isReady(): boolean;
  34740. }
  34741. /**
  34742. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  34743. */
  34744. class EdgesRenderer implements IEdgesRenderer {
  34745. /**
  34746. * Define the size of the edges with an orthographic camera
  34747. */
  34748. edgesWidthScalerForOrthographic: number;
  34749. /**
  34750. * Define the size of the edges with a perspective camera
  34751. */
  34752. edgesWidthScalerForPerspective: number;
  34753. protected _source: AbstractMesh;
  34754. protected _linesPositions: number[];
  34755. protected _linesNormals: number[];
  34756. protected _linesIndices: number[];
  34757. protected _epsilon: number;
  34758. protected _indicesCount: number;
  34759. protected _lineShader: ShaderMaterial;
  34760. protected _ib: WebGLBuffer;
  34761. protected _buffers: {
  34762. [key: string]: Nullable<VertexBuffer>;
  34763. };
  34764. protected _checkVerticesInsteadOfIndices: boolean;
  34765. private _meshRebuildObserver;
  34766. private _meshDisposeObserver;
  34767. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  34768. isEnabled: boolean;
  34769. /**
  34770. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  34771. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  34772. * @param source Mesh used to create edges
  34773. * @param epsilon sum of angles in adjacency to check for edge
  34774. * @param checkVerticesInsteadOfIndices
  34775. * @param generateEdgesLines - should generate Lines or only prepare resources.
  34776. */
  34777. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  34778. protected _prepareRessources(): void;
  34779. /** @hidden */
  34780. _rebuild(): void;
  34781. /**
  34782. * Releases the required resources for the edges renderer
  34783. */
  34784. dispose(): void;
  34785. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  34786. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  34787. /**
  34788. * Checks if the pair of p0 and p1 is en edge
  34789. * @param faceIndex
  34790. * @param edge
  34791. * @param faceNormals
  34792. * @param p0
  34793. * @param p1
  34794. * @private
  34795. */
  34796. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  34797. /**
  34798. * push line into the position, normal and index buffer
  34799. * @protected
  34800. */
  34801. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  34802. /**
  34803. * Generates lines edges from adjacencjes
  34804. * @private
  34805. */
  34806. _generateEdgesLines(): void;
  34807. /**
  34808. * Checks wether or not the edges renderer is ready to render.
  34809. * @return true if ready, otherwise false.
  34810. */
  34811. isReady(): boolean;
  34812. /**
  34813. * Renders the edges of the attached mesh,
  34814. */
  34815. render(): void;
  34816. }
  34817. }
  34818. declare module BABYLON {
  34819. /**
  34820. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  34821. */
  34822. class GeometryBufferRenderer {
  34823. /**
  34824. * Constant used to retrieve the position texture index in the G-Buffer textures array
  34825. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  34826. */
  34827. static readonly POSITION_TEXTURE_TYPE: number;
  34828. /**
  34829. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  34830. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  34831. */
  34832. static readonly VELOCITY_TEXTURE_TYPE: number;
  34833. /**
  34834. * Dictionary used to store the previous transformation matrices of each rendered mesh
  34835. * in order to compute objects velocities when enableVelocity is set to "true"
  34836. * @hidden
  34837. */
  34838. _previousTransformationMatrices: {
  34839. [index: number]: Matrix;
  34840. };
  34841. private _scene;
  34842. private _multiRenderTarget;
  34843. private _ratio;
  34844. private _enablePosition;
  34845. private _enableVelocity;
  34846. private _positionIndex;
  34847. private _velocityIndex;
  34848. protected _effect: Effect;
  34849. protected _cachedDefines: string;
  34850. /**
  34851. * Set the render list (meshes to be rendered) used in the G buffer.
  34852. */
  34853. renderList: Mesh[];
  34854. /**
  34855. * Gets wether or not G buffer are supported by the running hardware.
  34856. * This requires draw buffer supports
  34857. */
  34858. readonly isSupported: boolean;
  34859. /**
  34860. * Returns the index of the given texture type in the G-Buffer textures array
  34861. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  34862. * @returns the index of the given texture type in the G-Buffer textures array
  34863. */
  34864. getTextureIndex(textureType: number): number;
  34865. /**
  34866. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  34867. */
  34868. /**
  34869. * Sets whether or not objects positions are enabled for the G buffer.
  34870. */
  34871. enablePosition: boolean;
  34872. /**
  34873. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  34874. */
  34875. /**
  34876. * Sets wether or not objects velocities are enabled for the G buffer.
  34877. */
  34878. enableVelocity: boolean;
  34879. /**
  34880. * Gets the scene associated with the buffer.
  34881. */
  34882. readonly scene: Scene;
  34883. /**
  34884. * Gets the ratio used by the buffer during its creation.
  34885. * How big is the buffer related to the main canvas.
  34886. */
  34887. readonly ratio: number;
  34888. /**
  34889. * Creates a new G Buffer for the scene
  34890. * @param scene The scene the buffer belongs to
  34891. * @param ratio How big is the buffer related to the main canvas.
  34892. */
  34893. constructor(scene: Scene, ratio?: number);
  34894. /**
  34895. * Checks wether everything is ready to render a submesh to the G buffer.
  34896. * @param subMesh the submesh to check readiness for
  34897. * @param useInstances is the mesh drawn using instance or not
  34898. * @returns true if ready otherwise false
  34899. */
  34900. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  34901. /**
  34902. * Gets the current underlying G Buffer.
  34903. * @returns the buffer
  34904. */
  34905. getGBuffer(): MultiRenderTarget;
  34906. /**
  34907. * Gets the number of samples used to render the buffer (anti aliasing).
  34908. */
  34909. /**
  34910. * Sets the number of samples used to render the buffer (anti aliasing).
  34911. */
  34912. samples: number;
  34913. /**
  34914. * Disposes the renderer and frees up associated resources.
  34915. */
  34916. dispose(): void;
  34917. protected _createRenderTargets(): void;
  34918. }
  34919. }
  34920. declare module BABYLON {
  34921. interface Scene {
  34922. /** @hidden (Backing field) */
  34923. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  34924. /**
  34925. * Gets or Sets the current geometry buffer associated to the scene.
  34926. */
  34927. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  34928. /**
  34929. * Enables a GeometryBufferRender and associates it with the scene
  34930. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  34931. * @returns the GeometryBufferRenderer
  34932. */
  34933. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  34934. /**
  34935. * Disables the GeometryBufferRender associated with the scene
  34936. */
  34937. disableGeometryBufferRenderer(): void;
  34938. }
  34939. /**
  34940. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  34941. * in several rendering techniques.
  34942. */
  34943. class GeometryBufferRendererSceneComponent implements ISceneComponent {
  34944. /**
  34945. * The component name helpful to identify the component in the list of scene components.
  34946. */
  34947. readonly name: string;
  34948. /**
  34949. * The scene the component belongs to.
  34950. */
  34951. scene: Scene;
  34952. /**
  34953. * Creates a new instance of the component for the given scene
  34954. * @param scene Defines the scene to register the component in
  34955. */
  34956. constructor(scene: Scene);
  34957. /**
  34958. * Registers the component in a given scene
  34959. */
  34960. register(): void;
  34961. /**
  34962. * Rebuilds the elements related to this component in case of
  34963. * context lost for instance.
  34964. */
  34965. rebuild(): void;
  34966. /**
  34967. * Disposes the component and the associated ressources
  34968. */
  34969. dispose(): void;
  34970. private _gatherRenderTargets;
  34971. }
  34972. }
  34973. declare module BABYLON {
  34974. /**
  34975. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  34976. */
  34977. class LineEdgesRenderer extends EdgesRenderer {
  34978. /**
  34979. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  34980. * @param source LineMesh used to generate edges
  34981. * @param epsilon not important (specified angle for edge detection)
  34982. * @param checkVerticesInsteadOfIndices not important for LineMesh
  34983. */
  34984. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  34985. /**
  34986. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  34987. */
  34988. _generateEdgesLines(): void;
  34989. }
  34990. }
  34991. declare module BABYLON {
  34992. interface Scene {
  34993. /** @hidden */
  34994. _outlineRenderer: OutlineRenderer;
  34995. /**
  34996. * Gets the outline renderer associated with the scene
  34997. * @returns a OutlineRenderer
  34998. */
  34999. getOutlineRenderer(): OutlineRenderer;
  35000. }
  35001. interface AbstractMesh {
  35002. /** @hidden (Backing field) */
  35003. _renderOutline: boolean;
  35004. /**
  35005. * Gets or sets a boolean indicating if the outline must be rendered as well
  35006. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  35007. */
  35008. renderOutline: boolean;
  35009. /** @hidden (Backing field) */
  35010. _renderOverlay: boolean;
  35011. /**
  35012. * Gets or sets a boolean indicating if the overlay must be rendered as well
  35013. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  35014. */
  35015. renderOverlay: boolean;
  35016. }
  35017. /**
  35018. * This class is responsible to draw bothe outline/overlay of meshes.
  35019. * It should not be used directly but through the available method on mesh.
  35020. */
  35021. class OutlineRenderer implements ISceneComponent {
  35022. /**
  35023. * The name of the component. Each component must have a unique name.
  35024. */
  35025. name: string;
  35026. /**
  35027. * The scene the component belongs to.
  35028. */
  35029. scene: Scene;
  35030. /**
  35031. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  35032. */
  35033. zOffset: number;
  35034. private _engine;
  35035. private _effect;
  35036. private _cachedDefines;
  35037. private _savedDepthWrite;
  35038. /**
  35039. * Instantiates a new outline renderer. (There could be only one per scene).
  35040. * @param scene Defines the scene it belongs to
  35041. */
  35042. constructor(scene: Scene);
  35043. /**
  35044. * Register the component to one instance of a scene.
  35045. */
  35046. register(): void;
  35047. /**
  35048. * Rebuilds the elements related to this component in case of
  35049. * context lost for instance.
  35050. */
  35051. rebuild(): void;
  35052. /**
  35053. * Disposes the component and the associated ressources.
  35054. */
  35055. dispose(): void;
  35056. /**
  35057. * Renders the outline in the canvas.
  35058. * @param subMesh Defines the sumesh to render
  35059. * @param batch Defines the batch of meshes in case of instances
  35060. * @param useOverlay Defines if the rendering is for the overlay or the outline
  35061. */
  35062. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  35063. /**
  35064. * Returns whether or not the outline renderer is ready for a given submesh.
  35065. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  35066. * @param subMesh Defines the submesh to check readyness for
  35067. * @param useInstances Defines wheter wee are trying to render instances or not
  35068. * @returns true if ready otherwise false
  35069. */
  35070. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  35071. private _beforeRenderingMesh;
  35072. private _afterRenderingMesh;
  35073. }
  35074. }
  35075. declare module BABYLON {
  35076. /**
  35077. * This represents the object necessary to create a rendering group.
  35078. * This is exclusively used and created by the rendering manager.
  35079. * To modify the behavior, you use the available helpers in your scene or meshes.
  35080. * @hidden
  35081. */
  35082. class RenderingGroup {
  35083. index: number;
  35084. private _scene;
  35085. private _opaqueSubMeshes;
  35086. private _transparentSubMeshes;
  35087. private _alphaTestSubMeshes;
  35088. private _depthOnlySubMeshes;
  35089. private _particleSystems;
  35090. private _spriteManagers;
  35091. private _opaqueSortCompareFn;
  35092. private _alphaTestSortCompareFn;
  35093. private _transparentSortCompareFn;
  35094. private _renderOpaque;
  35095. private _renderAlphaTest;
  35096. private _renderTransparent;
  35097. private _edgesRenderers;
  35098. onBeforeTransparentRendering: () => void;
  35099. /**
  35100. * Set the opaque sort comparison function.
  35101. * If null the sub meshes will be render in the order they were created
  35102. */
  35103. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  35104. /**
  35105. * Set the alpha test sort comparison function.
  35106. * If null the sub meshes will be render in the order they were created
  35107. */
  35108. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  35109. /**
  35110. * Set the transparent sort comparison function.
  35111. * If null the sub meshes will be render in the order they were created
  35112. */
  35113. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  35114. /**
  35115. * Creates a new rendering group.
  35116. * @param index The rendering group index
  35117. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  35118. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  35119. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  35120. */
  35121. 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>);
  35122. /**
  35123. * Render all the sub meshes contained in the group.
  35124. * @param customRenderFunction Used to override the default render behaviour of the group.
  35125. * @returns true if rendered some submeshes.
  35126. */
  35127. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  35128. /**
  35129. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  35130. * @param subMeshes The submeshes to render
  35131. */
  35132. private renderOpaqueSorted;
  35133. /**
  35134. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  35135. * @param subMeshes The submeshes to render
  35136. */
  35137. private renderAlphaTestSorted;
  35138. /**
  35139. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  35140. * @param subMeshes The submeshes to render
  35141. */
  35142. private renderTransparentSorted;
  35143. /**
  35144. * Renders the submeshes in a specified order.
  35145. * @param subMeshes The submeshes to sort before render
  35146. * @param sortCompareFn The comparison function use to sort
  35147. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  35148. * @param transparent Specifies to activate blending if true
  35149. */
  35150. private static renderSorted;
  35151. /**
  35152. * Renders the submeshes in the order they were dispatched (no sort applied).
  35153. * @param subMeshes The submeshes to render
  35154. */
  35155. private static renderUnsorted;
  35156. /**
  35157. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  35158. * are rendered back to front if in the same alpha index.
  35159. *
  35160. * @param a The first submesh
  35161. * @param b The second submesh
  35162. * @returns The result of the comparison
  35163. */
  35164. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  35165. /**
  35166. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  35167. * are rendered back to front.
  35168. *
  35169. * @param a The first submesh
  35170. * @param b The second submesh
  35171. * @returns The result of the comparison
  35172. */
  35173. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  35174. /**
  35175. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  35176. * are rendered front to back (prevent overdraw).
  35177. *
  35178. * @param a The first submesh
  35179. * @param b The second submesh
  35180. * @returns The result of the comparison
  35181. */
  35182. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  35183. /**
  35184. * Resets the different lists of submeshes to prepare a new frame.
  35185. */
  35186. prepare(): void;
  35187. dispose(): void;
  35188. /**
  35189. * Inserts the submesh in its correct queue depending on its material.
  35190. * @param subMesh The submesh to dispatch
  35191. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  35192. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  35193. */
  35194. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  35195. dispatchSprites(spriteManager: ISpriteManager): void;
  35196. dispatchParticles(particleSystem: IParticleSystem): void;
  35197. private _renderParticles;
  35198. private _renderSprites;
  35199. }
  35200. }
  35201. declare module BABYLON {
  35202. /**
  35203. * Interface describing the different options available in the rendering manager
  35204. * regarding Auto Clear between groups.
  35205. */
  35206. interface IRenderingManagerAutoClearSetup {
  35207. /**
  35208. * Defines whether or not autoclear is enable.
  35209. */
  35210. autoClear: boolean;
  35211. /**
  35212. * Defines whether or not to autoclear the depth buffer.
  35213. */
  35214. depth: boolean;
  35215. /**
  35216. * Defines whether or not to autoclear the stencil buffer.
  35217. */
  35218. stencil: boolean;
  35219. }
  35220. /**
  35221. * This is the manager responsible of all the rendering for meshes sprites and particles.
  35222. * It is enable to manage the different groups as well as the different necessary sort functions.
  35223. * This should not be used directly aside of the few static configurations
  35224. */
  35225. class RenderingManager {
  35226. /**
  35227. * The max id used for rendering groups (not included)
  35228. */
  35229. static MAX_RENDERINGGROUPS: number;
  35230. /**
  35231. * The min id used for rendering groups (included)
  35232. */
  35233. static MIN_RENDERINGGROUPS: number;
  35234. /**
  35235. * Used to globally prevent autoclearing scenes.
  35236. */
  35237. static AUTOCLEAR: boolean;
  35238. /**
  35239. * @hidden
  35240. */
  35241. _useSceneAutoClearSetup: boolean;
  35242. private _scene;
  35243. private _renderingGroups;
  35244. private _depthStencilBufferAlreadyCleaned;
  35245. private _autoClearDepthStencil;
  35246. private _customOpaqueSortCompareFn;
  35247. private _customAlphaTestSortCompareFn;
  35248. private _customTransparentSortCompareFn;
  35249. private _renderingGroupInfo;
  35250. /**
  35251. * Instantiates a new rendering group for a particular scene
  35252. * @param scene Defines the scene the groups belongs to
  35253. */
  35254. constructor(scene: Scene);
  35255. private _clearDepthStencilBuffer;
  35256. /**
  35257. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  35258. * @hidden
  35259. */
  35260. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  35261. /**
  35262. * Resets the different information of the group to prepare a new frame
  35263. * @hidden
  35264. */
  35265. reset(): void;
  35266. /**
  35267. * Dispose and release the group and its associated resources.
  35268. * @hidden
  35269. */
  35270. dispose(): void;
  35271. /**
  35272. * Clear the info related to rendering groups preventing retention points during dispose.
  35273. */
  35274. freeRenderingGroups(): void;
  35275. private _prepareRenderingGroup;
  35276. /**
  35277. * Add a sprite manager to the rendering manager in order to render it this frame.
  35278. * @param spriteManager Define the sprite manager to render
  35279. */
  35280. dispatchSprites(spriteManager: ISpriteManager): void;
  35281. /**
  35282. * Add a particle system to the rendering manager in order to render it this frame.
  35283. * @param particleSystem Define the particle system to render
  35284. */
  35285. dispatchParticles(particleSystem: IParticleSystem): void;
  35286. /**
  35287. * Add a submesh to the manager in order to render it this frame
  35288. * @param subMesh The submesh to dispatch
  35289. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  35290. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  35291. */
  35292. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  35293. /**
  35294. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  35295. * This allowed control for front to back rendering or reversly depending of the special needs.
  35296. *
  35297. * @param renderingGroupId The rendering group id corresponding to its index
  35298. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  35299. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  35300. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  35301. */
  35302. 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;
  35303. /**
  35304. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  35305. *
  35306. * @param renderingGroupId The rendering group id corresponding to its index
  35307. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  35308. * @param depth Automatically clears depth between groups if true and autoClear is true.
  35309. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  35310. */
  35311. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  35312. /**
  35313. * Gets the current auto clear configuration for one rendering group of the rendering
  35314. * manager.
  35315. * @param index the rendering group index to get the information for
  35316. * @returns The auto clear setup for the requested rendering group
  35317. */
  35318. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  35319. }
  35320. }
  35321. declare module BABYLON {
  35322. /**
  35323. * Renders a layer on top of an existing scene
  35324. */
  35325. class UtilityLayerRenderer implements IDisposable {
  35326. /** the original scene that will be rendered on top of */
  35327. originalScene: Scene;
  35328. private _pointerCaptures;
  35329. private _lastPointerEvents;
  35330. private static _DefaultUtilityLayer;
  35331. private static _DefaultKeepDepthUtilityLayer;
  35332. /**
  35333. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  35334. */
  35335. pickUtilitySceneFirst: boolean;
  35336. /**
  35337. * 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)
  35338. */
  35339. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  35340. /**
  35341. * 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)
  35342. */
  35343. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  35344. /**
  35345. * The scene that is rendered on top of the original scene
  35346. */
  35347. utilityLayerScene: Scene;
  35348. /**
  35349. * If the utility layer should automatically be rendered on top of existing scene
  35350. */
  35351. shouldRender: boolean;
  35352. /**
  35353. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  35354. */
  35355. onlyCheckPointerDownEvents: boolean;
  35356. /**
  35357. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  35358. */
  35359. processAllEvents: boolean;
  35360. /**
  35361. * Observable raised when the pointer move from the utility layer scene to the main scene
  35362. */
  35363. onPointerOutObservable: Observable<number>;
  35364. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  35365. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  35366. private _afterRenderObserver;
  35367. private _sceneDisposeObserver;
  35368. private _originalPointerObserver;
  35369. /**
  35370. * Instantiates a UtilityLayerRenderer
  35371. * @param originalScene the original scene that will be rendered on top of
  35372. * @param handleEvents boolean indicating if the utility layer should handle events
  35373. */
  35374. constructor(
  35375. /** the original scene that will be rendered on top of */
  35376. originalScene: Scene, handleEvents?: boolean);
  35377. private _notifyObservers;
  35378. /**
  35379. * Renders the utility layers scene on top of the original scene
  35380. */
  35381. render(): void;
  35382. /**
  35383. * Disposes of the renderer
  35384. */
  35385. dispose(): void;
  35386. private _updateCamera;
  35387. }
  35388. }
  35389. declare module BABYLON {
  35390. /**
  35391. * Postprocess used to generate anaglyphic rendering
  35392. */
  35393. class AnaglyphPostProcess extends PostProcess {
  35394. private _passedProcess;
  35395. /**
  35396. * Creates a new AnaglyphPostProcess
  35397. * @param name defines postprocess name
  35398. * @param options defines creation options or target ratio scale
  35399. * @param rigCameras defines cameras using this postprocess
  35400. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  35401. * @param engine defines hosting engine
  35402. * @param reusable defines if the postprocess will be reused multiple times per frame
  35403. */
  35404. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  35405. }
  35406. }
  35407. declare module BABYLON {
  35408. /**
  35409. * Post process used to render in black and white
  35410. */
  35411. class BlackAndWhitePostProcess extends PostProcess {
  35412. /**
  35413. * Linear about to convert he result to black and white (default: 1)
  35414. */
  35415. degree: number;
  35416. /**
  35417. * Creates a black and white post process
  35418. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  35419. * @param name The name of the effect.
  35420. * @param options The required width/height ratio to downsize to before computing the render pass.
  35421. * @param camera The camera to apply the render pass to.
  35422. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35423. * @param engine The engine which the post process will be applied. (default: current engine)
  35424. * @param reusable If the post process can be reused on the same frame. (default: false)
  35425. */
  35426. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  35427. }
  35428. }
  35429. declare module BABYLON {
  35430. /**
  35431. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  35432. */
  35433. class BloomEffect extends PostProcessRenderEffect {
  35434. private bloomScale;
  35435. /**
  35436. * @hidden Internal
  35437. */
  35438. _effects: Array<PostProcess>;
  35439. /**
  35440. * @hidden Internal
  35441. */
  35442. _downscale: ExtractHighlightsPostProcess;
  35443. private _blurX;
  35444. private _blurY;
  35445. private _merge;
  35446. /**
  35447. * The luminance threshold to find bright areas of the image to bloom.
  35448. */
  35449. threshold: number;
  35450. /**
  35451. * The strength of the bloom.
  35452. */
  35453. weight: number;
  35454. /**
  35455. * Specifies the size of the bloom blur kernel, relative to the final output size
  35456. */
  35457. kernel: number;
  35458. /**
  35459. * Creates a new instance of @see BloomEffect
  35460. * @param scene The scene the effect belongs to.
  35461. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  35462. * @param bloomKernel The size of the kernel to be used when applying the blur.
  35463. * @param bloomWeight The the strength of bloom.
  35464. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  35465. * @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)
  35466. */
  35467. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  35468. /**
  35469. * Disposes each of the internal effects for a given camera.
  35470. * @param camera The camera to dispose the effect on.
  35471. */
  35472. disposeEffects(camera: Camera): void;
  35473. /**
  35474. * @hidden Internal
  35475. */
  35476. _updateEffects(): void;
  35477. /**
  35478. * Internal
  35479. * @returns if all the contained post processes are ready.
  35480. * @hidden
  35481. */
  35482. _isReady(): boolean;
  35483. }
  35484. }
  35485. declare module BABYLON {
  35486. /**
  35487. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  35488. */
  35489. class BloomMergePostProcess extends PostProcess {
  35490. /** Weight of the bloom to be added to the original input. */
  35491. weight: number;
  35492. /**
  35493. * Creates a new instance of @see BloomMergePostProcess
  35494. * @param name The name of the effect.
  35495. * @param originalFromInput Post process which's input will be used for the merge.
  35496. * @param blurred Blurred highlights post process which's output will be used.
  35497. * @param weight Weight of the bloom to be added to the original input.
  35498. * @param options The required width/height ratio to downsize to before computing the render pass.
  35499. * @param camera The camera to apply the render pass to.
  35500. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35501. * @param engine The engine which the post process will be applied. (default: current engine)
  35502. * @param reusable If the post process can be reused on the same frame. (default: false)
  35503. * @param textureType Type of textures used when performing the post process. (default: 0)
  35504. * @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)
  35505. */
  35506. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  35507. /** Weight of the bloom to be added to the original input. */
  35508. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  35509. }
  35510. }
  35511. declare module BABYLON {
  35512. /**
  35513. * The Blur Post Process which blurs an image based on a kernel and direction.
  35514. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  35515. */
  35516. class BlurPostProcess extends PostProcess {
  35517. /** The direction in which to blur the image. */
  35518. direction: Vector2;
  35519. private blockCompilation;
  35520. protected _kernel: number;
  35521. protected _idealKernel: number;
  35522. protected _packedFloat: boolean;
  35523. private _staticDefines;
  35524. /**
  35525. * Sets the length in pixels of the blur sample region
  35526. */
  35527. /**
  35528. * Gets the length in pixels of the blur sample region
  35529. */
  35530. kernel: number;
  35531. /**
  35532. * Sets wether or not the blur needs to unpack/repack floats
  35533. */
  35534. /**
  35535. * Gets wether or not the blur is unpacking/repacking floats
  35536. */
  35537. packedFloat: boolean;
  35538. /**
  35539. * Creates a new instance BlurPostProcess
  35540. * @param name The name of the effect.
  35541. * @param direction The direction in which to blur the image.
  35542. * @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.
  35543. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  35544. * @param camera The camera to apply the render pass to.
  35545. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35546. * @param engine The engine which the post process will be applied. (default: current engine)
  35547. * @param reusable If the post process can be reused on the same frame. (default: false)
  35548. * @param textureType Type of textures used when performing the post process. (default: 0)
  35549. * @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)
  35550. */
  35551. constructor(name: string,
  35552. /** The direction in which to blur the image. */
  35553. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  35554. /**
  35555. * Updates the effect with the current post process compile time values and recompiles the shader.
  35556. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  35557. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  35558. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  35559. * @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
  35560. * @param onCompiled Called when the shader has been compiled.
  35561. * @param onError Called if there is an error when compiling a shader.
  35562. */
  35563. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  35564. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  35565. /**
  35566. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  35567. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  35568. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  35569. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  35570. * The gaps between physical kernels are compensated for in the weighting of the samples
  35571. * @param idealKernel Ideal blur kernel.
  35572. * @return Nearest best kernel.
  35573. */
  35574. protected _nearestBestKernel(idealKernel: number): number;
  35575. /**
  35576. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  35577. * @param x The point on the Gaussian distribution to sample.
  35578. * @return the value of the Gaussian function at x.
  35579. */
  35580. protected _gaussianWeight(x: number): number;
  35581. /**
  35582. * Generates a string that can be used as a floating point number in GLSL.
  35583. * @param x Value to print.
  35584. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  35585. * @return GLSL float string.
  35586. */
  35587. protected _glslFloat(x: number, decimalFigures?: number): string;
  35588. }
  35589. }
  35590. declare module BABYLON {
  35591. /**
  35592. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  35593. */
  35594. class ChromaticAberrationPostProcess extends PostProcess {
  35595. /**
  35596. * The amount of seperation of rgb channels (default: 30)
  35597. */
  35598. aberrationAmount: number;
  35599. /**
  35600. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  35601. */
  35602. radialIntensity: number;
  35603. /**
  35604. * 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))
  35605. */
  35606. direction: Vector2;
  35607. /**
  35608. * 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))
  35609. */
  35610. centerPosition: Vector2;
  35611. /**
  35612. * Creates a new instance ChromaticAberrationPostProcess
  35613. * @param name The name of the effect.
  35614. * @param screenWidth The width of the screen to apply the effect on.
  35615. * @param screenHeight The height of the screen to apply the effect on.
  35616. * @param options The required width/height ratio to downsize to before computing the render pass.
  35617. * @param camera The camera to apply the render pass to.
  35618. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35619. * @param engine The engine which the post process will be applied. (default: current engine)
  35620. * @param reusable If the post process can be reused on the same frame. (default: false)
  35621. * @param textureType Type of textures used when performing the post process. (default: 0)
  35622. * @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)
  35623. */
  35624. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  35625. }
  35626. }
  35627. declare module BABYLON {
  35628. /**
  35629. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  35630. */
  35631. class CircleOfConfusionPostProcess extends PostProcess {
  35632. /**
  35633. * 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.
  35634. */
  35635. lensSize: number;
  35636. /**
  35637. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  35638. */
  35639. fStop: number;
  35640. /**
  35641. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  35642. */
  35643. focusDistance: number;
  35644. /**
  35645. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  35646. */
  35647. focalLength: number;
  35648. private _depthTexture;
  35649. /**
  35650. * Creates a new instance CircleOfConfusionPostProcess
  35651. * @param name The name of the effect.
  35652. * @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.
  35653. * @param options The required width/height ratio to downsize to before computing the render pass.
  35654. * @param camera The camera to apply the render pass to.
  35655. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35656. * @param engine The engine which the post process will be applied. (default: current engine)
  35657. * @param reusable If the post process can be reused on the same frame. (default: false)
  35658. * @param textureType Type of textures used when performing the post process. (default: 0)
  35659. * @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)
  35660. */
  35661. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  35662. /**
  35663. * 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.
  35664. */
  35665. depthTexture: RenderTargetTexture;
  35666. }
  35667. }
  35668. declare module BABYLON {
  35669. /**
  35670. *
  35671. * This post-process allows the modification of rendered colors by using
  35672. * a 'look-up table' (LUT). This effect is also called Color Grading.
  35673. *
  35674. * The object needs to be provided an url to a texture containing the color
  35675. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  35676. * Use an image editing software to tweak the LUT to match your needs.
  35677. *
  35678. * For an example of a color LUT, see here:
  35679. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  35680. * For explanations on color grading, see here:
  35681. * @see http://udn.epicgames.com/Three/ColorGrading.html
  35682. *
  35683. */
  35684. class ColorCorrectionPostProcess extends PostProcess {
  35685. private _colorTableTexture;
  35686. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  35687. }
  35688. }
  35689. declare module BABYLON {
  35690. /**
  35691. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  35692. * input texture to perform effects such as edge detection or sharpening
  35693. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  35694. */
  35695. class ConvolutionPostProcess extends PostProcess {
  35696. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  35697. kernel: number[];
  35698. /**
  35699. * Creates a new instance ConvolutionPostProcess
  35700. * @param name The name of the effect.
  35701. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  35702. * @param options The required width/height ratio to downsize to before computing the render pass.
  35703. * @param camera The camera to apply the render pass to.
  35704. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35705. * @param engine The engine which the post process will be applied. (default: current engine)
  35706. * @param reusable If the post process can be reused on the same frame. (default: false)
  35707. * @param textureType Type of textures used when performing the post process. (default: 0)
  35708. */
  35709. constructor(name: string,
  35710. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  35711. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  35712. /**
  35713. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  35714. */
  35715. static EdgeDetect0Kernel: number[];
  35716. /**
  35717. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  35718. */
  35719. static EdgeDetect1Kernel: number[];
  35720. /**
  35721. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  35722. */
  35723. static EdgeDetect2Kernel: number[];
  35724. /**
  35725. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  35726. */
  35727. static SharpenKernel: number[];
  35728. /**
  35729. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  35730. */
  35731. static EmbossKernel: number[];
  35732. /**
  35733. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  35734. */
  35735. static GaussianKernel: number[];
  35736. }
  35737. }
  35738. declare module BABYLON {
  35739. /**
  35740. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  35741. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  35742. * based on samples that have a large difference in distance than the center pixel.
  35743. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  35744. */
  35745. class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  35746. direction: Vector2;
  35747. /**
  35748. * Creates a new instance CircleOfConfusionPostProcess
  35749. * @param name The name of the effect.
  35750. * @param scene The scene the effect belongs to.
  35751. * @param direction The direction the blur should be applied.
  35752. * @param kernel The size of the kernel used to blur.
  35753. * @param options The required width/height ratio to downsize to before computing the render pass.
  35754. * @param camera The camera to apply the render pass to.
  35755. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  35756. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  35757. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35758. * @param engine The engine which the post process will be applied. (default: current engine)
  35759. * @param reusable If the post process can be reused on the same frame. (default: false)
  35760. * @param textureType Type of textures used when performing the post process. (default: 0)
  35761. * @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)
  35762. */
  35763. 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);
  35764. }
  35765. }
  35766. declare module BABYLON {
  35767. /**
  35768. * Specifies the level of max blur that should be applied when using the depth of field effect
  35769. */
  35770. enum DepthOfFieldEffectBlurLevel {
  35771. /**
  35772. * Subtle blur
  35773. */
  35774. Low = 0,
  35775. /**
  35776. * Medium blur
  35777. */
  35778. Medium = 1,
  35779. /**
  35780. * Large blur
  35781. */
  35782. High = 2
  35783. }
  35784. /**
  35785. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  35786. */
  35787. class DepthOfFieldEffect extends PostProcessRenderEffect {
  35788. private _circleOfConfusion;
  35789. /**
  35790. * @hidden Internal, blurs from high to low
  35791. */
  35792. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  35793. private _depthOfFieldBlurY;
  35794. private _dofMerge;
  35795. /**
  35796. * @hidden Internal post processes in depth of field effect
  35797. */
  35798. _effects: Array<PostProcess>;
  35799. /**
  35800. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  35801. */
  35802. focalLength: number;
  35803. /**
  35804. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  35805. */
  35806. fStop: number;
  35807. /**
  35808. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  35809. */
  35810. focusDistance: number;
  35811. /**
  35812. * 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.
  35813. */
  35814. lensSize: number;
  35815. /**
  35816. * Creates a new instance DepthOfFieldEffect
  35817. * @param scene The scene the effect belongs to.
  35818. * @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.
  35819. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  35820. * @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)
  35821. */
  35822. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  35823. /**
  35824. * 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.
  35825. */
  35826. depthTexture: RenderTargetTexture;
  35827. /**
  35828. * Disposes each of the internal effects for a given camera.
  35829. * @param camera The camera to dispose the effect on.
  35830. */
  35831. disposeEffects(camera: Camera): void;
  35832. /**
  35833. * @hidden Internal
  35834. */
  35835. _updateEffects(): void;
  35836. /**
  35837. * Internal
  35838. * @returns if all the contained post processes are ready.
  35839. * @hidden
  35840. */
  35841. _isReady(): boolean;
  35842. }
  35843. }
  35844. declare module BABYLON {
  35845. /**
  35846. * Options to be set when merging outputs from the default pipeline.
  35847. */
  35848. class DepthOfFieldMergePostProcessOptions {
  35849. /**
  35850. * The original image to merge on top of
  35851. */
  35852. originalFromInput: PostProcess;
  35853. /**
  35854. * Parameters to perform the merge of the depth of field effect
  35855. */
  35856. depthOfField?: {
  35857. circleOfConfusion: PostProcess;
  35858. blurSteps: Array<PostProcess>;
  35859. };
  35860. /**
  35861. * Parameters to perform the merge of bloom effect
  35862. */
  35863. bloom?: {
  35864. blurred: PostProcess;
  35865. weight: number;
  35866. };
  35867. }
  35868. /**
  35869. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  35870. */
  35871. class DepthOfFieldMergePostProcess extends PostProcess {
  35872. private blurSteps;
  35873. /**
  35874. * Creates a new instance of DepthOfFieldMergePostProcess
  35875. * @param name The name of the effect.
  35876. * @param originalFromInput Post process which's input will be used for the merge.
  35877. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  35878. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  35879. * @param options The required width/height ratio to downsize to before computing the render pass.
  35880. * @param camera The camera to apply the render pass to.
  35881. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35882. * @param engine The engine which the post process will be applied. (default: current engine)
  35883. * @param reusable If the post process can be reused on the same frame. (default: false)
  35884. * @param textureType Type of textures used when performing the post process. (default: 0)
  35885. * @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)
  35886. */
  35887. 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);
  35888. /**
  35889. * Updates the effect with the current post process compile time values and recompiles the shader.
  35890. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  35891. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  35892. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  35893. * @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
  35894. * @param onCompiled Called when the shader has been compiled.
  35895. * @param onError Called if there is an error when compiling a shader.
  35896. */
  35897. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  35898. }
  35899. }
  35900. declare module BABYLON {
  35901. /**
  35902. * DisplayPassPostProcess which produces an output the same as it's input
  35903. */
  35904. class DisplayPassPostProcess extends PostProcess {
  35905. /**
  35906. * Creates the DisplayPassPostProcess
  35907. * @param name The name of the effect.
  35908. * @param options The required width/height ratio to downsize to before computing the render pass.
  35909. * @param camera The camera to apply the render pass to.
  35910. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35911. * @param engine The engine which the post process will be applied. (default: current engine)
  35912. * @param reusable If the post process can be reused on the same frame. (default: false)
  35913. */
  35914. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  35915. }
  35916. }
  35917. declare module BABYLON {
  35918. /**
  35919. * 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.
  35920. */
  35921. class ExtractHighlightsPostProcess extends PostProcess {
  35922. /**
  35923. * The luminance threshold, pixels below this value will be set to black.
  35924. */
  35925. threshold: number;
  35926. /** @hidden */
  35927. _exposure: number;
  35928. /**
  35929. * Post process which has the input texture to be used when performing highlight extraction
  35930. * @hidden
  35931. */
  35932. _inputPostProcess: Nullable<PostProcess>;
  35933. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  35934. }
  35935. }
  35936. declare module BABYLON {
  35937. /**
  35938. * Applies a kernel filter to the image
  35939. */
  35940. class FilterPostProcess extends PostProcess {
  35941. /** The matrix to be applied to the image */
  35942. kernelMatrix: Matrix;
  35943. /**
  35944. *
  35945. * @param name The name of the effect.
  35946. * @param kernelMatrix The matrix to be applied to the image
  35947. * @param options The required width/height ratio to downsize to before computing the render pass.
  35948. * @param camera The camera to apply the render pass to.
  35949. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35950. * @param engine The engine which the post process will be applied. (default: current engine)
  35951. * @param reusable If the post process can be reused on the same frame. (default: false)
  35952. */
  35953. constructor(name: string,
  35954. /** The matrix to be applied to the image */
  35955. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  35956. }
  35957. }
  35958. declare module BABYLON {
  35959. /**
  35960. * Fxaa post process
  35961. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  35962. */
  35963. class FxaaPostProcess extends PostProcess {
  35964. /** @hidden */
  35965. texelWidth: number;
  35966. /** @hidden */
  35967. texelHeight: number;
  35968. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  35969. private _getDefines;
  35970. }
  35971. }
  35972. declare module BABYLON {
  35973. /**
  35974. * The GrainPostProcess adds noise to the image at mid luminance levels
  35975. */
  35976. class GrainPostProcess extends PostProcess {
  35977. /**
  35978. * The intensity of the grain added (default: 30)
  35979. */
  35980. intensity: number;
  35981. /**
  35982. * If the grain should be randomized on every frame
  35983. */
  35984. animated: boolean;
  35985. /**
  35986. * Creates a new instance of @see GrainPostProcess
  35987. * @param name The name of the effect.
  35988. * @param options The required width/height ratio to downsize to before computing the render pass.
  35989. * @param camera The camera to apply the render pass to.
  35990. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35991. * @param engine The engine which the post process will be applied. (default: current engine)
  35992. * @param reusable If the post process can be reused on the same frame. (default: false)
  35993. * @param textureType Type of textures used when performing the post process. (default: 0)
  35994. * @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)
  35995. */
  35996. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  35997. }
  35998. }
  35999. declare module BABYLON {
  36000. /**
  36001. * Extracts highlights from the image
  36002. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  36003. */
  36004. class HighlightsPostProcess extends PostProcess {
  36005. /**
  36006. * Extracts highlights from the image
  36007. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  36008. * @param name The name of the effect.
  36009. * @param options The required width/height ratio to downsize to before computing the render pass.
  36010. * @param camera The camera to apply the render pass to.
  36011. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36012. * @param engine The engine which the post process will be applied. (default: current engine)
  36013. * @param reusable If the post process can be reused on the same frame. (default: false)
  36014. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  36015. */
  36016. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  36017. }
  36018. }
  36019. declare module BABYLON {
  36020. /**
  36021. * ImageProcessingPostProcess
  36022. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  36023. */
  36024. class ImageProcessingPostProcess extends PostProcess {
  36025. /**
  36026. * Default configuration related to image processing available in the PBR Material.
  36027. */
  36028. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  36029. /**
  36030. * Gets the image processing configuration used either in this material.
  36031. */
  36032. /**
  36033. * Sets the Default image processing configuration used either in the this material.
  36034. *
  36035. * If sets to null, the scene one is in use.
  36036. */
  36037. imageProcessingConfiguration: ImageProcessingConfiguration;
  36038. /**
  36039. * Keep track of the image processing observer to allow dispose and replace.
  36040. */
  36041. private _imageProcessingObserver;
  36042. /**
  36043. * Attaches a new image processing configuration to the PBR Material.
  36044. * @param configuration
  36045. */
  36046. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  36047. /**
  36048. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  36049. */
  36050. /**
  36051. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  36052. */
  36053. colorCurves: Nullable<ColorCurves>;
  36054. /**
  36055. * Gets wether the color curves effect is enabled.
  36056. */
  36057. /**
  36058. * Sets wether the color curves effect is enabled.
  36059. */
  36060. colorCurvesEnabled: boolean;
  36061. /**
  36062. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  36063. */
  36064. /**
  36065. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  36066. */
  36067. colorGradingTexture: Nullable<BaseTexture>;
  36068. /**
  36069. * Gets wether the color grading effect is enabled.
  36070. */
  36071. /**
  36072. * Gets wether the color grading effect is enabled.
  36073. */
  36074. colorGradingEnabled: boolean;
  36075. /**
  36076. * Gets exposure used in the effect.
  36077. */
  36078. /**
  36079. * Sets exposure used in the effect.
  36080. */
  36081. exposure: number;
  36082. /**
  36083. * Gets wether tonemapping is enabled or not.
  36084. */
  36085. /**
  36086. * Sets wether tonemapping is enabled or not
  36087. */
  36088. toneMappingEnabled: boolean;
  36089. /**
  36090. * Gets contrast used in the effect.
  36091. */
  36092. /**
  36093. * Sets contrast used in the effect.
  36094. */
  36095. contrast: number;
  36096. /**
  36097. * Gets Vignette stretch size.
  36098. */
  36099. /**
  36100. * Sets Vignette stretch size.
  36101. */
  36102. vignetteStretch: number;
  36103. /**
  36104. * Gets Vignette centre X Offset.
  36105. */
  36106. /**
  36107. * Sets Vignette centre X Offset.
  36108. */
  36109. vignetteCentreX: number;
  36110. /**
  36111. * Gets Vignette centre Y Offset.
  36112. */
  36113. /**
  36114. * Sets Vignette centre Y Offset.
  36115. */
  36116. vignetteCentreY: number;
  36117. /**
  36118. * Gets Vignette weight or intensity of the vignette effect.
  36119. */
  36120. /**
  36121. * Sets Vignette weight or intensity of the vignette effect.
  36122. */
  36123. vignetteWeight: number;
  36124. /**
  36125. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  36126. * if vignetteEnabled is set to true.
  36127. */
  36128. /**
  36129. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  36130. * if vignetteEnabled is set to true.
  36131. */
  36132. vignetteColor: Color4;
  36133. /**
  36134. * Gets Camera field of view used by the Vignette effect.
  36135. */
  36136. /**
  36137. * Sets Camera field of view used by the Vignette effect.
  36138. */
  36139. vignetteCameraFov: number;
  36140. /**
  36141. * Gets the vignette blend mode allowing different kind of effect.
  36142. */
  36143. /**
  36144. * Sets the vignette blend mode allowing different kind of effect.
  36145. */
  36146. vignetteBlendMode: number;
  36147. /**
  36148. * Gets wether the vignette effect is enabled.
  36149. */
  36150. /**
  36151. * Sets wether the vignette effect is enabled.
  36152. */
  36153. vignetteEnabled: boolean;
  36154. private _fromLinearSpace;
  36155. /**
  36156. * Gets wether the input of the processing is in Gamma or Linear Space.
  36157. */
  36158. /**
  36159. * Sets wether the input of the processing is in Gamma or Linear Space.
  36160. */
  36161. fromLinearSpace: boolean;
  36162. /**
  36163. * Defines cache preventing GC.
  36164. */
  36165. private _defines;
  36166. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  36167. /**
  36168. * "ImageProcessingPostProcess"
  36169. * @returns "ImageProcessingPostProcess"
  36170. */
  36171. getClassName(): string;
  36172. protected _updateParameters(): void;
  36173. dispose(camera?: Camera): void;
  36174. }
  36175. }
  36176. declare module BABYLON {
  36177. /**
  36178. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  36179. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  36180. * As an example, all you have to do is to create the post-process:
  36181. * var mb = new BABYLON.MotionBlurPostProcess(
  36182. * 'mb', // The name of the effect.
  36183. * scene, // The scene containing the objects to blur according to their velocity.
  36184. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  36185. * camera // The camera to apply the render pass to.
  36186. * );
  36187. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  36188. */
  36189. class MotionBlurPostProcess extends PostProcess {
  36190. /**
  36191. * Defines how much the image is blurred by the movement. Default value is equal to 1
  36192. */
  36193. motionStrength: number;
  36194. /**
  36195. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  36196. */
  36197. /**
  36198. * Sets the number of iterations to be used for motion blur quality
  36199. */
  36200. motionBlurSamples: number;
  36201. private _motionBlurSamples;
  36202. private _geometryBufferRenderer;
  36203. /**
  36204. * Creates a new instance MotionBlurPostProcess
  36205. * @param name The name of the effect.
  36206. * @param scene The scene containing the objects to blur according to their velocity.
  36207. * @param options The required width/height ratio to downsize to before computing the render pass.
  36208. * @param camera The camera to apply the render pass to.
  36209. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36210. * @param engine The engine which the post process will be applied. (default: current engine)
  36211. * @param reusable If the post process can be reused on the same frame. (default: false)
  36212. * @param textureType Type of textures used when performing the post process. (default: 0)
  36213. * @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)
  36214. */
  36215. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  36216. /**
  36217. * Disposes the post process.
  36218. * @param camera The camera to dispose the post process on.
  36219. */
  36220. dispose(camera?: Camera): void;
  36221. }
  36222. }
  36223. declare module BABYLON {
  36224. /**
  36225. * PassPostProcess which produces an output the same as it's input
  36226. */
  36227. class PassPostProcess extends PostProcess {
  36228. /**
  36229. * Creates the PassPostProcess
  36230. * @param name The name of the effect.
  36231. * @param options The required width/height ratio to downsize to before computing the render pass.
  36232. * @param camera The camera to apply the render pass to.
  36233. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36234. * @param engine The engine which the post process will be applied. (default: current engine)
  36235. * @param reusable If the post process can be reused on the same frame. (default: false)
  36236. * @param textureType The type of texture to be used when performing the post processing.
  36237. * @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)
  36238. */
  36239. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  36240. }
  36241. /**
  36242. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  36243. */
  36244. class PassCubePostProcess extends PostProcess {
  36245. private _face;
  36246. /**
  36247. * Gets or sets the cube face to display.
  36248. * * 0 is +X
  36249. * * 1 is -X
  36250. * * 2 is +Y
  36251. * * 3 is -Y
  36252. * * 4 is +Z
  36253. * * 5 is -Z
  36254. */
  36255. face: number;
  36256. /**
  36257. * Creates the PassCubePostProcess
  36258. * @param name The name of the effect.
  36259. * @param options The required width/height ratio to downsize to before computing the render pass.
  36260. * @param camera The camera to apply the render pass to.
  36261. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36262. * @param engine The engine which the post process will be applied. (default: current engine)
  36263. * @param reusable If the post process can be reused on the same frame. (default: false)
  36264. * @param textureType The type of texture to be used when performing the post processing.
  36265. * @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)
  36266. */
  36267. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  36268. }
  36269. }
  36270. declare module BABYLON {
  36271. /**
  36272. * Size options for a post process
  36273. */
  36274. type PostProcessOptions = {
  36275. width: number;
  36276. height: number;
  36277. };
  36278. /**
  36279. * PostProcess can be used to apply a shader to a texture after it has been rendered
  36280. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  36281. */
  36282. class PostProcess {
  36283. /** Name of the PostProcess. */
  36284. name: string;
  36285. /**
  36286. * Width of the texture to apply the post process on
  36287. */
  36288. width: number;
  36289. /**
  36290. * Height of the texture to apply the post process on
  36291. */
  36292. height: number;
  36293. /**
  36294. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  36295. * @hidden
  36296. */
  36297. _outputTexture: Nullable<InternalTexture>;
  36298. /**
  36299. * Sampling mode used by the shader
  36300. * See https://doc.babylonjs.com/classes/3.1/texture
  36301. */
  36302. renderTargetSamplingMode: number;
  36303. /**
  36304. * Clear color to use when screen clearing
  36305. */
  36306. clearColor: Color4;
  36307. /**
  36308. * If the buffer needs to be cleared before applying the post process. (default: true)
  36309. * Should be set to false if shader will overwrite all previous pixels.
  36310. */
  36311. autoClear: boolean;
  36312. /**
  36313. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  36314. */
  36315. alphaMode: number;
  36316. /**
  36317. * Sets the setAlphaBlendConstants of the babylon engine
  36318. */
  36319. alphaConstants: Color4;
  36320. /**
  36321. * Animations to be used for the post processing
  36322. */
  36323. animations: Animation[];
  36324. /**
  36325. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  36326. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  36327. */
  36328. enablePixelPerfectMode: boolean;
  36329. /**
  36330. * Force the postprocess to be applied without taking in account viewport
  36331. */
  36332. forceFullscreenViewport: boolean;
  36333. /**
  36334. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  36335. *
  36336. * | Value | Type | Description |
  36337. * | ----- | ----------------------------------- | ----------- |
  36338. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  36339. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  36340. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  36341. *
  36342. */
  36343. scaleMode: number;
  36344. /**
  36345. * Force textures to be a power of two (default: false)
  36346. */
  36347. alwaysForcePOT: boolean;
  36348. private _samples;
  36349. /**
  36350. * Number of sample textures (default: 1)
  36351. */
  36352. samples: number;
  36353. /**
  36354. * Modify the scale of the post process to be the same as the viewport (default: false)
  36355. */
  36356. adaptScaleToCurrentViewport: boolean;
  36357. private _camera;
  36358. private _scene;
  36359. private _engine;
  36360. private _options;
  36361. private _reusable;
  36362. private _textureType;
  36363. /**
  36364. * Smart array of input and output textures for the post process.
  36365. * @hidden
  36366. */
  36367. _textures: SmartArray<InternalTexture>;
  36368. /**
  36369. * The index in _textures that corresponds to the output texture.
  36370. * @hidden
  36371. */
  36372. _currentRenderTextureInd: number;
  36373. private _effect;
  36374. private _samplers;
  36375. private _fragmentUrl;
  36376. private _vertexUrl;
  36377. private _parameters;
  36378. private _scaleRatio;
  36379. protected _indexParameters: any;
  36380. private _shareOutputWithPostProcess;
  36381. private _texelSize;
  36382. private _forcedOutputTexture;
  36383. /**
  36384. * An event triggered when the postprocess is activated.
  36385. */
  36386. onActivateObservable: Observable<Camera>;
  36387. private _onActivateObserver;
  36388. /**
  36389. * A function that is added to the onActivateObservable
  36390. */
  36391. onActivate: Nullable<(camera: Camera) => void>;
  36392. /**
  36393. * An event triggered when the postprocess changes its size.
  36394. */
  36395. onSizeChangedObservable: Observable<PostProcess>;
  36396. private _onSizeChangedObserver;
  36397. /**
  36398. * A function that is added to the onSizeChangedObservable
  36399. */
  36400. onSizeChanged: (postProcess: PostProcess) => void;
  36401. /**
  36402. * An event triggered when the postprocess applies its effect.
  36403. */
  36404. onApplyObservable: Observable<Effect>;
  36405. private _onApplyObserver;
  36406. /**
  36407. * A function that is added to the onApplyObservable
  36408. */
  36409. onApply: (effect: Effect) => void;
  36410. /**
  36411. * An event triggered before rendering the postprocess
  36412. */
  36413. onBeforeRenderObservable: Observable<Effect>;
  36414. private _onBeforeRenderObserver;
  36415. /**
  36416. * A function that is added to the onBeforeRenderObservable
  36417. */
  36418. onBeforeRender: (effect: Effect) => void;
  36419. /**
  36420. * An event triggered after rendering the postprocess
  36421. */
  36422. onAfterRenderObservable: Observable<Effect>;
  36423. private _onAfterRenderObserver;
  36424. /**
  36425. * A function that is added to the onAfterRenderObservable
  36426. */
  36427. onAfterRender: (efect: Effect) => void;
  36428. /**
  36429. * 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
  36430. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  36431. */
  36432. inputTexture: InternalTexture;
  36433. /**
  36434. * Gets the camera which post process is applied to.
  36435. * @returns The camera the post process is applied to.
  36436. */
  36437. getCamera(): Camera;
  36438. /**
  36439. * Gets the texel size of the postprocess.
  36440. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  36441. */
  36442. readonly texelSize: Vector2;
  36443. /**
  36444. * Creates a new instance PostProcess
  36445. * @param name The name of the PostProcess.
  36446. * @param fragmentUrl The url of the fragment shader to be used.
  36447. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  36448. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  36449. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  36450. * @param camera The camera to apply the render pass to.
  36451. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36452. * @param engine The engine which the post process will be applied. (default: current engine)
  36453. * @param reusable If the post process can be reused on the same frame. (default: false)
  36454. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  36455. * @param textureType Type of textures used when performing the post process. (default: 0)
  36456. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  36457. * @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
  36458. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  36459. */
  36460. constructor(
  36461. /** Name of the PostProcess. */
  36462. 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);
  36463. /**
  36464. * Gets the engine which this post process belongs to.
  36465. * @returns The engine the post process was enabled with.
  36466. */
  36467. getEngine(): Engine;
  36468. /**
  36469. * The effect that is created when initializing the post process.
  36470. * @returns The created effect corrisponding the the postprocess.
  36471. */
  36472. getEffect(): Effect;
  36473. /**
  36474. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  36475. * @param postProcess The post process to share the output with.
  36476. * @returns This post process.
  36477. */
  36478. shareOutputWith(postProcess: PostProcess): PostProcess;
  36479. /**
  36480. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  36481. * This should be called if the post process that shares output with this post process is disabled/disposed.
  36482. */
  36483. useOwnOutput(): void;
  36484. /**
  36485. * Updates the effect with the current post process compile time values and recompiles the shader.
  36486. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  36487. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  36488. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  36489. * @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
  36490. * @param onCompiled Called when the shader has been compiled.
  36491. * @param onError Called if there is an error when compiling a shader.
  36492. */
  36493. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  36494. /**
  36495. * The post process is reusable if it can be used multiple times within one frame.
  36496. * @returns If the post process is reusable
  36497. */
  36498. isReusable(): boolean;
  36499. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  36500. markTextureDirty(): void;
  36501. /**
  36502. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  36503. * 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.
  36504. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  36505. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  36506. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  36507. * @returns The target texture that was bound to be written to.
  36508. */
  36509. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  36510. /**
  36511. * If the post process is supported.
  36512. */
  36513. readonly isSupported: boolean;
  36514. /**
  36515. * The aspect ratio of the output texture.
  36516. */
  36517. readonly aspectRatio: number;
  36518. /**
  36519. * Get a value indicating if the post-process is ready to be used
  36520. * @returns true if the post-process is ready (shader is compiled)
  36521. */
  36522. isReady(): boolean;
  36523. /**
  36524. * Binds all textures and uniforms to the shader, this will be run on every pass.
  36525. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  36526. */
  36527. apply(): Nullable<Effect>;
  36528. private _disposeTextures;
  36529. /**
  36530. * Disposes the post process.
  36531. * @param camera The camera to dispose the post process on.
  36532. */
  36533. dispose(camera?: Camera): void;
  36534. }
  36535. }
  36536. declare module BABYLON {
  36537. /**
  36538. * PostProcessManager is used to manage one or more post processes or post process pipelines
  36539. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  36540. */
  36541. class PostProcessManager {
  36542. private _scene;
  36543. private _indexBuffer;
  36544. private _vertexBuffers;
  36545. /**
  36546. * Creates a new instance PostProcess
  36547. * @param scene The scene that the post process is associated with.
  36548. */
  36549. constructor(scene: Scene);
  36550. private _prepareBuffers;
  36551. private _buildIndexBuffer;
  36552. /**
  36553. * Rebuilds the vertex buffers of the manager.
  36554. * @hidden
  36555. */
  36556. _rebuild(): void;
  36557. /**
  36558. * Prepares a frame to be run through a post process.
  36559. * @param sourceTexture The input texture to the post procesess. (default: null)
  36560. * @param postProcesses An array of post processes to be run. (default: null)
  36561. * @returns True if the post processes were able to be run.
  36562. * @hidden
  36563. */
  36564. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  36565. /**
  36566. * Manually render a set of post processes to a texture.
  36567. * @param postProcesses An array of post processes to be run.
  36568. * @param targetTexture The target texture to render to.
  36569. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  36570. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  36571. * @param lodLevel defines which lod of the texture to render to
  36572. */
  36573. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  36574. /**
  36575. * Finalize the result of the output of the postprocesses.
  36576. * @param doNotPresent If true the result will not be displayed to the screen.
  36577. * @param targetTexture The target texture to render to.
  36578. * @param faceIndex The index of the face to bind the target texture to.
  36579. * @param postProcesses The array of post processes to render.
  36580. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  36581. * @hidden
  36582. */
  36583. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  36584. /**
  36585. * Disposes of the post process manager.
  36586. */
  36587. dispose(): void;
  36588. }
  36589. }
  36590. declare module BABYLON {
  36591. /**
  36592. * Post process which applies a refractin texture
  36593. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  36594. */
  36595. class RefractionPostProcess extends PostProcess {
  36596. /** the base color of the refraction (used to taint the rendering) */
  36597. color: Color3;
  36598. /** simulated refraction depth */
  36599. depth: number;
  36600. /** the coefficient of the base color (0 to remove base color tainting) */
  36601. colorLevel: number;
  36602. private _refTexture;
  36603. private _ownRefractionTexture;
  36604. /**
  36605. * Gets or sets the refraction texture
  36606. * Please note that you are responsible for disposing the texture if you set it manually
  36607. */
  36608. refractionTexture: Texture;
  36609. /**
  36610. * Initializes the RefractionPostProcess
  36611. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  36612. * @param name The name of the effect.
  36613. * @param refractionTextureUrl Url of the refraction texture to use
  36614. * @param color the base color of the refraction (used to taint the rendering)
  36615. * @param depth simulated refraction depth
  36616. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  36617. * @param camera The camera to apply the render pass to.
  36618. * @param options The required width/height ratio to downsize to before computing the render pass.
  36619. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36620. * @param engine The engine which the post process will be applied. (default: current engine)
  36621. * @param reusable If the post process can be reused on the same frame. (default: false)
  36622. */
  36623. constructor(name: string, refractionTextureUrl: string,
  36624. /** the base color of the refraction (used to taint the rendering) */
  36625. color: Color3,
  36626. /** simulated refraction depth */
  36627. depth: number,
  36628. /** the coefficient of the base color (0 to remove base color tainting) */
  36629. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  36630. /**
  36631. * Disposes of the post process
  36632. * @param camera Camera to dispose post process on
  36633. */
  36634. dispose(camera: Camera): void;
  36635. }
  36636. }
  36637. declare module BABYLON {
  36638. /**
  36639. * The SharpenPostProcess applies a sharpen kernel to every pixel
  36640. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  36641. */
  36642. class SharpenPostProcess extends PostProcess {
  36643. /**
  36644. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  36645. */
  36646. colorAmount: number;
  36647. /**
  36648. * How much sharpness should be applied (default: 0.3)
  36649. */
  36650. edgeAmount: number;
  36651. /**
  36652. * Creates a new instance ConvolutionPostProcess
  36653. * @param name The name of the effect.
  36654. * @param options The required width/height ratio to downsize to before computing the render pass.
  36655. * @param camera The camera to apply the render pass to.
  36656. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36657. * @param engine The engine which the post process will be applied. (default: current engine)
  36658. * @param reusable If the post process can be reused on the same frame. (default: false)
  36659. * @param textureType Type of textures used when performing the post process. (default: 0)
  36660. * @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)
  36661. */
  36662. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  36663. }
  36664. }
  36665. declare module BABYLON {
  36666. /**
  36667. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  36668. */
  36669. class StereoscopicInterlacePostProcess extends PostProcess {
  36670. private _stepSize;
  36671. private _passedProcess;
  36672. /**
  36673. * Initializes a StereoscopicInterlacePostProcess
  36674. * @param name The name of the effect.
  36675. * @param rigCameras The rig cameras to be appled to the post process
  36676. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  36677. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36678. * @param engine The engine which the post process will be applied. (default: current engine)
  36679. * @param reusable If the post process can be reused on the same frame. (default: false)
  36680. */
  36681. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  36682. }
  36683. }
  36684. declare module BABYLON {
  36685. /** Defines operator used for tonemapping */
  36686. enum TonemappingOperator {
  36687. /** Hable */
  36688. Hable = 0,
  36689. /** Reinhard */
  36690. Reinhard = 1,
  36691. /** HejiDawson */
  36692. HejiDawson = 2,
  36693. /** Photographic */
  36694. Photographic = 3
  36695. }
  36696. /**
  36697. * Defines a post process to apply tone mapping
  36698. */
  36699. class TonemapPostProcess extends PostProcess {
  36700. private _operator;
  36701. /** Defines the required exposure adjustement */
  36702. exposureAdjustment: number;
  36703. /**
  36704. * Creates a new TonemapPostProcess
  36705. * @param name defines the name of the postprocess
  36706. * @param _operator defines the operator to use
  36707. * @param exposureAdjustment defines the required exposure adjustement
  36708. * @param camera defines the camera to use (can be null)
  36709. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  36710. * @param engine defines the hosting engine (can be ignore if camera is set)
  36711. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  36712. */
  36713. constructor(name: string, _operator: TonemappingOperator,
  36714. /** Defines the required exposure adjustement */
  36715. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  36716. }
  36717. }
  36718. declare module BABYLON {
  36719. /**
  36720. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  36721. */
  36722. class VolumetricLightScatteringPostProcess extends PostProcess {
  36723. private _volumetricLightScatteringPass;
  36724. private _volumetricLightScatteringRTT;
  36725. private _viewPort;
  36726. private _screenCoordinates;
  36727. private _cachedDefines;
  36728. /**
  36729. * If not undefined, the mesh position is computed from the attached node position
  36730. */
  36731. attachedNode: {
  36732. position: Vector3;
  36733. };
  36734. /**
  36735. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  36736. */
  36737. customMeshPosition: Vector3;
  36738. /**
  36739. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  36740. */
  36741. useCustomMeshPosition: boolean;
  36742. /**
  36743. * If the post-process should inverse the light scattering direction
  36744. */
  36745. invert: boolean;
  36746. /**
  36747. * The internal mesh used by the post-process
  36748. */
  36749. mesh: Mesh;
  36750. /**
  36751. * @hidden
  36752. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  36753. */
  36754. useDiffuseColor: boolean;
  36755. /**
  36756. * Array containing the excluded meshes not rendered in the internal pass
  36757. */
  36758. excludedMeshes: AbstractMesh[];
  36759. /**
  36760. * Controls the overall intensity of the post-process
  36761. */
  36762. exposure: number;
  36763. /**
  36764. * Dissipates each sample's contribution in range [0, 1]
  36765. */
  36766. decay: number;
  36767. /**
  36768. * Controls the overall intensity of each sample
  36769. */
  36770. weight: number;
  36771. /**
  36772. * Controls the density of each sample
  36773. */
  36774. density: number;
  36775. /**
  36776. * @constructor
  36777. * @param name The post-process name
  36778. * @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)
  36779. * @param camera The camera that the post-process will be attached to
  36780. * @param mesh The mesh used to create the light scattering
  36781. * @param samples The post-process quality, default 100
  36782. * @param samplingModeThe post-process filtering mode
  36783. * @param engine The babylon engine
  36784. * @param reusable If the post-process is reusable
  36785. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  36786. */
  36787. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  36788. /**
  36789. * Returns the string "VolumetricLightScatteringPostProcess"
  36790. * @returns "VolumetricLightScatteringPostProcess"
  36791. */
  36792. getClassName(): string;
  36793. private _isReady;
  36794. /**
  36795. * Sets the new light position for light scattering effect
  36796. * @param position The new custom light position
  36797. */
  36798. setCustomMeshPosition(position: Vector3): void;
  36799. /**
  36800. * Returns the light position for light scattering effect
  36801. * @return Vector3 The custom light position
  36802. */
  36803. getCustomMeshPosition(): Vector3;
  36804. /**
  36805. * Disposes the internal assets and detaches the post-process from the camera
  36806. */
  36807. dispose(camera: Camera): void;
  36808. /**
  36809. * Returns the render target texture used by the post-process
  36810. * @return the render target texture used by the post-process
  36811. */
  36812. getPass(): RenderTargetTexture;
  36813. private _meshExcluded;
  36814. private _createPass;
  36815. private _updateMeshScreenCoordinates;
  36816. /**
  36817. * Creates a default mesh for the Volumeric Light Scattering post-process
  36818. * @param name The mesh name
  36819. * @param scene The scene where to create the mesh
  36820. * @return the default mesh
  36821. */
  36822. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  36823. }
  36824. }
  36825. declare module BABYLON {
  36826. /**
  36827. * VRDistortionCorrectionPostProcess used for mobile VR
  36828. */
  36829. class VRDistortionCorrectionPostProcess extends PostProcess {
  36830. private _isRightEye;
  36831. private _distortionFactors;
  36832. private _postProcessScaleFactor;
  36833. private _lensCenterOffset;
  36834. private _scaleIn;
  36835. private _scaleFactor;
  36836. private _lensCenter;
  36837. /**
  36838. * Initializes the VRDistortionCorrectionPostProcess
  36839. * @param name The name of the effect.
  36840. * @param camera The camera to apply the render pass to.
  36841. * @param isRightEye If this is for the right eye distortion
  36842. * @param vrMetrics All the required metrics for the VR camera
  36843. */
  36844. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  36845. }
  36846. }
  36847. declare module BABYLON {
  36848. /**
  36849. * Class used to represent a sprite
  36850. * @see http://doc.babylonjs.com/babylon101/sprites
  36851. */
  36852. class Sprite {
  36853. /** defines the name */
  36854. name: string;
  36855. /** Gets or sets the current world position */
  36856. position: Vector3;
  36857. /** Gets or sets the main color */
  36858. color: Color4;
  36859. /** Gets or sets the width */
  36860. width: number;
  36861. /** Gets or sets the height */
  36862. height: number;
  36863. /** Gets or sets rotation angle */
  36864. angle: number;
  36865. /** Gets or sets the cell index in the sprite sheet */
  36866. cellIndex: number;
  36867. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  36868. invertU: number;
  36869. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  36870. invertV: number;
  36871. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  36872. disposeWhenFinishedAnimating: boolean;
  36873. /** Gets the list of attached animations */
  36874. animations: Animation[];
  36875. /** Gets or sets a boolean indicating if the sprite can be picked */
  36876. isPickable: boolean;
  36877. /**
  36878. * Gets or sets the associated action manager
  36879. */
  36880. actionManager: Nullable<ActionManager>;
  36881. private _animationStarted;
  36882. private _loopAnimation;
  36883. private _fromIndex;
  36884. private _toIndex;
  36885. private _delay;
  36886. private _direction;
  36887. private _manager;
  36888. private _time;
  36889. private _onAnimationEnd;
  36890. /**
  36891. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  36892. */
  36893. isVisible: boolean;
  36894. /**
  36895. * Gets or sets the sprite size
  36896. */
  36897. size: number;
  36898. /**
  36899. * Creates a new Sprite
  36900. * @param name defines the name
  36901. * @param manager defines the manager
  36902. */
  36903. constructor(
  36904. /** defines the name */
  36905. name: string, manager: ISpriteManager);
  36906. /**
  36907. * Starts an animation
  36908. * @param from defines the initial key
  36909. * @param to defines the end key
  36910. * @param loop defines if the animation must loop
  36911. * @param delay defines the start delay (in ms)
  36912. * @param onAnimationEnd defines a callback to call when animation ends
  36913. */
  36914. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  36915. /** Stops current animation (if any) */
  36916. stopAnimation(): void;
  36917. /** @hidden */
  36918. _animate(deltaTime: number): void;
  36919. /** Release associated resources */
  36920. dispose(): void;
  36921. }
  36922. }
  36923. declare module BABYLON {
  36924. /**
  36925. * Defines the minimum interface to fullfil in order to be a sprite manager.
  36926. */
  36927. interface ISpriteManager extends IDisposable {
  36928. /**
  36929. * Restricts the camera to viewing objects with the same layerMask.
  36930. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  36931. */
  36932. layerMask: number;
  36933. /**
  36934. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  36935. */
  36936. isPickable: boolean;
  36937. /**
  36938. * Specifies the rendering group id for this mesh (0 by default)
  36939. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  36940. */
  36941. renderingGroupId: number;
  36942. /**
  36943. * Defines the list of sprites managed by the manager.
  36944. */
  36945. sprites: Array<Sprite>;
  36946. /**
  36947. * Tests the intersection of a sprite with a specific ray.
  36948. * @param ray The ray we are sending to test the collision
  36949. * @param camera The camera space we are sending rays in
  36950. * @param predicate A predicate allowing excluding sprites from the list of object to test
  36951. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  36952. * @returns picking info or null.
  36953. */
  36954. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  36955. /**
  36956. * Renders the list of sprites on screen.
  36957. */
  36958. render(): void;
  36959. }
  36960. /**
  36961. * Class used to manage multiple sprites on the same spritesheet
  36962. * @see http://doc.babylonjs.com/babylon101/sprites
  36963. */
  36964. class SpriteManager implements ISpriteManager {
  36965. /** defines the manager's name */
  36966. name: string;
  36967. /** Gets the list of sprites */
  36968. sprites: Sprite[];
  36969. /** Gets or sets the rendering group id (0 by default) */
  36970. renderingGroupId: number;
  36971. /** Gets or sets camera layer mask */
  36972. layerMask: number;
  36973. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  36974. fogEnabled: boolean;
  36975. /** Gets or sets a boolean indicating if the sprites are pickable */
  36976. isPickable: boolean;
  36977. /** Defines the default width of a cell in the spritesheet */
  36978. cellWidth: number;
  36979. /** Defines the default height of a cell in the spritesheet */
  36980. cellHeight: number;
  36981. /**
  36982. * An event triggered when the manager is disposed.
  36983. */
  36984. onDisposeObservable: Observable<SpriteManager>;
  36985. private _onDisposeObserver;
  36986. /**
  36987. * Callback called when the manager is disposed
  36988. */
  36989. onDispose: () => void;
  36990. private _capacity;
  36991. private _spriteTexture;
  36992. private _epsilon;
  36993. private _scene;
  36994. private _vertexData;
  36995. private _buffer;
  36996. private _vertexBuffers;
  36997. private _indexBuffer;
  36998. private _effectBase;
  36999. private _effectFog;
  37000. /**
  37001. * Gets or sets the spritesheet texture
  37002. */
  37003. texture: Texture;
  37004. /**
  37005. * Creates a new sprite manager
  37006. * @param name defines the manager's name
  37007. * @param imgUrl defines the sprite sheet url
  37008. * @param capacity defines the maximum allowed number of sprites
  37009. * @param cellSize defines the size of a sprite cell
  37010. * @param scene defines the hosting scene
  37011. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  37012. * @param samplingMode defines the smapling mode to use with spritesheet
  37013. */
  37014. constructor(
  37015. /** defines the manager's name */
  37016. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  37017. private _appendSpriteVertex;
  37018. /**
  37019. * Intersects the sprites with a ray
  37020. * @param ray defines the ray to intersect with
  37021. * @param camera defines the current active camera
  37022. * @param predicate defines a predicate used to select candidate sprites
  37023. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  37024. * @returns null if no hit or a PickingInfo
  37025. */
  37026. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  37027. /**
  37028. * Render all child sprites
  37029. */
  37030. render(): void;
  37031. /**
  37032. * Release associated resources
  37033. */
  37034. dispose(): void;
  37035. }
  37036. }
  37037. declare module BABYLON {
  37038. interface Scene {
  37039. /** @hidden */
  37040. _pointerOverSprite: Nullable<Sprite>;
  37041. /** @hidden */
  37042. _pickedDownSprite: Nullable<Sprite>;
  37043. /** @hidden */
  37044. _tempSpritePickingRay: Nullable<Ray>;
  37045. /**
  37046. * All of the sprite managers added to this scene
  37047. * @see http://doc.babylonjs.com/babylon101/sprites
  37048. */
  37049. spriteManagers: Array<ISpriteManager>;
  37050. /**
  37051. * An event triggered when sprites rendering is about to start
  37052. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  37053. */
  37054. onBeforeSpritesRenderingObservable: Observable<Scene>;
  37055. /**
  37056. * An event triggered when sprites rendering is done
  37057. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  37058. */
  37059. onAfterSpritesRenderingObservable: Observable<Scene>;
  37060. /** @hidden */
  37061. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  37062. /** Launch a ray to try to pick a sprite in the scene
  37063. * @param x position on screen
  37064. * @param y position on screen
  37065. * @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
  37066. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  37067. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37068. * @returns a PickingInfo
  37069. */
  37070. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  37071. /** Use the given ray to pick a sprite in the scene
  37072. * @param ray The ray (in world space) to use to pick meshes
  37073. * @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
  37074. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  37075. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  37076. * @returns a PickingInfo
  37077. */
  37078. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  37079. /**
  37080. * Force the sprite under the pointer
  37081. * @param sprite defines the sprite to use
  37082. */
  37083. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  37084. /**
  37085. * Gets the sprite under the pointer
  37086. * @returns a Sprite or null if no sprite is under the pointer
  37087. */
  37088. getPointerOverSprite(): Nullable<Sprite>;
  37089. }
  37090. /**
  37091. * Defines the sprite scene component responsible to manage sprites
  37092. * in a given scene.
  37093. */
  37094. class SpriteSceneComponent implements ISceneComponent {
  37095. /**
  37096. * The component name helpfull to identify the component in the list of scene components.
  37097. */
  37098. readonly name: string;
  37099. /**
  37100. * The scene the component belongs to.
  37101. */
  37102. scene: Scene;
  37103. /** @hidden */
  37104. private _spritePredicate;
  37105. /**
  37106. * Creates a new instance of the component for the given scene
  37107. * @param scene Defines the scene to register the component in
  37108. */
  37109. constructor(scene: Scene);
  37110. /**
  37111. * Registers the component in a given scene
  37112. */
  37113. register(): void;
  37114. /**
  37115. * Rebuilds the elements related to this component in case of
  37116. * context lost for instance.
  37117. */
  37118. rebuild(): void;
  37119. /**
  37120. * Disposes the component and the associated ressources.
  37121. */
  37122. dispose(): void;
  37123. private _pickSpriteButKeepRay;
  37124. private _pointerMove;
  37125. private _pointerDown;
  37126. private _pointerUp;
  37127. }
  37128. }
  37129. declare module BABYLON {
  37130. /**
  37131. * @hidden
  37132. **/
  37133. class _AlphaState {
  37134. private _isAlphaBlendDirty;
  37135. private _isBlendFunctionParametersDirty;
  37136. private _isBlendEquationParametersDirty;
  37137. private _isBlendConstantsDirty;
  37138. private _alphaBlend;
  37139. private _blendFunctionParameters;
  37140. private _blendEquationParameters;
  37141. private _blendConstants;
  37142. /**
  37143. * Initializes the state.
  37144. */
  37145. constructor();
  37146. readonly isDirty: boolean;
  37147. alphaBlend: boolean;
  37148. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  37149. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  37150. setAlphaEquationParameters(rgb: number, alpha: number): void;
  37151. reset(): void;
  37152. apply(gl: WebGLRenderingContext): void;
  37153. }
  37154. }
  37155. declare module BABYLON {
  37156. /**
  37157. * @hidden
  37158. **/
  37159. class _DepthCullingState {
  37160. private _isDepthTestDirty;
  37161. private _isDepthMaskDirty;
  37162. private _isDepthFuncDirty;
  37163. private _isCullFaceDirty;
  37164. private _isCullDirty;
  37165. private _isZOffsetDirty;
  37166. private _isFrontFaceDirty;
  37167. private _depthTest;
  37168. private _depthMask;
  37169. private _depthFunc;
  37170. private _cull;
  37171. private _cullFace;
  37172. private _zOffset;
  37173. private _frontFace;
  37174. /**
  37175. * Initializes the state.
  37176. */
  37177. constructor();
  37178. readonly isDirty: boolean;
  37179. zOffset: number;
  37180. cullFace: Nullable<number>;
  37181. cull: Nullable<boolean>;
  37182. depthFunc: Nullable<number>;
  37183. depthMask: boolean;
  37184. depthTest: boolean;
  37185. frontFace: Nullable<number>;
  37186. reset(): void;
  37187. apply(gl: WebGLRenderingContext): void;
  37188. }
  37189. }
  37190. declare module BABYLON {
  37191. /**
  37192. * @hidden
  37193. **/
  37194. class _StencilState {
  37195. private _isStencilTestDirty;
  37196. private _isStencilMaskDirty;
  37197. private _isStencilFuncDirty;
  37198. private _isStencilOpDirty;
  37199. private _stencilTest;
  37200. private _stencilMask;
  37201. private _stencilFunc;
  37202. private _stencilFuncRef;
  37203. private _stencilFuncMask;
  37204. private _stencilOpStencilFail;
  37205. private _stencilOpDepthFail;
  37206. private _stencilOpStencilDepthPass;
  37207. readonly isDirty: boolean;
  37208. stencilFunc: number;
  37209. stencilFuncRef: number;
  37210. stencilFuncMask: number;
  37211. stencilOpStencilFail: number;
  37212. stencilOpDepthFail: number;
  37213. stencilOpStencilDepthPass: number;
  37214. stencilMask: number;
  37215. stencilTest: boolean;
  37216. constructor();
  37217. reset(): void;
  37218. apply(gl: WebGLRenderingContext): void;
  37219. }
  37220. }
  37221. declare module BABYLON {
  37222. /**
  37223. * Class used to evalaute queries containing `and` and `or` operators
  37224. */
  37225. class AndOrNotEvaluator {
  37226. /**
  37227. * Evaluate a query
  37228. * @param query defines the query to evaluate
  37229. * @param evaluateCallback defines the callback used to filter result
  37230. * @returns true if the query matches
  37231. */
  37232. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  37233. private static _HandleParenthesisContent;
  37234. private static _SimplifyNegation;
  37235. }
  37236. }
  37237. declare module BABYLON {
  37238. /**
  37239. * Defines the list of states available for a task inside a AssetsManager
  37240. */
  37241. enum AssetTaskState {
  37242. /**
  37243. * Initialization
  37244. */
  37245. INIT = 0,
  37246. /**
  37247. * Running
  37248. */
  37249. RUNNING = 1,
  37250. /**
  37251. * Done
  37252. */
  37253. DONE = 2,
  37254. /**
  37255. * Error
  37256. */
  37257. ERROR = 3
  37258. }
  37259. /**
  37260. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  37261. */
  37262. abstract class AbstractAssetTask {
  37263. /**
  37264. * Task name
  37265. */ name: string;
  37266. /**
  37267. * Callback called when the task is successful
  37268. */
  37269. onSuccess: (task: any) => void;
  37270. /**
  37271. * Callback called when the task is not successful
  37272. */
  37273. onError: (task: any, message?: string, exception?: any) => void;
  37274. /**
  37275. * Creates a new AssetsManager
  37276. * @param name defines the name of the task
  37277. */
  37278. constructor(
  37279. /**
  37280. * Task name
  37281. */ name: string);
  37282. private _isCompleted;
  37283. private _taskState;
  37284. private _errorObject;
  37285. /**
  37286. * Get if the task is completed
  37287. */
  37288. readonly isCompleted: boolean;
  37289. /**
  37290. * Gets the current state of the task
  37291. */
  37292. readonly taskState: AssetTaskState;
  37293. /**
  37294. * Gets the current error object (if task is in error)
  37295. */
  37296. readonly errorObject: {
  37297. message?: string;
  37298. exception?: any;
  37299. };
  37300. /**
  37301. * Internal only
  37302. * @hidden
  37303. */
  37304. _setErrorObject(message?: string, exception?: any): void;
  37305. /**
  37306. * Execute the current task
  37307. * @param scene defines the scene where you want your assets to be loaded
  37308. * @param onSuccess is a callback called when the task is successfully executed
  37309. * @param onError is a callback called if an error occurs
  37310. */
  37311. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37312. /**
  37313. * Execute the current task
  37314. * @param scene defines the scene where you want your assets to be loaded
  37315. * @param onSuccess is a callback called when the task is successfully executed
  37316. * @param onError is a callback called if an error occurs
  37317. */
  37318. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37319. /**
  37320. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  37321. * This can be used with failed tasks that have the reason for failure fixed.
  37322. */
  37323. reset(): void;
  37324. private onErrorCallback;
  37325. private onDoneCallback;
  37326. }
  37327. /**
  37328. * Define the interface used by progress events raised during assets loading
  37329. */
  37330. interface IAssetsProgressEvent {
  37331. /**
  37332. * Defines the number of remaining tasks to process
  37333. */
  37334. remainingCount: number;
  37335. /**
  37336. * Defines the total number of tasks
  37337. */
  37338. totalCount: number;
  37339. /**
  37340. * Defines the task that was just processed
  37341. */
  37342. task: AbstractAssetTask;
  37343. }
  37344. /**
  37345. * Class used to share progress information about assets loading
  37346. */
  37347. class AssetsProgressEvent implements IAssetsProgressEvent {
  37348. /**
  37349. * Defines the number of remaining tasks to process
  37350. */
  37351. remainingCount: number;
  37352. /**
  37353. * Defines the total number of tasks
  37354. */
  37355. totalCount: number;
  37356. /**
  37357. * Defines the task that was just processed
  37358. */
  37359. task: AbstractAssetTask;
  37360. /**
  37361. * Creates a AssetsProgressEvent
  37362. * @param remainingCount defines the number of remaining tasks to process
  37363. * @param totalCount defines the total number of tasks
  37364. * @param task defines the task that was just processed
  37365. */
  37366. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  37367. }
  37368. /**
  37369. * Define a task used by AssetsManager to load meshes
  37370. */
  37371. class MeshAssetTask extends AbstractAssetTask {
  37372. /**
  37373. * Defines the name of the task
  37374. */
  37375. name: string;
  37376. /**
  37377. * Defines the list of mesh's names you want to load
  37378. */
  37379. meshesNames: any;
  37380. /**
  37381. * Defines the root url to use as a base to load your meshes and associated resources
  37382. */
  37383. rootUrl: string;
  37384. /**
  37385. * Defines the filename of the scene to load from
  37386. */
  37387. sceneFilename: string;
  37388. /**
  37389. * Gets the list of loaded meshes
  37390. */
  37391. loadedMeshes: Array<AbstractMesh>;
  37392. /**
  37393. * Gets the list of loaded particle systems
  37394. */
  37395. loadedParticleSystems: Array<IParticleSystem>;
  37396. /**
  37397. * Gets the list of loaded skeletons
  37398. */
  37399. loadedSkeletons: Array<Skeleton>;
  37400. /**
  37401. * Callback called when the task is successful
  37402. */
  37403. onSuccess: (task: MeshAssetTask) => void;
  37404. /**
  37405. * Callback called when the task is successful
  37406. */
  37407. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  37408. /**
  37409. * Creates a new MeshAssetTask
  37410. * @param name defines the name of the task
  37411. * @param meshesNames defines the list of mesh's names you want to load
  37412. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  37413. * @param sceneFilename defines the filename of the scene to load from
  37414. */
  37415. constructor(
  37416. /**
  37417. * Defines the name of the task
  37418. */
  37419. name: string,
  37420. /**
  37421. * Defines the list of mesh's names you want to load
  37422. */
  37423. meshesNames: any,
  37424. /**
  37425. * Defines the root url to use as a base to load your meshes and associated resources
  37426. */
  37427. rootUrl: string,
  37428. /**
  37429. * Defines the filename of the scene to load from
  37430. */
  37431. sceneFilename: string);
  37432. /**
  37433. * Execute the current task
  37434. * @param scene defines the scene where you want your assets to be loaded
  37435. * @param onSuccess is a callback called when the task is successfully executed
  37436. * @param onError is a callback called if an error occurs
  37437. */
  37438. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37439. }
  37440. /**
  37441. * Define a task used by AssetsManager to load text content
  37442. */
  37443. class TextFileAssetTask extends AbstractAssetTask {
  37444. /**
  37445. * Defines the name of the task
  37446. */
  37447. name: string;
  37448. /**
  37449. * Defines the location of the file to load
  37450. */
  37451. url: string;
  37452. /**
  37453. * Gets the loaded text string
  37454. */
  37455. text: string;
  37456. /**
  37457. * Callback called when the task is successful
  37458. */
  37459. onSuccess: (task: TextFileAssetTask) => void;
  37460. /**
  37461. * Callback called when the task is successful
  37462. */
  37463. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  37464. /**
  37465. * Creates a new TextFileAssetTask object
  37466. * @param name defines the name of the task
  37467. * @param url defines the location of the file to load
  37468. */
  37469. constructor(
  37470. /**
  37471. * Defines the name of the task
  37472. */
  37473. name: string,
  37474. /**
  37475. * Defines the location of the file to load
  37476. */
  37477. url: string);
  37478. /**
  37479. * Execute the current task
  37480. * @param scene defines the scene where you want your assets to be loaded
  37481. * @param onSuccess is a callback called when the task is successfully executed
  37482. * @param onError is a callback called if an error occurs
  37483. */
  37484. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37485. }
  37486. /**
  37487. * Define a task used by AssetsManager to load binary data
  37488. */
  37489. class BinaryFileAssetTask extends AbstractAssetTask {
  37490. /**
  37491. * Defines the name of the task
  37492. */
  37493. name: string;
  37494. /**
  37495. * Defines the location of the file to load
  37496. */
  37497. url: string;
  37498. /**
  37499. * Gets the lodaded data (as an array buffer)
  37500. */
  37501. data: ArrayBuffer;
  37502. /**
  37503. * Callback called when the task is successful
  37504. */
  37505. onSuccess: (task: BinaryFileAssetTask) => void;
  37506. /**
  37507. * Callback called when the task is successful
  37508. */
  37509. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  37510. /**
  37511. * Creates a new BinaryFileAssetTask object
  37512. * @param name defines the name of the new task
  37513. * @param url defines the location of the file to load
  37514. */
  37515. constructor(
  37516. /**
  37517. * Defines the name of the task
  37518. */
  37519. name: string,
  37520. /**
  37521. * Defines the location of the file to load
  37522. */
  37523. url: string);
  37524. /**
  37525. * Execute the current task
  37526. * @param scene defines the scene where you want your assets to be loaded
  37527. * @param onSuccess is a callback called when the task is successfully executed
  37528. * @param onError is a callback called if an error occurs
  37529. */
  37530. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37531. }
  37532. /**
  37533. * Define a task used by AssetsManager to load images
  37534. */
  37535. class ImageAssetTask extends AbstractAssetTask {
  37536. /**
  37537. * Defines the name of the task
  37538. */
  37539. name: string;
  37540. /**
  37541. * Defines the location of the image to load
  37542. */
  37543. url: string;
  37544. /**
  37545. * Gets the loaded images
  37546. */
  37547. image: HTMLImageElement;
  37548. /**
  37549. * Callback called when the task is successful
  37550. */
  37551. onSuccess: (task: ImageAssetTask) => void;
  37552. /**
  37553. * Callback called when the task is successful
  37554. */
  37555. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  37556. /**
  37557. * Creates a new ImageAssetTask
  37558. * @param name defines the name of the task
  37559. * @param url defines the location of the image to load
  37560. */
  37561. constructor(
  37562. /**
  37563. * Defines the name of the task
  37564. */
  37565. name: string,
  37566. /**
  37567. * Defines the location of the image to load
  37568. */
  37569. url: string);
  37570. /**
  37571. * Execute the current task
  37572. * @param scene defines the scene where you want your assets to be loaded
  37573. * @param onSuccess is a callback called when the task is successfully executed
  37574. * @param onError is a callback called if an error occurs
  37575. */
  37576. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37577. }
  37578. /**
  37579. * Defines the interface used by texture loading tasks
  37580. */
  37581. interface ITextureAssetTask<TEX extends BaseTexture> {
  37582. /**
  37583. * Gets the loaded texture
  37584. */
  37585. texture: TEX;
  37586. }
  37587. /**
  37588. * Define a task used by AssetsManager to load 2D textures
  37589. */
  37590. class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  37591. /**
  37592. * Defines the name of the task
  37593. */
  37594. name: string;
  37595. /**
  37596. * Defines the location of the file to load
  37597. */
  37598. url: string;
  37599. /**
  37600. * Defines if mipmap should not be generated (default is false)
  37601. */
  37602. noMipmap?: boolean | undefined;
  37603. /**
  37604. * Defines if texture must be inverted on Y axis (default is false)
  37605. */
  37606. invertY?: boolean | undefined;
  37607. /**
  37608. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  37609. */
  37610. samplingMode: number;
  37611. /**
  37612. * Gets the loaded texture
  37613. */
  37614. texture: Texture;
  37615. /**
  37616. * Callback called when the task is successful
  37617. */
  37618. onSuccess: (task: TextureAssetTask) => void;
  37619. /**
  37620. * Callback called when the task is successful
  37621. */
  37622. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  37623. /**
  37624. * Creates a new TextureAssetTask object
  37625. * @param name defines the name of the task
  37626. * @param url defines the location of the file to load
  37627. * @param noMipmap defines if mipmap should not be generated (default is false)
  37628. * @param invertY defines if texture must be inverted on Y axis (default is false)
  37629. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  37630. */
  37631. constructor(
  37632. /**
  37633. * Defines the name of the task
  37634. */
  37635. name: string,
  37636. /**
  37637. * Defines the location of the file to load
  37638. */
  37639. url: string,
  37640. /**
  37641. * Defines if mipmap should not be generated (default is false)
  37642. */
  37643. noMipmap?: boolean | undefined,
  37644. /**
  37645. * Defines if texture must be inverted on Y axis (default is false)
  37646. */
  37647. invertY?: boolean | undefined,
  37648. /**
  37649. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  37650. */
  37651. samplingMode?: number);
  37652. /**
  37653. * Execute the current task
  37654. * @param scene defines the scene where you want your assets to be loaded
  37655. * @param onSuccess is a callback called when the task is successfully executed
  37656. * @param onError is a callback called if an error occurs
  37657. */
  37658. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37659. }
  37660. /**
  37661. * Define a task used by AssetsManager to load cube textures
  37662. */
  37663. class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  37664. /**
  37665. * Defines the name of the task
  37666. */
  37667. name: string;
  37668. /**
  37669. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  37670. */
  37671. url: string;
  37672. /**
  37673. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  37674. */
  37675. extensions?: string[] | undefined;
  37676. /**
  37677. * Defines if mipmaps should not be generated (default is false)
  37678. */
  37679. noMipmap?: boolean | undefined;
  37680. /**
  37681. * Defines the explicit list of files (undefined by default)
  37682. */
  37683. files?: string[] | undefined;
  37684. /**
  37685. * Gets the loaded texture
  37686. */
  37687. texture: CubeTexture;
  37688. /**
  37689. * Callback called when the task is successful
  37690. */
  37691. onSuccess: (task: CubeTextureAssetTask) => void;
  37692. /**
  37693. * Callback called when the task is successful
  37694. */
  37695. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  37696. /**
  37697. * Creates a new CubeTextureAssetTask
  37698. * @param name defines the name of the task
  37699. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  37700. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  37701. * @param noMipmap defines if mipmaps should not be generated (default is false)
  37702. * @param files defines the explicit list of files (undefined by default)
  37703. */
  37704. constructor(
  37705. /**
  37706. * Defines the name of the task
  37707. */
  37708. name: string,
  37709. /**
  37710. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  37711. */
  37712. url: string,
  37713. /**
  37714. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  37715. */
  37716. extensions?: string[] | undefined,
  37717. /**
  37718. * Defines if mipmaps should not be generated (default is false)
  37719. */
  37720. noMipmap?: boolean | undefined,
  37721. /**
  37722. * Defines the explicit list of files (undefined by default)
  37723. */
  37724. files?: string[] | undefined);
  37725. /**
  37726. * Execute the current task
  37727. * @param scene defines the scene where you want your assets to be loaded
  37728. * @param onSuccess is a callback called when the task is successfully executed
  37729. * @param onError is a callback called if an error occurs
  37730. */
  37731. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37732. }
  37733. /**
  37734. * Define a task used by AssetsManager to load HDR cube textures
  37735. */
  37736. class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  37737. /**
  37738. * Defines the name of the task
  37739. */
  37740. name: string;
  37741. /**
  37742. * Defines the location of the file to load
  37743. */
  37744. url: string;
  37745. /**
  37746. * Defines the desired size (the more it increases the longer the generation will be)
  37747. */
  37748. size: number;
  37749. /**
  37750. * Defines if mipmaps should not be generated (default is false)
  37751. */
  37752. noMipmap: boolean;
  37753. /**
  37754. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  37755. */
  37756. generateHarmonics: boolean;
  37757. /**
  37758. * 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)
  37759. */
  37760. gammaSpace: boolean;
  37761. /**
  37762. * Internal Use Only
  37763. */
  37764. reserved: boolean;
  37765. /**
  37766. * Gets the loaded texture
  37767. */
  37768. texture: HDRCubeTexture;
  37769. /**
  37770. * Callback called when the task is successful
  37771. */
  37772. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  37773. /**
  37774. * Callback called when the task is successful
  37775. */
  37776. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  37777. /**
  37778. * Creates a new HDRCubeTextureAssetTask object
  37779. * @param name defines the name of the task
  37780. * @param url defines the location of the file to load
  37781. * @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.
  37782. * @param noMipmap defines if mipmaps should not be generated (default is false)
  37783. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  37784. * @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)
  37785. * @param reserved Internal use only
  37786. */
  37787. constructor(
  37788. /**
  37789. * Defines the name of the task
  37790. */
  37791. name: string,
  37792. /**
  37793. * Defines the location of the file to load
  37794. */
  37795. url: string,
  37796. /**
  37797. * Defines the desired size (the more it increases the longer the generation will be)
  37798. */
  37799. size: number,
  37800. /**
  37801. * Defines if mipmaps should not be generated (default is false)
  37802. */
  37803. noMipmap?: boolean,
  37804. /**
  37805. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  37806. */
  37807. generateHarmonics?: boolean,
  37808. /**
  37809. * 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)
  37810. */
  37811. gammaSpace?: boolean,
  37812. /**
  37813. * Internal Use Only
  37814. */
  37815. reserved?: boolean);
  37816. /**
  37817. * Execute the current task
  37818. * @param scene defines the scene where you want your assets to be loaded
  37819. * @param onSuccess is a callback called when the task is successfully executed
  37820. * @param onError is a callback called if an error occurs
  37821. */
  37822. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37823. }
  37824. /**
  37825. * This class can be used to easily import assets into a scene
  37826. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  37827. */
  37828. class AssetsManager {
  37829. private _scene;
  37830. private _isLoading;
  37831. protected _tasks: AbstractAssetTask[];
  37832. protected _waitingTasksCount: number;
  37833. protected _totalTasksCount: number;
  37834. /**
  37835. * Callback called when all tasks are processed
  37836. */
  37837. onFinish: (tasks: AbstractAssetTask[]) => void;
  37838. /**
  37839. * Callback called when a task is successful
  37840. */
  37841. onTaskSuccess: (task: AbstractAssetTask) => void;
  37842. /**
  37843. * Callback called when a task had an error
  37844. */
  37845. onTaskError: (task: AbstractAssetTask) => void;
  37846. /**
  37847. * Callback called when a task is done (whatever the result is)
  37848. */
  37849. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  37850. /**
  37851. * Observable called when all tasks are processed
  37852. */
  37853. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  37854. /**
  37855. * Observable called when a task had an error
  37856. */
  37857. onTaskErrorObservable: Observable<AbstractAssetTask>;
  37858. /**
  37859. * Observable called when a task is successful
  37860. */
  37861. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  37862. /**
  37863. * Observable called when a task is done (whatever the result is)
  37864. */
  37865. onProgressObservable: Observable<IAssetsProgressEvent>;
  37866. /**
  37867. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  37868. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37869. */
  37870. useDefaultLoadingScreen: boolean;
  37871. /**
  37872. * Creates a new AssetsManager
  37873. * @param scene defines the scene to work on
  37874. */
  37875. constructor(scene: Scene);
  37876. /**
  37877. * Add a MeshAssetTask to the list of active tasks
  37878. * @param taskName defines the name of the new task
  37879. * @param meshesNames defines the name of meshes to load
  37880. * @param rootUrl defines the root url to use to locate files
  37881. * @param sceneFilename defines the filename of the scene file
  37882. * @returns a new MeshAssetTask object
  37883. */
  37884. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  37885. /**
  37886. * Add a TextFileAssetTask to the list of active tasks
  37887. * @param taskName defines the name of the new task
  37888. * @param url defines the url of the file to load
  37889. * @returns a new TextFileAssetTask object
  37890. */
  37891. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  37892. /**
  37893. * Add a BinaryFileAssetTask to the list of active tasks
  37894. * @param taskName defines the name of the new task
  37895. * @param url defines the url of the file to load
  37896. * @returns a new BinaryFileAssetTask object
  37897. */
  37898. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  37899. /**
  37900. * Add a ImageAssetTask to the list of active tasks
  37901. * @param taskName defines the name of the new task
  37902. * @param url defines the url of the file to load
  37903. * @returns a new ImageAssetTask object
  37904. */
  37905. addImageTask(taskName: string, url: string): ImageAssetTask;
  37906. /**
  37907. * Add a TextureAssetTask to the list of active tasks
  37908. * @param taskName defines the name of the new task
  37909. * @param url defines the url of the file to load
  37910. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  37911. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  37912. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  37913. * @returns a new TextureAssetTask object
  37914. */
  37915. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  37916. /**
  37917. * Add a CubeTextureAssetTask to the list of active tasks
  37918. * @param taskName defines the name of the new task
  37919. * @param url defines the url of the file to load
  37920. * @param extensions defines the extension to use to load the cube map (can be null)
  37921. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  37922. * @param files defines the list of files to load (can be null)
  37923. * @returns a new CubeTextureAssetTask object
  37924. */
  37925. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  37926. /**
  37927. *
  37928. * Add a HDRCubeTextureAssetTask to the list of active tasks
  37929. * @param taskName defines the name of the new task
  37930. * @param url defines the url of the file to load
  37931. * @param size defines the size you want for the cubemap (can be null)
  37932. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  37933. * @param generateHarmonics defines if you want to automatically generate (true by default)
  37934. * @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)
  37935. * @param reserved Internal use only
  37936. * @returns a new HDRCubeTextureAssetTask object
  37937. */
  37938. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  37939. /**
  37940. * Remove a task from the assets manager.
  37941. * @param task the task to remove
  37942. */
  37943. removeTask(task: AbstractAssetTask): void;
  37944. private _decreaseWaitingTasksCount;
  37945. private _runTask;
  37946. /**
  37947. * Reset the AssetsManager and remove all tasks
  37948. * @return the current instance of the AssetsManager
  37949. */
  37950. reset(): AssetsManager;
  37951. /**
  37952. * Start the loading process
  37953. * @return the current instance of the AssetsManager
  37954. */
  37955. load(): AssetsManager;
  37956. }
  37957. }
  37958. declare module BABYLON {
  37959. /**
  37960. * Direct draw surface info
  37961. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  37962. */
  37963. interface DDSInfo {
  37964. /**
  37965. * Width of the texture
  37966. */
  37967. width: number;
  37968. /**
  37969. * Width of the texture
  37970. */
  37971. height: number;
  37972. /**
  37973. * Number of Mipmaps for the texture
  37974. * @see https://en.wikipedia.org/wiki/Mipmap
  37975. */
  37976. mipmapCount: number;
  37977. /**
  37978. * If the textures format is a known fourCC format
  37979. * @see https://www.fourcc.org/
  37980. */
  37981. isFourCC: boolean;
  37982. /**
  37983. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  37984. */
  37985. isRGB: boolean;
  37986. /**
  37987. * If the texture is a lumincance format
  37988. */
  37989. isLuminance: boolean;
  37990. /**
  37991. * If this is a cube texture
  37992. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  37993. */
  37994. isCube: boolean;
  37995. /**
  37996. * If the texture is a compressed format eg. FOURCC_DXT1
  37997. */
  37998. isCompressed: boolean;
  37999. /**
  38000. * The dxgiFormat of the texture
  38001. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  38002. */
  38003. dxgiFormat: number;
  38004. /**
  38005. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  38006. */
  38007. textureType: number;
  38008. /**
  38009. * Sphericle polynomial created for the dds texture
  38010. */
  38011. sphericalPolynomial?: SphericalPolynomial;
  38012. }
  38013. /**
  38014. * Class used to provide DDS decompression tools
  38015. */
  38016. class DDSTools {
  38017. /**
  38018. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  38019. */
  38020. static StoreLODInAlphaChannel: boolean;
  38021. /**
  38022. * Gets DDS information from an array buffer
  38023. * @param arrayBuffer defines the array buffer to read data from
  38024. * @returns the DDS information
  38025. */
  38026. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  38027. private static _FloatView;
  38028. private static _Int32View;
  38029. private static _ToHalfFloat;
  38030. private static _FromHalfFloat;
  38031. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  38032. private static _GetHalfFloatRGBAArrayBuffer;
  38033. private static _GetFloatRGBAArrayBuffer;
  38034. private static _GetFloatAsUIntRGBAArrayBuffer;
  38035. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  38036. private static _GetRGBAArrayBuffer;
  38037. private static _ExtractLongWordOrder;
  38038. private static _GetRGBArrayBuffer;
  38039. private static _GetLuminanceArrayBuffer;
  38040. /**
  38041. * Uploads DDS Levels to a Babylon Texture
  38042. * @hidden
  38043. */
  38044. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  38045. }
  38046. }
  38047. declare module BABYLON {
  38048. function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  38049. function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38050. function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38051. function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38052. function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38053. function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38054. function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38055. function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38056. function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38057. function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38058. function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38059. function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38060. /**
  38061. * Decorator used to define property that can be serialized as reference to a camera
  38062. * @param sourceName defines the name of the property to decorate
  38063. */
  38064. function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38065. /**
  38066. * Class used to help serialization objects
  38067. */
  38068. class SerializationHelper {
  38069. /**
  38070. * Static function used to serialized a specific entity
  38071. * @param entity defines the entity to serialize
  38072. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  38073. * @returns a JSON compatible object representing the serialization of the entity
  38074. */
  38075. static Serialize<T>(entity: T, serializationObject?: any): any;
  38076. /**
  38077. * Creates a new entity from a serialization data object
  38078. * @param creationFunction defines a function used to instanciated the new entity
  38079. * @param source defines the source serialization data
  38080. * @param scene defines the hosting scene
  38081. * @param rootUrl defines the root url for resources
  38082. * @returns a new entity
  38083. */
  38084. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  38085. /**
  38086. * Clones an object
  38087. * @param creationFunction defines the function used to instanciate the new object
  38088. * @param source defines the source object
  38089. * @returns the cloned object
  38090. */
  38091. static Clone<T>(creationFunction: () => T, source: T): T;
  38092. /**
  38093. * Instanciates a new object based on a source one (some data will be shared between both object)
  38094. * @param creationFunction defines the function used to instanciate the new object
  38095. * @param source defines the source object
  38096. * @returns the new object
  38097. */
  38098. static Instanciate<T>(creationFunction: () => T, source: T): T;
  38099. }
  38100. }
  38101. declare module BABYLON {
  38102. /**
  38103. * Wrapper class for promise with external resolve and reject.
  38104. */
  38105. class Deferred<T> {
  38106. /**
  38107. * The promise associated with this deferred object.
  38108. */
  38109. readonly promise: Promise<T>;
  38110. private _resolve;
  38111. private _reject;
  38112. /**
  38113. * The resolve method of the promise associated with this deferred object.
  38114. */
  38115. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  38116. /**
  38117. * The reject method of the promise associated with this deferred object.
  38118. */
  38119. readonly reject: (reason?: any) => void;
  38120. /**
  38121. * Constructor for this deferred object.
  38122. */
  38123. constructor();
  38124. }
  38125. }
  38126. declare module BABYLON {
  38127. /**
  38128. * Raw texture data and descriptor sufficient for WebGL texture upload
  38129. */
  38130. interface EnvironmentTextureInfo {
  38131. /**
  38132. * Version of the environment map
  38133. */
  38134. version: number;
  38135. /**
  38136. * Width of image
  38137. */
  38138. width: number;
  38139. /**
  38140. * Irradiance information stored in the file.
  38141. */
  38142. irradiance: any;
  38143. /**
  38144. * Specular information stored in the file.
  38145. */
  38146. specular: any;
  38147. }
  38148. /**
  38149. * Sets of helpers addressing the serialization and deserialization of environment texture
  38150. * stored in a BabylonJS env file.
  38151. * Those files are usually stored as .env files.
  38152. */
  38153. class EnvironmentTextureTools {
  38154. /**
  38155. * Magic number identifying the env file.
  38156. */
  38157. private static _MagicBytes;
  38158. /**
  38159. * Gets the environment info from an env file.
  38160. * @param data The array buffer containing the .env bytes.
  38161. * @returns the environment file info (the json header) if successfully parsed.
  38162. */
  38163. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  38164. /**
  38165. * Creates an environment texture from a loaded cube texture.
  38166. * @param texture defines the cube texture to convert in env file
  38167. * @return a promise containing the environment data if succesfull.
  38168. */
  38169. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  38170. /**
  38171. * Creates a JSON representation of the spherical data.
  38172. * @param texture defines the texture containing the polynomials
  38173. * @return the JSON representation of the spherical info
  38174. */
  38175. private static _CreateEnvTextureIrradiance;
  38176. /**
  38177. * Uploads the texture info contained in the env file to the GPU.
  38178. * @param texture defines the internal texture to upload to
  38179. * @param arrayBuffer defines the buffer cotaining the data to load
  38180. * @param info defines the texture info retrieved through the GetEnvInfo method
  38181. * @returns a promise
  38182. */
  38183. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  38184. /**
  38185. * Uploads the levels of image data to the GPU.
  38186. * @param texture defines the internal texture to upload to
  38187. * @param imageData defines the array buffer views of image data [mipmap][face]
  38188. * @returns a promise
  38189. */
  38190. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  38191. /**
  38192. * Uploads spherical polynomials information to the texture.
  38193. * @param texture defines the texture we are trying to upload the information to
  38194. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  38195. */
  38196. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  38197. }
  38198. }
  38199. declare module BABYLON {
  38200. /**
  38201. * Class used to help managing file picking and drag'n'drop
  38202. */
  38203. class FilesInput {
  38204. /**
  38205. * List of files ready to be loaded
  38206. */
  38207. static FilesToLoad: {
  38208. [key: string]: File;
  38209. };
  38210. /**
  38211. * Callback called when a file is processed
  38212. */
  38213. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  38214. private _engine;
  38215. private _currentScene;
  38216. private _sceneLoadedCallback;
  38217. private _progressCallback;
  38218. private _additionalRenderLoopLogicCallback;
  38219. private _textureLoadingCallback;
  38220. private _startingProcessingFilesCallback;
  38221. private _onReloadCallback;
  38222. private _errorCallback;
  38223. private _elementToMonitor;
  38224. private _sceneFileToLoad;
  38225. private _filesToLoad;
  38226. /**
  38227. * Creates a new FilesInput
  38228. * @param engine defines the rendering engine
  38229. * @param scene defines the hosting scene
  38230. * @param sceneLoadedCallback callback called when scene is loaded
  38231. * @param progressCallback callback called to track progress
  38232. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  38233. * @param textureLoadingCallback callback called when a texture is loading
  38234. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  38235. * @param onReloadCallback callback called when a reload is requested
  38236. * @param errorCallback callback call if an error occurs
  38237. */
  38238. 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);
  38239. private _dragEnterHandler;
  38240. private _dragOverHandler;
  38241. private _dropHandler;
  38242. /**
  38243. * Calls this function to listen to drag'n'drop events on a specific DOM element
  38244. * @param elementToMonitor defines the DOM element to track
  38245. */
  38246. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  38247. /**
  38248. * Release all associated resources
  38249. */
  38250. dispose(): void;
  38251. private renderFunction;
  38252. private drag;
  38253. private drop;
  38254. private _traverseFolder;
  38255. private _processFiles;
  38256. /**
  38257. * Load files from a drop event
  38258. * @param event defines the drop event to use as source
  38259. */
  38260. loadFiles(event: any): void;
  38261. private _processReload;
  38262. /**
  38263. * Reload the current scene from the loaded files
  38264. */
  38265. reload(): void;
  38266. }
  38267. }
  38268. declare module BABYLON {
  38269. /**
  38270. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  38271. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  38272. */
  38273. class KhronosTextureContainer {
  38274. /** contents of the KTX container file */
  38275. arrayBuffer: any;
  38276. private static HEADER_LEN;
  38277. private static COMPRESSED_2D;
  38278. private static COMPRESSED_3D;
  38279. private static TEX_2D;
  38280. private static TEX_3D;
  38281. /**
  38282. * Gets the openGL type
  38283. */
  38284. glType: number;
  38285. /**
  38286. * Gets the openGL type size
  38287. */
  38288. glTypeSize: number;
  38289. /**
  38290. * Gets the openGL format
  38291. */
  38292. glFormat: number;
  38293. /**
  38294. * Gets the openGL internal format
  38295. */
  38296. glInternalFormat: number;
  38297. /**
  38298. * Gets the base internal format
  38299. */
  38300. glBaseInternalFormat: number;
  38301. /**
  38302. * Gets image width in pixel
  38303. */
  38304. pixelWidth: number;
  38305. /**
  38306. * Gets image height in pixel
  38307. */
  38308. pixelHeight: number;
  38309. /**
  38310. * Gets image depth in pixels
  38311. */
  38312. pixelDepth: number;
  38313. /**
  38314. * Gets the number of array elements
  38315. */
  38316. numberOfArrayElements: number;
  38317. /**
  38318. * Gets the number of faces
  38319. */
  38320. numberOfFaces: number;
  38321. /**
  38322. * Gets the number of mipmap levels
  38323. */
  38324. numberOfMipmapLevels: number;
  38325. /**
  38326. * Gets the bytes of key value data
  38327. */
  38328. bytesOfKeyValueData: number;
  38329. /**
  38330. * Gets the load type
  38331. */
  38332. loadType: number;
  38333. /**
  38334. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  38335. */
  38336. isInvalid: boolean;
  38337. /**
  38338. * Creates a new KhronosTextureContainer
  38339. * @param arrayBuffer contents of the KTX container file
  38340. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  38341. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  38342. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  38343. */
  38344. constructor(
  38345. /** contents of the KTX container file */
  38346. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  38347. /**
  38348. * Revert the endianness of a value.
  38349. * Not as fast hardware based, but will probably never need to use
  38350. * @param val defines the value to convert
  38351. * @returns the new value
  38352. */
  38353. switchEndianness(val: number): number;
  38354. /**
  38355. * Uploads KTX content to a Babylon Texture.
  38356. * It is assumed that the texture has already been created & is currently bound
  38357. * @hidden
  38358. */
  38359. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  38360. private _upload2DCompressedLevels;
  38361. }
  38362. }
  38363. declare module BABYLON {
  38364. /**
  38365. * A class serves as a medium between the observable and its observers
  38366. */
  38367. class EventState {
  38368. /**
  38369. * Create a new EventState
  38370. * @param mask defines the mask associated with this state
  38371. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  38372. * @param target defines the original target of the state
  38373. * @param currentTarget defines the current target of the state
  38374. */
  38375. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  38376. /**
  38377. * Initialize the current event state
  38378. * @param mask defines the mask associated with this state
  38379. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  38380. * @param target defines the original target of the state
  38381. * @param currentTarget defines the current target of the state
  38382. * @returns the current event state
  38383. */
  38384. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  38385. /**
  38386. * An Observer can set this property to true to prevent subsequent observers of being notified
  38387. */
  38388. skipNextObservers: boolean;
  38389. /**
  38390. * Get the mask value that were used to trigger the event corresponding to this EventState object
  38391. */
  38392. mask: number;
  38393. /**
  38394. * The object that originally notified the event
  38395. */
  38396. target?: any;
  38397. /**
  38398. * The current object in the bubbling phase
  38399. */
  38400. currentTarget?: any;
  38401. /**
  38402. * This will be populated with the return value of the last function that was executed.
  38403. * If it is the first function in the callback chain it will be the event data.
  38404. */
  38405. lastReturnValue?: any;
  38406. }
  38407. /**
  38408. * Represent an Observer registered to a given Observable object.
  38409. */
  38410. class Observer<T> {
  38411. /**
  38412. * Defines the callback to call when the observer is notified
  38413. */
  38414. callback: (eventData: T, eventState: EventState) => void;
  38415. /**
  38416. * Defines the mask of the observer (used to filter notifications)
  38417. */
  38418. mask: number;
  38419. /**
  38420. * Defines the current scope used to restore the JS context
  38421. */
  38422. scope: any;
  38423. /** @hidden */
  38424. _willBeUnregistered: boolean;
  38425. /**
  38426. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  38427. */
  38428. unregisterOnNextCall: boolean;
  38429. /**
  38430. * Creates a new observer
  38431. * @param callback defines the callback to call when the observer is notified
  38432. * @param mask defines the mask of the observer (used to filter notifications)
  38433. * @param scope defines the current scope used to restore the JS context
  38434. */
  38435. constructor(
  38436. /**
  38437. * Defines the callback to call when the observer is notified
  38438. */
  38439. callback: (eventData: T, eventState: EventState) => void,
  38440. /**
  38441. * Defines the mask of the observer (used to filter notifications)
  38442. */
  38443. mask: number,
  38444. /**
  38445. * Defines the current scope used to restore the JS context
  38446. */
  38447. scope?: any);
  38448. }
  38449. /**
  38450. * Represent a list of observers registered to multiple Observables object.
  38451. */
  38452. class MultiObserver<T> {
  38453. private _observers;
  38454. private _observables;
  38455. /**
  38456. * Release associated resources
  38457. */
  38458. dispose(): void;
  38459. /**
  38460. * Raise a callback when one of the observable will notify
  38461. * @param observables defines a list of observables to watch
  38462. * @param callback defines the callback to call on notification
  38463. * @param mask defines the mask used to filter notifications
  38464. * @param scope defines the current scope used to restore the JS context
  38465. * @returns the new MultiObserver
  38466. */
  38467. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  38468. }
  38469. /**
  38470. * The Observable class is a simple implementation of the Observable pattern.
  38471. *
  38472. * 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.
  38473. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  38474. * 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).
  38475. * 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.
  38476. */
  38477. class Observable<T> {
  38478. private _observers;
  38479. private _eventState;
  38480. private _onObserverAdded;
  38481. /**
  38482. * Creates a new observable
  38483. * @param onObserverAdded defines a callback to call when a new observer is added
  38484. */
  38485. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  38486. /**
  38487. * Create a new Observer with the specified callback
  38488. * @param callback the callback that will be executed for that Observer
  38489. * @param mask the mask used to filter observers
  38490. * @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.
  38491. * @param scope optional scope for the callback to be called from
  38492. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  38493. * @returns the new observer created for the callback
  38494. */
  38495. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  38496. /**
  38497. * Create a new Observer with the specified callback and unregisters after the next notification
  38498. * @param callback the callback that will be executed for that Observer
  38499. * @returns the new observer created for the callback
  38500. */
  38501. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  38502. /**
  38503. * Remove an Observer from the Observable object
  38504. * @param observer the instance of the Observer to remove
  38505. * @returns false if it doesn't belong to this Observable
  38506. */
  38507. remove(observer: Nullable<Observer<T>>): boolean;
  38508. /**
  38509. * Remove a callback from the Observable object
  38510. * @param callback the callback to remove
  38511. * @param scope optional scope. If used only the callbacks with this scope will be removed
  38512. * @returns false if it doesn't belong to this Observable
  38513. */
  38514. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  38515. private _deferUnregister;
  38516. private _remove;
  38517. /**
  38518. * Notify all Observers by calling their respective callback with the given data
  38519. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  38520. * @param eventData defines the data to send to all observers
  38521. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  38522. * @param target defines the original target of the state
  38523. * @param currentTarget defines the current target of the state
  38524. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  38525. */
  38526. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  38527. /**
  38528. * Calling this will execute each callback, expecting it to be a promise or return a value.
  38529. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  38530. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  38531. * and it is crucial that all callbacks will be executed.
  38532. * The order of the callbacks is kept, callbacks are not executed parallel.
  38533. *
  38534. * @param eventData The data to be sent to each callback
  38535. * @param mask is used to filter observers defaults to -1
  38536. * @param target defines the callback target (see EventState)
  38537. * @param currentTarget defines he current object in the bubbling phase
  38538. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  38539. */
  38540. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  38541. /**
  38542. * Notify a specific observer
  38543. * @param observer defines the observer to notify
  38544. * @param eventData defines the data to be sent to each callback
  38545. * @param mask is used to filter observers defaults to -1
  38546. */
  38547. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  38548. /**
  38549. * Gets a boolean indicating if the observable has at least one observer
  38550. * @returns true is the Observable has at least one Observer registered
  38551. */
  38552. hasObservers(): boolean;
  38553. /**
  38554. * Clear the list of observers
  38555. */
  38556. clear(): void;
  38557. /**
  38558. * Clone the current observable
  38559. * @returns a new observable
  38560. */
  38561. clone(): Observable<T>;
  38562. /**
  38563. * Does this observable handles observer registered with a given mask
  38564. * @param mask defines the mask to be tested
  38565. * @return whether or not one observer registered with the given mask is handeled
  38566. **/
  38567. hasSpecificMask(mask?: number): boolean;
  38568. }
  38569. }
  38570. declare module BABYLON {
  38571. /**
  38572. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  38573. */
  38574. class PerformanceMonitor {
  38575. private _enabled;
  38576. private _rollingFrameTime;
  38577. private _lastFrameTimeMs;
  38578. /**
  38579. * constructor
  38580. * @param frameSampleSize The number of samples required to saturate the sliding window
  38581. */
  38582. constructor(frameSampleSize?: number);
  38583. /**
  38584. * Samples current frame
  38585. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  38586. */
  38587. sampleFrame(timeMs?: number): void;
  38588. /**
  38589. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  38590. */
  38591. readonly averageFrameTime: number;
  38592. /**
  38593. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  38594. */
  38595. readonly averageFrameTimeVariance: number;
  38596. /**
  38597. * Returns the frame time of the most recent frame
  38598. */
  38599. readonly instantaneousFrameTime: number;
  38600. /**
  38601. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  38602. */
  38603. readonly averageFPS: number;
  38604. /**
  38605. * Returns the average framerate in frames per second using the most recent frame time
  38606. */
  38607. readonly instantaneousFPS: number;
  38608. /**
  38609. * Returns true if enough samples have been taken to completely fill the sliding window
  38610. */
  38611. readonly isSaturated: boolean;
  38612. /**
  38613. * Enables contributions to the sliding window sample set
  38614. */
  38615. enable(): void;
  38616. /**
  38617. * Disables contributions to the sliding window sample set
  38618. * Samples will not be interpolated over the disabled period
  38619. */
  38620. disable(): void;
  38621. /**
  38622. * Returns true if sampling is enabled
  38623. */
  38624. readonly isEnabled: boolean;
  38625. /**
  38626. * Resets performance monitor
  38627. */
  38628. reset(): void;
  38629. }
  38630. /**
  38631. * RollingAverage
  38632. *
  38633. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  38634. */
  38635. class RollingAverage {
  38636. /**
  38637. * Current average
  38638. */
  38639. average: number;
  38640. /**
  38641. * Current variance
  38642. */
  38643. variance: number;
  38644. protected _samples: Array<number>;
  38645. protected _sampleCount: number;
  38646. protected _pos: number;
  38647. protected _m2: number;
  38648. /**
  38649. * constructor
  38650. * @param length The number of samples required to saturate the sliding window
  38651. */
  38652. constructor(length: number);
  38653. /**
  38654. * Adds a sample to the sample set
  38655. * @param v The sample value
  38656. */
  38657. add(v: number): void;
  38658. /**
  38659. * Returns previously added values or null if outside of history or outside the sliding window domain
  38660. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  38661. * @return Value previously recorded with add() or null if outside of range
  38662. */
  38663. history(i: number): number;
  38664. /**
  38665. * Returns true if enough samples have been taken to completely fill the sliding window
  38666. * @return true if sample-set saturated
  38667. */
  38668. isSaturated(): boolean;
  38669. /**
  38670. * Resets the rolling average (equivalent to 0 samples taken so far)
  38671. */
  38672. reset(): void;
  38673. /**
  38674. * Wraps a value around the sample range boundaries
  38675. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  38676. * @return Wrapped position in sample range
  38677. */
  38678. protected _wrapPosition(i: number): number;
  38679. }
  38680. }
  38681. declare module BABYLON {
  38682. /**
  38683. * Helper class that provides a small promise polyfill
  38684. */
  38685. class PromisePolyfill {
  38686. /**
  38687. * Static function used to check if the polyfill is required
  38688. * If this is the case then the function will inject the polyfill to window.Promise
  38689. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  38690. */
  38691. static Apply(force?: boolean): void;
  38692. }
  38693. }
  38694. declare module BABYLON {
  38695. /**
  38696. * Defines the root class used to create scene optimization to use with SceneOptimizer
  38697. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38698. */
  38699. class SceneOptimization {
  38700. /**
  38701. * Defines the priority of this optimization (0 by default which means first in the list)
  38702. */
  38703. priority: number;
  38704. /**
  38705. * Gets a string describing the action executed by the current optimization
  38706. * @returns description string
  38707. */
  38708. getDescription(): string;
  38709. /**
  38710. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38711. * @param scene defines the current scene where to apply this optimization
  38712. * @param optimizer defines the current optimizer
  38713. * @returns true if everything that can be done was applied
  38714. */
  38715. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38716. /**
  38717. * Creates the SceneOptimization object
  38718. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  38719. * @param desc defines the description associated with the optimization
  38720. */
  38721. constructor(
  38722. /**
  38723. * Defines the priority of this optimization (0 by default which means first in the list)
  38724. */
  38725. priority?: number);
  38726. }
  38727. /**
  38728. * Defines an optimization used to reduce the size of render target textures
  38729. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38730. */
  38731. class TextureOptimization extends SceneOptimization {
  38732. /**
  38733. * Defines the priority of this optimization (0 by default which means first in the list)
  38734. */
  38735. priority: number;
  38736. /**
  38737. * 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
  38738. */
  38739. maximumSize: number;
  38740. /**
  38741. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  38742. */
  38743. step: number;
  38744. /**
  38745. * Gets a string describing the action executed by the current optimization
  38746. * @returns description string
  38747. */
  38748. getDescription(): string;
  38749. /**
  38750. * Creates the TextureOptimization object
  38751. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  38752. * @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
  38753. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  38754. */
  38755. constructor(
  38756. /**
  38757. * Defines the priority of this optimization (0 by default which means first in the list)
  38758. */
  38759. priority?: number,
  38760. /**
  38761. * 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
  38762. */
  38763. maximumSize?: number,
  38764. /**
  38765. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  38766. */
  38767. step?: number);
  38768. /**
  38769. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38770. * @param scene defines the current scene where to apply this optimization
  38771. * @param optimizer defines the current optimizer
  38772. * @returns true if everything that can be done was applied
  38773. */
  38774. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38775. }
  38776. /**
  38777. * Defines an optimization used to increase or decrease the rendering resolution
  38778. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38779. */
  38780. class HardwareScalingOptimization extends SceneOptimization {
  38781. /**
  38782. * Defines the priority of this optimization (0 by default which means first in the list)
  38783. */
  38784. priority: number;
  38785. /**
  38786. * Defines the maximum scale to use (2 by default)
  38787. */
  38788. maximumScale: number;
  38789. /**
  38790. * Defines the step to use between two passes (0.5 by default)
  38791. */
  38792. step: number;
  38793. private _currentScale;
  38794. private _directionOffset;
  38795. /**
  38796. * Gets a string describing the action executed by the current optimization
  38797. * @return description string
  38798. */
  38799. getDescription(): string;
  38800. /**
  38801. * Creates the HardwareScalingOptimization object
  38802. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  38803. * @param maximumScale defines the maximum scale to use (2 by default)
  38804. * @param step defines the step to use between two passes (0.5 by default)
  38805. */
  38806. constructor(
  38807. /**
  38808. * Defines the priority of this optimization (0 by default which means first in the list)
  38809. */
  38810. priority?: number,
  38811. /**
  38812. * Defines the maximum scale to use (2 by default)
  38813. */
  38814. maximumScale?: number,
  38815. /**
  38816. * Defines the step to use between two passes (0.5 by default)
  38817. */
  38818. step?: number);
  38819. /**
  38820. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38821. * @param scene defines the current scene where to apply this optimization
  38822. * @param optimizer defines the current optimizer
  38823. * @returns true if everything that can be done was applied
  38824. */
  38825. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38826. }
  38827. /**
  38828. * Defines an optimization used to remove shadows
  38829. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38830. */
  38831. class ShadowsOptimization extends SceneOptimization {
  38832. /**
  38833. * Gets a string describing the action executed by the current optimization
  38834. * @return description string
  38835. */
  38836. getDescription(): string;
  38837. /**
  38838. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38839. * @param scene defines the current scene where to apply this optimization
  38840. * @param optimizer defines the current optimizer
  38841. * @returns true if everything that can be done was applied
  38842. */
  38843. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38844. }
  38845. /**
  38846. * Defines an optimization used to turn post-processes off
  38847. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38848. */
  38849. class PostProcessesOptimization extends SceneOptimization {
  38850. /**
  38851. * Gets a string describing the action executed by the current optimization
  38852. * @return description string
  38853. */
  38854. getDescription(): string;
  38855. /**
  38856. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38857. * @param scene defines the current scene where to apply this optimization
  38858. * @param optimizer defines the current optimizer
  38859. * @returns true if everything that can be done was applied
  38860. */
  38861. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38862. }
  38863. /**
  38864. * Defines an optimization used to turn lens flares off
  38865. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38866. */
  38867. class LensFlaresOptimization extends SceneOptimization {
  38868. /**
  38869. * Gets a string describing the action executed by the current optimization
  38870. * @return description string
  38871. */
  38872. getDescription(): string;
  38873. /**
  38874. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38875. * @param scene defines the current scene where to apply this optimization
  38876. * @param optimizer defines the current optimizer
  38877. * @returns true if everything that can be done was applied
  38878. */
  38879. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38880. }
  38881. /**
  38882. * Defines an optimization based on user defined callback.
  38883. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38884. */
  38885. class CustomOptimization extends SceneOptimization {
  38886. /**
  38887. * Callback called to apply the custom optimization.
  38888. */
  38889. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  38890. /**
  38891. * Callback called to get custom description
  38892. */
  38893. onGetDescription: () => string;
  38894. /**
  38895. * Gets a string describing the action executed by the current optimization
  38896. * @returns description string
  38897. */
  38898. getDescription(): string;
  38899. /**
  38900. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38901. * @param scene defines the current scene where to apply this optimization
  38902. * @param optimizer defines the current optimizer
  38903. * @returns true if everything that can be done was applied
  38904. */
  38905. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38906. }
  38907. /**
  38908. * Defines an optimization used to turn particles off
  38909. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38910. */
  38911. class ParticlesOptimization extends SceneOptimization {
  38912. /**
  38913. * Gets a string describing the action executed by the current optimization
  38914. * @return description string
  38915. */
  38916. getDescription(): string;
  38917. /**
  38918. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38919. * @param scene defines the current scene where to apply this optimization
  38920. * @param optimizer defines the current optimizer
  38921. * @returns true if everything that can be done was applied
  38922. */
  38923. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38924. }
  38925. /**
  38926. * Defines an optimization used to turn render targets off
  38927. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38928. */
  38929. class RenderTargetsOptimization extends SceneOptimization {
  38930. /**
  38931. * Gets a string describing the action executed by the current optimization
  38932. * @return description string
  38933. */
  38934. getDescription(): string;
  38935. /**
  38936. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38937. * @param scene defines the current scene where to apply this optimization
  38938. * @param optimizer defines the current optimizer
  38939. * @returns true if everything that can be done was applied
  38940. */
  38941. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38942. }
  38943. /**
  38944. * Defines an optimization used to merge meshes with compatible materials
  38945. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38946. */
  38947. class MergeMeshesOptimization extends SceneOptimization {
  38948. private static _UpdateSelectionTree;
  38949. /**
  38950. * Gets or sets a boolean which defines if optimization octree has to be updated
  38951. */
  38952. /**
  38953. * Gets or sets a boolean which defines if optimization octree has to be updated
  38954. */
  38955. static UpdateSelectionTree: boolean;
  38956. /**
  38957. * Gets a string describing the action executed by the current optimization
  38958. * @return description string
  38959. */
  38960. getDescription(): string;
  38961. private _canBeMerged;
  38962. /**
  38963. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38964. * @param scene defines the current scene where to apply this optimization
  38965. * @param optimizer defines the current optimizer
  38966. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  38967. * @returns true if everything that can be done was applied
  38968. */
  38969. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  38970. }
  38971. /**
  38972. * Defines a list of options used by SceneOptimizer
  38973. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38974. */
  38975. class SceneOptimizerOptions {
  38976. /**
  38977. * Defines the target frame rate to reach (60 by default)
  38978. */
  38979. targetFrameRate: number;
  38980. /**
  38981. * Defines the interval between two checkes (2000ms by default)
  38982. */
  38983. trackerDuration: number;
  38984. /**
  38985. * Gets the list of optimizations to apply
  38986. */
  38987. optimizations: SceneOptimization[];
  38988. /**
  38989. * Creates a new list of options used by SceneOptimizer
  38990. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  38991. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  38992. */
  38993. constructor(
  38994. /**
  38995. * Defines the target frame rate to reach (60 by default)
  38996. */
  38997. targetFrameRate?: number,
  38998. /**
  38999. * Defines the interval between two checkes (2000ms by default)
  39000. */
  39001. trackerDuration?: number);
  39002. /**
  39003. * Add a new optimization
  39004. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  39005. * @returns the current SceneOptimizerOptions
  39006. */
  39007. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  39008. /**
  39009. * Add a new custom optimization
  39010. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  39011. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  39012. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  39013. * @returns the current SceneOptimizerOptions
  39014. */
  39015. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  39016. /**
  39017. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  39018. * @param targetFrameRate defines the target frame rate (60 by default)
  39019. * @returns a SceneOptimizerOptions object
  39020. */
  39021. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  39022. /**
  39023. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  39024. * @param targetFrameRate defines the target frame rate (60 by default)
  39025. * @returns a SceneOptimizerOptions object
  39026. */
  39027. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  39028. /**
  39029. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  39030. * @param targetFrameRate defines the target frame rate (60 by default)
  39031. * @returns a SceneOptimizerOptions object
  39032. */
  39033. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  39034. }
  39035. /**
  39036. * Class used to run optimizations in order to reach a target frame rate
  39037. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  39038. */
  39039. class SceneOptimizer implements IDisposable {
  39040. private _isRunning;
  39041. private _options;
  39042. private _scene;
  39043. private _currentPriorityLevel;
  39044. private _targetFrameRate;
  39045. private _trackerDuration;
  39046. private _currentFrameRate;
  39047. private _sceneDisposeObserver;
  39048. private _improvementMode;
  39049. /**
  39050. * Defines an observable called when the optimizer reaches the target frame rate
  39051. */
  39052. onSuccessObservable: Observable<SceneOptimizer>;
  39053. /**
  39054. * Defines an observable called when the optimizer enables an optimization
  39055. */
  39056. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  39057. /**
  39058. * Defines an observable called when the optimizer is not able to reach the target frame rate
  39059. */
  39060. onFailureObservable: Observable<SceneOptimizer>;
  39061. /**
  39062. * Gets a boolean indicating if the optimizer is in improvement mode
  39063. */
  39064. readonly isInImprovementMode: boolean;
  39065. /**
  39066. * Gets the current priority level (0 at start)
  39067. */
  39068. readonly currentPriorityLevel: number;
  39069. /**
  39070. * Gets the current frame rate checked by the SceneOptimizer
  39071. */
  39072. readonly currentFrameRate: number;
  39073. /**
  39074. * Gets or sets the current target frame rate (60 by default)
  39075. */
  39076. /**
  39077. * Gets or sets the current target frame rate (60 by default)
  39078. */
  39079. targetFrameRate: number;
  39080. /**
  39081. * Gets or sets the current interval between two checks (every 2000ms by default)
  39082. */
  39083. /**
  39084. * Gets or sets the current interval between two checks (every 2000ms by default)
  39085. */
  39086. trackerDuration: number;
  39087. /**
  39088. * Gets the list of active optimizations
  39089. */
  39090. readonly optimizations: SceneOptimization[];
  39091. /**
  39092. * Creates a new SceneOptimizer
  39093. * @param scene defines the scene to work on
  39094. * @param options defines the options to use with the SceneOptimizer
  39095. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  39096. * @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)
  39097. */
  39098. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  39099. /**
  39100. * Stops the current optimizer
  39101. */
  39102. stop(): void;
  39103. /**
  39104. * Reset the optimizer to initial step (current priority level = 0)
  39105. */
  39106. reset(): void;
  39107. /**
  39108. * Start the optimizer. By default it will try to reach a specific framerate
  39109. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  39110. */
  39111. start(): void;
  39112. private _checkCurrentState;
  39113. /**
  39114. * Release all resources
  39115. */
  39116. dispose(): void;
  39117. /**
  39118. * Helper function to create a SceneOptimizer with one single line of code
  39119. * @param scene defines the scene to work on
  39120. * @param options defines the options to use with the SceneOptimizer
  39121. * @param onSuccess defines a callback to call on success
  39122. * @param onFailure defines a callback to call on failure
  39123. * @returns the new SceneOptimizer object
  39124. */
  39125. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  39126. }
  39127. }
  39128. declare module BABYLON {
  39129. /**
  39130. * Class used to serialize a scene into a string
  39131. */
  39132. class SceneSerializer {
  39133. /**
  39134. * Clear cache used by a previous serialization
  39135. */
  39136. static ClearCache(): void;
  39137. /**
  39138. * Serialize a scene into a JSON compatible object
  39139. * @param scene defines the scene to serialize
  39140. * @returns a JSON compatible object
  39141. */
  39142. static Serialize(scene: Scene): any;
  39143. /**
  39144. * Serialize a mesh into a JSON compatible object
  39145. * @param toSerialize defines the mesh to serialize
  39146. * @param withParents defines if parents must be serialized as well
  39147. * @param withChildren defines if children must be serialized as well
  39148. * @returns a JSON compatible object
  39149. */
  39150. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  39151. }
  39152. }
  39153. declare module BABYLON {
  39154. /**
  39155. * Defines an array and its length.
  39156. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  39157. */
  39158. interface ISmartArrayLike<T> {
  39159. /**
  39160. * The data of the array.
  39161. */
  39162. data: Array<T>;
  39163. /**
  39164. * The active length of the array.
  39165. */
  39166. length: number;
  39167. }
  39168. /**
  39169. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  39170. */
  39171. class SmartArray<T> implements ISmartArrayLike<T> {
  39172. /**
  39173. * The full set of data from the array.
  39174. */
  39175. data: Array<T>;
  39176. /**
  39177. * The active length of the array.
  39178. */
  39179. length: number;
  39180. protected _id: number;
  39181. /**
  39182. * Instantiates a Smart Array.
  39183. * @param capacity defines the default capacity of the array.
  39184. */
  39185. constructor(capacity: number);
  39186. /**
  39187. * Pushes a value at the end of the active data.
  39188. * @param value defines the object to push in the array.
  39189. */
  39190. push(value: T): void;
  39191. /**
  39192. * Iterates over the active data and apply the lambda to them.
  39193. * @param func defines the action to apply on each value.
  39194. */
  39195. forEach(func: (content: T) => void): void;
  39196. /**
  39197. * Sorts the full sets of data.
  39198. * @param compareFn defines the comparison function to apply.
  39199. */
  39200. sort(compareFn: (a: T, b: T) => number): void;
  39201. /**
  39202. * Resets the active data to an empty array.
  39203. */
  39204. reset(): void;
  39205. /**
  39206. * Releases all the data from the array as well as the array.
  39207. */
  39208. dispose(): void;
  39209. /**
  39210. * Concats the active data with a given array.
  39211. * @param array defines the data to concatenate with.
  39212. */
  39213. concat(array: any): void;
  39214. /**
  39215. * Returns the position of a value in the active data.
  39216. * @param value defines the value to find the index for
  39217. * @returns the index if found in the active data otherwise -1
  39218. */
  39219. indexOf(value: T): number;
  39220. /**
  39221. * Returns whether an element is part of the active data.
  39222. * @param value defines the value to look for
  39223. * @returns true if found in the active data otherwise false
  39224. */
  39225. contains(value: T): boolean;
  39226. private static _GlobalId;
  39227. }
  39228. /**
  39229. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  39230. * The data in this array can only be present once
  39231. */
  39232. class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  39233. private _duplicateId;
  39234. /**
  39235. * Pushes a value at the end of the active data.
  39236. * THIS DOES NOT PREVENT DUPPLICATE DATA
  39237. * @param value defines the object to push in the array.
  39238. */
  39239. push(value: T): void;
  39240. /**
  39241. * Pushes a value at the end of the active data.
  39242. * If the data is already present, it won t be added again
  39243. * @param value defines the object to push in the array.
  39244. * @returns true if added false if it was already present
  39245. */
  39246. pushNoDuplicate(value: T): boolean;
  39247. /**
  39248. * Resets the active data to an empty array.
  39249. */
  39250. reset(): void;
  39251. /**
  39252. * Concats the active data with a given array.
  39253. * This ensures no dupplicate will be present in the result.
  39254. * @param array defines the data to concatenate with.
  39255. */
  39256. concatWithNoDuplicate(array: any): void;
  39257. }
  39258. }
  39259. declare module BABYLON {
  39260. /**
  39261. * This class implement a typical dictionary using a string as key and the generic type T as value.
  39262. * The underlying implementation relies on an associative array to ensure the best performances.
  39263. * The value can be anything including 'null' but except 'undefined'
  39264. */
  39265. class StringDictionary<T> {
  39266. /**
  39267. * This will clear this dictionary and copy the content from the 'source' one.
  39268. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  39269. * @param source the dictionary to take the content from and copy to this dictionary
  39270. */
  39271. copyFrom(source: StringDictionary<T>): void;
  39272. /**
  39273. * Get a value based from its key
  39274. * @param key the given key to get the matching value from
  39275. * @return the value if found, otherwise undefined is returned
  39276. */
  39277. get(key: string): T | undefined;
  39278. /**
  39279. * Get a value from its key or add it if it doesn't exist.
  39280. * This method will ensure you that a given key/data will be present in the dictionary.
  39281. * @param key the given key to get the matching value from
  39282. * @param factory the factory that will create the value if the key is not present in the dictionary.
  39283. * The factory will only be invoked if there's no data for the given key.
  39284. * @return the value corresponding to the key.
  39285. */
  39286. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  39287. /**
  39288. * Get a value from its key if present in the dictionary otherwise add it
  39289. * @param key the key to get the value from
  39290. * @param val if there's no such key/value pair in the dictionary add it with this value
  39291. * @return the value corresponding to the key
  39292. */
  39293. getOrAdd(key: string, val: T): T;
  39294. /**
  39295. * Check if there's a given key in the dictionary
  39296. * @param key the key to check for
  39297. * @return true if the key is present, false otherwise
  39298. */
  39299. contains(key: string): boolean;
  39300. /**
  39301. * Add a new key and its corresponding value
  39302. * @param key the key to add
  39303. * @param value the value corresponding to the key
  39304. * @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
  39305. */
  39306. add(key: string, value: T): boolean;
  39307. /**
  39308. * Update a specific value associated to a key
  39309. * @param key defines the key to use
  39310. * @param value defines the value to store
  39311. * @returns true if the value was updated (or false if the key was not found)
  39312. */
  39313. set(key: string, value: T): boolean;
  39314. /**
  39315. * Get the element of the given key and remove it from the dictionary
  39316. * @param key defines the key to search
  39317. * @returns the value associated with the key or null if not found
  39318. */
  39319. getAndRemove(key: string): Nullable<T>;
  39320. /**
  39321. * Remove a key/value from the dictionary.
  39322. * @param key the key to remove
  39323. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  39324. */
  39325. remove(key: string): boolean;
  39326. /**
  39327. * Clear the whole content of the dictionary
  39328. */
  39329. clear(): void;
  39330. /**
  39331. * Gets the current count
  39332. */
  39333. readonly count: number;
  39334. /**
  39335. * Execute a callback on each key/val of the dictionary.
  39336. * Note that you can remove any element in this dictionary in the callback implementation
  39337. * @param callback the callback to execute on a given key/value pair
  39338. */
  39339. forEach(callback: (key: string, val: T) => void): void;
  39340. /**
  39341. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  39342. * If the callback returns null or undefined the method will iterate to the next key/value pair
  39343. * Note that you can remove any element in this dictionary in the callback implementation
  39344. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  39345. * @returns the first item
  39346. */
  39347. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  39348. private _count;
  39349. private _data;
  39350. }
  39351. }
  39352. declare module BABYLON {
  39353. /**
  39354. * Class used to store custom tags
  39355. */
  39356. class Tags {
  39357. /**
  39358. * Adds support for tags on the given object
  39359. * @param obj defines the object to use
  39360. */
  39361. static EnableFor(obj: any): void;
  39362. /**
  39363. * Removes tags support
  39364. * @param obj defines the object to use
  39365. */
  39366. static DisableFor(obj: any): void;
  39367. /**
  39368. * Gets a boolean indicating if the given object has tags
  39369. * @param obj defines the object to use
  39370. * @returns a boolean
  39371. */
  39372. static HasTags(obj: any): boolean;
  39373. /**
  39374. * Gets the tags available on a given object
  39375. * @param obj defines the object to use
  39376. * @param asString defines if the tags must be returned as a string instead of an array of strings
  39377. * @returns the tags
  39378. */
  39379. static GetTags(obj: any, asString?: boolean): any;
  39380. /**
  39381. * Adds tags to an object
  39382. * @param obj defines the object to use
  39383. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  39384. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  39385. */
  39386. static AddTagsTo(obj: any, tagsString: string): void;
  39387. /**
  39388. * @hidden
  39389. */
  39390. static _AddTagTo(obj: any, tag: string): void;
  39391. /**
  39392. * Removes specific tags from a specific object
  39393. * @param obj defines the object to use
  39394. * @param tagsString defines the tags to remove
  39395. */
  39396. static RemoveTagsFrom(obj: any, tagsString: string): void;
  39397. /**
  39398. * @hidden
  39399. */
  39400. static _RemoveTagFrom(obj: any, tag: string): void;
  39401. /**
  39402. * Defines if tags hosted on an object match a given query
  39403. * @param obj defines the object to use
  39404. * @param tagsQuery defines the tag query
  39405. * @returns a boolean
  39406. */
  39407. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  39408. }
  39409. }
  39410. declare module BABYLON {
  39411. /**
  39412. * Class used to host texture specific utilities
  39413. */
  39414. class TextureTools {
  39415. /**
  39416. * Uses the GPU to create a copy texture rescaled at a given size
  39417. * @param texture Texture to copy from
  39418. * @param width defines the desired width
  39419. * @param height defines the desired height
  39420. * @param useBilinearMode defines if bilinear mode has to be used
  39421. * @return the generated texture
  39422. */
  39423. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  39424. /**
  39425. * Gets an environment BRDF texture for a given scene
  39426. * @param scene defines the hosting scene
  39427. * @returns the environment BRDF texture
  39428. */
  39429. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  39430. private static _environmentBRDFBase64Texture;
  39431. }
  39432. }
  39433. declare module BABYLON {
  39434. /**
  39435. * Based on jsTGALoader - Javascript loader for TGA file
  39436. * By Vincent Thibault
  39437. * @see http://blog.robrowser.com/javascript-tga-loader.html
  39438. */
  39439. class TGATools {
  39440. private static _TYPE_INDEXED;
  39441. private static _TYPE_RGB;
  39442. private static _TYPE_GREY;
  39443. private static _TYPE_RLE_INDEXED;
  39444. private static _TYPE_RLE_RGB;
  39445. private static _TYPE_RLE_GREY;
  39446. private static _ORIGIN_MASK;
  39447. private static _ORIGIN_SHIFT;
  39448. private static _ORIGIN_BL;
  39449. private static _ORIGIN_BR;
  39450. private static _ORIGIN_UL;
  39451. private static _ORIGIN_UR;
  39452. /**
  39453. * Gets the header of a TGA file
  39454. * @param data defines the TGA data
  39455. * @returns the header
  39456. */
  39457. static GetTGAHeader(data: Uint8Array): any;
  39458. /**
  39459. * Uploads TGA content to a Babylon Texture
  39460. * @hidden
  39461. */
  39462. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  39463. /** @hidden */
  39464. 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;
  39465. /** @hidden */
  39466. 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;
  39467. /** @hidden */
  39468. 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;
  39469. /** @hidden */
  39470. 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;
  39471. /** @hidden */
  39472. 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;
  39473. /** @hidden */
  39474. 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;
  39475. }
  39476. }
  39477. declare module BABYLON {
  39478. /**
  39479. * Interface for any object that can request an animation frame
  39480. */
  39481. interface ICustomAnimationFrameRequester {
  39482. /**
  39483. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  39484. */
  39485. renderFunction?: Function;
  39486. /**
  39487. * Called to request the next frame to render to
  39488. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  39489. */
  39490. requestAnimationFrame: Function;
  39491. /**
  39492. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  39493. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  39494. */
  39495. requestID?: number;
  39496. }
  39497. /**
  39498. * Interface containing an array of animations
  39499. */
  39500. interface IAnimatable {
  39501. /**
  39502. * Array of animations
  39503. */
  39504. animations: Array<Animation>;
  39505. }
  39506. /** Interface used by value gradients (color, factor, ...) */
  39507. interface IValueGradient {
  39508. /**
  39509. * Gets or sets the gradient value (between 0 and 1)
  39510. */
  39511. gradient: number;
  39512. }
  39513. /** Class used to store color4 gradient */
  39514. class ColorGradient implements IValueGradient {
  39515. /**
  39516. * Gets or sets the gradient value (between 0 and 1)
  39517. */
  39518. gradient: number;
  39519. /**
  39520. * Gets or sets first associated color
  39521. */
  39522. color1: Color4;
  39523. /**
  39524. * Gets or sets second associated color
  39525. */
  39526. color2?: Color4;
  39527. /**
  39528. * Will get a color picked randomly between color1 and color2.
  39529. * If color2 is undefined then color1 will be used
  39530. * @param result defines the target Color4 to store the result in
  39531. */
  39532. getColorToRef(result: Color4): void;
  39533. }
  39534. /** Class used to store color 3 gradient */
  39535. class Color3Gradient implements IValueGradient {
  39536. /**
  39537. * Gets or sets the gradient value (between 0 and 1)
  39538. */
  39539. gradient: number;
  39540. /**
  39541. * Gets or sets the associated color
  39542. */
  39543. color: Color3;
  39544. }
  39545. /** Class used to store factor gradient */
  39546. class FactorGradient implements IValueGradient {
  39547. /**
  39548. * Gets or sets the gradient value (between 0 and 1)
  39549. */
  39550. gradient: number;
  39551. /**
  39552. * Gets or sets first associated factor
  39553. */
  39554. factor1: number;
  39555. /**
  39556. * Gets or sets second associated factor
  39557. */
  39558. factor2?: number;
  39559. /**
  39560. * Will get a number picked randomly between factor1 and factor2.
  39561. * If factor2 is undefined then factor1 will be used
  39562. * @returns the picked number
  39563. */
  39564. getFactor(): number;
  39565. }
  39566. /**
  39567. * @ignore
  39568. * Application error to support additional information when loading a file
  39569. */
  39570. class LoadFileError extends Error {
  39571. /** defines the optional XHR request */
  39572. request?: XMLHttpRequest | undefined;
  39573. private static _setPrototypeOf;
  39574. /**
  39575. * Creates a new LoadFileError
  39576. * @param message defines the message of the error
  39577. * @param request defines the optional XHR request
  39578. */
  39579. constructor(message: string,
  39580. /** defines the optional XHR request */
  39581. request?: XMLHttpRequest | undefined);
  39582. }
  39583. /**
  39584. * Class used to define a retry strategy when error happens while loading assets
  39585. */
  39586. class RetryStrategy {
  39587. /**
  39588. * Function used to defines an exponential back off strategy
  39589. * @param maxRetries defines the maximum number of retries (3 by default)
  39590. * @param baseInterval defines the interval between retries
  39591. * @returns the strategy function to use
  39592. */
  39593. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  39594. }
  39595. /**
  39596. * File request interface
  39597. */
  39598. interface IFileRequest {
  39599. /**
  39600. * Raised when the request is complete (success or error).
  39601. */
  39602. onCompleteObservable: Observable<IFileRequest>;
  39603. /**
  39604. * Aborts the request for a file.
  39605. */
  39606. abort: () => void;
  39607. }
  39608. /**
  39609. * Class containing a set of static utilities functions
  39610. */
  39611. class Tools {
  39612. /**
  39613. * Gets or sets the base URL to use to load assets
  39614. */
  39615. static BaseUrl: string;
  39616. /**
  39617. * Enable/Disable Custom HTTP Request Headers globally.
  39618. * default = false
  39619. * @see CustomRequestHeaders
  39620. */
  39621. static UseCustomRequestHeaders: boolean;
  39622. /**
  39623. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  39624. * i.e. when loading files, where the server/service expects an Authorization header.
  39625. * @see InjectCustomRequestHeaders injects them to an XMLHttpRequest
  39626. */
  39627. static CustomRequestHeaders: {
  39628. [key: string]: string;
  39629. };
  39630. /**
  39631. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  39632. */
  39633. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  39634. /**
  39635. * Default behaviour for cors in the application.
  39636. * It can be a string if the expected behavior is identical in the entire app.
  39637. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  39638. */
  39639. static CorsBehavior: string | ((url: string | string[]) => string);
  39640. /**
  39641. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  39642. * @ignorenaming
  39643. */
  39644. static UseFallbackTexture: boolean;
  39645. /**
  39646. * Use this object to register external classes like custom textures or material
  39647. * to allow the laoders to instantiate them
  39648. */
  39649. static RegisteredExternalClasses: {
  39650. [key: string]: Object;
  39651. };
  39652. /**
  39653. * Texture content used if a texture cannot loaded
  39654. * @ignorenaming
  39655. */
  39656. static fallbackTexture: string;
  39657. /**
  39658. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  39659. * @param u defines the coordinate on X axis
  39660. * @param v defines the coordinate on Y axis
  39661. * @param width defines the width of the source data
  39662. * @param height defines the height of the source data
  39663. * @param pixels defines the source byte array
  39664. * @param color defines the output color
  39665. */
  39666. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  39667. /**
  39668. * Interpolates between a and b via alpha
  39669. * @param a The lower value (returned when alpha = 0)
  39670. * @param b The upper value (returned when alpha = 1)
  39671. * @param alpha The interpolation-factor
  39672. * @return The mixed value
  39673. */
  39674. static Mix(a: number, b: number, alpha: number): number;
  39675. /**
  39676. * Tries to instantiate a new object from a given class name
  39677. * @param className defines the class name to instantiate
  39678. * @returns the new object or null if the system was not able to do the instantiation
  39679. */
  39680. static Instantiate(className: string): any;
  39681. /**
  39682. * Provides a slice function that will work even on IE
  39683. * @param data defines the array to slice
  39684. * @param start defines the start of the data (optional)
  39685. * @param end defines the end of the data (optional)
  39686. * @returns the new sliced array
  39687. */
  39688. static Slice<T>(data: T, start?: number, end?: number): T;
  39689. /**
  39690. * Polyfill for setImmediate
  39691. * @param action defines the action to execute after the current execution block
  39692. */
  39693. static SetImmediate(action: () => void): void;
  39694. /**
  39695. * Function indicating if a number is an exponent of 2
  39696. * @param value defines the value to test
  39697. * @returns true if the value is an exponent of 2
  39698. */
  39699. static IsExponentOfTwo(value: number): boolean;
  39700. private static _tmpFloatArray;
  39701. /**
  39702. * Returns the nearest 32-bit single precision float representation of a Number
  39703. * @param value A Number. If the parameter is of a different type, it will get converted
  39704. * to a number or to NaN if it cannot be converted
  39705. * @returns number
  39706. */
  39707. static FloatRound(value: number): number;
  39708. /**
  39709. * Find the next highest power of two.
  39710. * @param x Number to start search from.
  39711. * @return Next highest power of two.
  39712. */
  39713. static CeilingPOT(x: number): number;
  39714. /**
  39715. * Find the next lowest power of two.
  39716. * @param x Number to start search from.
  39717. * @return Next lowest power of two.
  39718. */
  39719. static FloorPOT(x: number): number;
  39720. /**
  39721. * Find the nearest power of two.
  39722. * @param x Number to start search from.
  39723. * @return Next nearest power of two.
  39724. */
  39725. static NearestPOT(x: number): number;
  39726. /**
  39727. * Get the closest exponent of two
  39728. * @param value defines the value to approximate
  39729. * @param max defines the maximum value to return
  39730. * @param mode defines how to define the closest value
  39731. * @returns closest exponent of two of the given value
  39732. */
  39733. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  39734. /**
  39735. * Extracts the filename from a path
  39736. * @param path defines the path to use
  39737. * @returns the filename
  39738. */
  39739. static GetFilename(path: string): string;
  39740. /**
  39741. * Extracts the "folder" part of a path (everything before the filename).
  39742. * @param uri The URI to extract the info from
  39743. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  39744. * @returns The "folder" part of the path
  39745. */
  39746. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  39747. /**
  39748. * Extracts text content from a DOM element hierarchy
  39749. * @param element defines the root element
  39750. * @returns a string
  39751. */
  39752. static GetDOMTextContent(element: HTMLElement): string;
  39753. /**
  39754. * Convert an angle in radians to degrees
  39755. * @param angle defines the angle to convert
  39756. * @returns the angle in degrees
  39757. */
  39758. static ToDegrees(angle: number): number;
  39759. /**
  39760. * Convert an angle in degrees to radians
  39761. * @param angle defines the angle to convert
  39762. * @returns the angle in radians
  39763. */
  39764. static ToRadians(angle: number): number;
  39765. /**
  39766. * Encode a buffer to a base64 string
  39767. * @param buffer defines the buffer to encode
  39768. * @returns the encoded string
  39769. */
  39770. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  39771. /**
  39772. * Extracts minimum and maximum values from a list of indexed positions
  39773. * @param positions defines the positions to use
  39774. * @param indices defines the indices to the positions
  39775. * @param indexStart defines the start index
  39776. * @param indexCount defines the end index
  39777. * @param bias defines bias value to add to the result
  39778. * @return minimum and maximum values
  39779. */
  39780. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  39781. minimum: Vector3;
  39782. maximum: Vector3;
  39783. };
  39784. /**
  39785. * Extracts minimum and maximum values from a list of positions
  39786. * @param positions defines the positions to use
  39787. * @param start defines the start index in the positions array
  39788. * @param count defines the number of positions to handle
  39789. * @param bias defines bias value to add to the result
  39790. * @param stride defines the stride size to use (distance between two positions in the positions array)
  39791. * @return minimum and maximum values
  39792. */
  39793. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  39794. minimum: Vector3;
  39795. maximum: Vector3;
  39796. };
  39797. /**
  39798. * Returns an array if obj is not an array
  39799. * @param obj defines the object to evaluate as an array
  39800. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  39801. * @returns either obj directly if obj is an array or a new array containing obj
  39802. */
  39803. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  39804. /**
  39805. * Returns an array of the given size filled with element built from the given constructor and the paramters
  39806. * @param size the number of element to construct and put in the array
  39807. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  39808. * @returns a new array filled with new objects
  39809. */
  39810. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  39811. /**
  39812. * Gets the pointer prefix to use
  39813. * @returns "pointer" if touch is enabled. Else returns "mouse"
  39814. */
  39815. static GetPointerPrefix(): string;
  39816. /**
  39817. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  39818. * @param func - the function to be called
  39819. * @param requester - the object that will request the next frame. Falls back to window.
  39820. * @returns frame number
  39821. */
  39822. static QueueNewFrame(func: () => void, requester?: any): number;
  39823. /**
  39824. * Ask the browser to promote the current element to fullscreen rendering mode
  39825. * @param element defines the DOM element to promote
  39826. */
  39827. static RequestFullscreen(element: HTMLElement): void;
  39828. /**
  39829. * Asks the browser to exit fullscreen mode
  39830. */
  39831. static ExitFullscreen(): void;
  39832. /**
  39833. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  39834. * @param url define the url we are trying
  39835. * @param element define the dom element where to configure the cors policy
  39836. */
  39837. static SetCorsBehavior(url: string | string[], element: {
  39838. crossOrigin: string | null;
  39839. }): void;
  39840. /**
  39841. * Removes unwanted characters from an url
  39842. * @param url defines the url to clean
  39843. * @returns the cleaned url
  39844. */
  39845. static CleanUrl(url: string): string;
  39846. /**
  39847. * Gets or sets a function used to pre-process url before using them to load assets
  39848. */
  39849. static PreprocessUrl: (url: string) => string;
  39850. /**
  39851. * Loads an image as an HTMLImageElement.
  39852. * @param input url string, ArrayBuffer, or Blob to load
  39853. * @param onLoad callback called when the image successfully loads
  39854. * @param onError callback called when the image fails to load
  39855. * @param offlineProvider offline provider for caching
  39856. * @returns the HTMLImageElement of the loaded image
  39857. */
  39858. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  39859. /**
  39860. * Loads a file
  39861. * @param url url string, ArrayBuffer, or Blob to load
  39862. * @param onSuccess callback called when the file successfully loads
  39863. * @param onProgress callback called while file is loading (if the server supports this mode)
  39864. * @param offlineProvider defines the offline provider for caching
  39865. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  39866. * @param onError callback called when the file fails to load
  39867. * @returns a file request object
  39868. */
  39869. 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;
  39870. /**
  39871. * Load a script (identified by an url). When the url returns, the
  39872. * content of this file is added into a new script element, attached to the DOM (body element)
  39873. * @param scriptUrl defines the url of the script to laod
  39874. * @param onSuccess defines the callback called when the script is loaded
  39875. * @param onError defines the callback to call if an error occurs
  39876. */
  39877. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  39878. /**
  39879. * Loads a file from a blob
  39880. * @param fileToLoad defines the blob to use
  39881. * @param callback defines the callback to call when data is loaded
  39882. * @param progressCallback defines the callback to call during loading process
  39883. * @returns a file request object
  39884. */
  39885. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  39886. /**
  39887. * Loads a file
  39888. * @param fileToLoad defines the file to load
  39889. * @param callback defines the callback to call when data is loaded
  39890. * @param progressCallBack defines the callback to call during loading process
  39891. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  39892. * @returns a file request object
  39893. */
  39894. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  39895. /**
  39896. * Creates a data url from a given string content
  39897. * @param content defines the content to convert
  39898. * @returns the new data url link
  39899. */
  39900. static FileAsURL(content: string): string;
  39901. /**
  39902. * Format the given number to a specific decimal format
  39903. * @param value defines the number to format
  39904. * @param decimals defines the number of decimals to use
  39905. * @returns the formatted string
  39906. */
  39907. static Format(value: number, decimals?: number): string;
  39908. /**
  39909. * Checks if a given vector is inside a specific range
  39910. * @param v defines the vector to test
  39911. * @param min defines the minimum range
  39912. * @param max defines the maximum range
  39913. */
  39914. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  39915. /**
  39916. * Tries to copy an object by duplicating every property
  39917. * @param source defines the source object
  39918. * @param destination defines the target object
  39919. * @param doNotCopyList defines a list of properties to avoid
  39920. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  39921. */
  39922. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  39923. /**
  39924. * Gets a boolean indicating if the given object has no own property
  39925. * @param obj defines the object to test
  39926. * @returns true if object has no own property
  39927. */
  39928. static IsEmpty(obj: any): boolean;
  39929. /**
  39930. * Function used to register events at window level
  39931. * @param events defines the events to register
  39932. */
  39933. static RegisterTopRootEvents(events: {
  39934. name: string;
  39935. handler: Nullable<(e: FocusEvent) => any>;
  39936. }[]): void;
  39937. /**
  39938. * Function used to unregister events from window level
  39939. * @param events defines the events to unregister
  39940. */
  39941. static UnregisterTopRootEvents(events: {
  39942. name: string;
  39943. handler: Nullable<(e: FocusEvent) => any>;
  39944. }[]): void;
  39945. /**
  39946. * Dumps the current bound framebuffer
  39947. * @param width defines the rendering width
  39948. * @param height defines the rendering height
  39949. * @param engine defines the hosting engine
  39950. * @param successCallback defines the callback triggered once the data are available
  39951. * @param mimeType defines the mime type of the result
  39952. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  39953. */
  39954. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  39955. /**
  39956. * Converts the canvas data to blob.
  39957. * This acts as a polyfill for browsers not supporting the to blob function.
  39958. * @param canvas Defines the canvas to extract the data from
  39959. * @param successCallback Defines the callback triggered once the data are available
  39960. * @param mimeType Defines the mime type of the result
  39961. */
  39962. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  39963. /**
  39964. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  39965. * @param successCallback defines the callback triggered once the data are available
  39966. * @param mimeType defines the mime type of the result
  39967. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  39968. */
  39969. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  39970. /**
  39971. * Downloads a blob in the browser
  39972. * @param blob defines the blob to download
  39973. * @param fileName defines the name of the downloaded file
  39974. */
  39975. static Download(blob: Blob, fileName: string): void;
  39976. /**
  39977. * Captures a screenshot of the current rendering
  39978. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  39979. * @param engine defines the rendering engine
  39980. * @param camera defines the source camera
  39981. * @param size This parameter can be set to a single number or to an object with the
  39982. * following (optional) properties: precision, width, height. If a single number is passed,
  39983. * it will be used for both width and height. If an object is passed, the screenshot size
  39984. * will be derived from the parameters. The precision property is a multiplier allowing
  39985. * rendering at a higher or lower resolution
  39986. * @param successCallback defines the callback receives a single parameter which contains the
  39987. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  39988. * src parameter of an <img> to display it
  39989. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  39990. * Check your browser for supported MIME types
  39991. */
  39992. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  39993. /**
  39994. * Generates an image screenshot from the specified camera.
  39995. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  39996. * @param engine The engine to use for rendering
  39997. * @param camera The camera to use for rendering
  39998. * @param size This parameter can be set to a single number or to an object with the
  39999. * following (optional) properties: precision, width, height. If a single number is passed,
  40000. * it will be used for both width and height. If an object is passed, the screenshot size
  40001. * will be derived from the parameters. The precision property is a multiplier allowing
  40002. * rendering at a higher or lower resolution
  40003. * @param successCallback The callback receives a single parameter which contains the
  40004. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  40005. * src parameter of an <img> to display it
  40006. * @param mimeType The MIME type of the screenshot image (default: image/png).
  40007. * Check your browser for supported MIME types
  40008. * @param samples Texture samples (default: 1)
  40009. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  40010. * @param fileName A name for for the downloaded file.
  40011. */
  40012. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  40013. /**
  40014. * Validates if xhr data is correct
  40015. * @param xhr defines the request to validate
  40016. * @param dataType defines the expected data type
  40017. * @returns true if data is correct
  40018. */
  40019. static ValidateXHRData(xhr: XMLHttpRequest, dataType?: number): boolean;
  40020. /**
  40021. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  40022. * Be aware Math.random() could cause collisions, but:
  40023. * "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"
  40024. * @returns a pseudo random id
  40025. */
  40026. static RandomId(): string;
  40027. /**
  40028. * Test if the given uri is a base64 string
  40029. * @param uri The uri to test
  40030. * @return True if the uri is a base64 string or false otherwise
  40031. */
  40032. static IsBase64(uri: string): boolean;
  40033. /**
  40034. * Decode the given base64 uri.
  40035. * @param uri The uri to decode
  40036. * @return The decoded base64 data.
  40037. */
  40038. static DecodeBase64(uri: string): ArrayBuffer;
  40039. /**
  40040. * No log
  40041. */
  40042. static readonly NoneLogLevel: number;
  40043. /**
  40044. * Only message logs
  40045. */
  40046. static readonly MessageLogLevel: number;
  40047. /**
  40048. * Only warning logs
  40049. */
  40050. static readonly WarningLogLevel: number;
  40051. /**
  40052. * Only error logs
  40053. */
  40054. static readonly ErrorLogLevel: number;
  40055. /**
  40056. * All logs
  40057. */
  40058. static readonly AllLogLevel: number;
  40059. private static _LogCache;
  40060. /**
  40061. * Gets a value indicating the number of loading errors
  40062. * @ignorenaming
  40063. */
  40064. static errorsCount: number;
  40065. /**
  40066. * Callback called when a new log is added
  40067. */
  40068. static OnNewCacheEntry: (entry: string) => void;
  40069. private static _AddLogEntry;
  40070. private static _FormatMessage;
  40071. private static _LogDisabled;
  40072. private static _LogEnabled;
  40073. private static _WarnDisabled;
  40074. private static _WarnEnabled;
  40075. private static _ErrorDisabled;
  40076. private static _ErrorEnabled;
  40077. /**
  40078. * Log a message to the console
  40079. */
  40080. static Log: (message: string) => void;
  40081. /**
  40082. * Write a warning message to the console
  40083. */
  40084. static Warn: (message: string) => void;
  40085. /**
  40086. * Write an error message to the console
  40087. */
  40088. static Error: (message: string) => void;
  40089. /**
  40090. * Gets current log cache (list of logs)
  40091. */
  40092. static readonly LogCache: string;
  40093. /**
  40094. * Clears the log cache
  40095. */
  40096. static ClearLogCache(): void;
  40097. /**
  40098. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  40099. */
  40100. static LogLevels: number;
  40101. /**
  40102. * Checks if the loaded document was accessed via `file:`-Protocol.
  40103. * @returns boolean
  40104. */
  40105. static IsFileURL(): boolean;
  40106. /**
  40107. * Checks if the window object exists
  40108. * @returns true if the window object exists
  40109. */
  40110. static IsWindowObjectExist(): boolean;
  40111. /**
  40112. * No performance log
  40113. */
  40114. static readonly PerformanceNoneLogLevel: number;
  40115. /**
  40116. * Use user marks to log performance
  40117. */
  40118. static readonly PerformanceUserMarkLogLevel: number;
  40119. /**
  40120. * Log performance to the console
  40121. */
  40122. static readonly PerformanceConsoleLogLevel: number;
  40123. private static _performance;
  40124. /**
  40125. * Sets the current performance log level
  40126. */
  40127. static PerformanceLogLevel: number;
  40128. private static _StartPerformanceCounterDisabled;
  40129. private static _EndPerformanceCounterDisabled;
  40130. private static _StartUserMark;
  40131. private static _EndUserMark;
  40132. private static _StartPerformanceConsole;
  40133. private static _EndPerformanceConsole;
  40134. /**
  40135. * Injects the @see CustomRequestHeaders into the given request
  40136. * @param request the request that should be used for injection
  40137. */
  40138. static InjectCustomRequestHeaders(request: XMLHttpRequest): void;
  40139. /**
  40140. * Starts a performance counter
  40141. */
  40142. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  40143. /**
  40144. * Ends a specific performance coutner
  40145. */
  40146. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  40147. /**
  40148. * Gets either window.performance.now() if supported or Date.now() else
  40149. */
  40150. static readonly Now: number;
  40151. /**
  40152. * This method will return the name of the class used to create the instance of the given object.
  40153. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  40154. * @param object the object to get the class name from
  40155. * @param isType defines if the object is actually a type
  40156. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  40157. */
  40158. static GetClassName(object: any, isType?: boolean): string;
  40159. /**
  40160. * Gets the first element of an array satisfying a given predicate
  40161. * @param array defines the array to browse
  40162. * @param predicate defines the predicate to use
  40163. * @returns null if not found or the element
  40164. */
  40165. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  40166. /**
  40167. * This method will return the name of the full name of the class, including its owning module (if any).
  40168. * 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).
  40169. * @param object the object to get the class name from
  40170. * @param isType defines if the object is actually a type
  40171. * @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.
  40172. * @ignorenaming
  40173. */
  40174. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  40175. /**
  40176. * Returns a promise that resolves after the given amount of time.
  40177. * @param delay Number of milliseconds to delay
  40178. * @returns Promise that resolves after the given amount of time
  40179. */
  40180. static DelayAsync(delay: number): Promise<void>;
  40181. /**
  40182. * Gets the current gradient from an array of IValueGradient
  40183. * @param ratio defines the current ratio to get
  40184. * @param gradients defines the array of IValueGradient
  40185. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  40186. */
  40187. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  40188. }
  40189. /**
  40190. * This class is used to track a performance counter which is number based.
  40191. * The user has access to many properties which give statistics of different nature.
  40192. *
  40193. * The implementer can track two kinds of Performance Counter: time and count.
  40194. * 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.
  40195. * 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.
  40196. */
  40197. class PerfCounter {
  40198. /**
  40199. * Gets or sets a global boolean to turn on and off all the counters
  40200. */
  40201. static Enabled: boolean;
  40202. /**
  40203. * Returns the smallest value ever
  40204. */
  40205. readonly min: number;
  40206. /**
  40207. * Returns the biggest value ever
  40208. */
  40209. readonly max: number;
  40210. /**
  40211. * Returns the average value since the performance counter is running
  40212. */
  40213. readonly average: number;
  40214. /**
  40215. * Returns the average value of the last second the counter was monitored
  40216. */
  40217. readonly lastSecAverage: number;
  40218. /**
  40219. * Returns the current value
  40220. */
  40221. readonly current: number;
  40222. /**
  40223. * Gets the accumulated total
  40224. */
  40225. readonly total: number;
  40226. /**
  40227. * Gets the total value count
  40228. */
  40229. readonly count: number;
  40230. /**
  40231. * Creates a new counter
  40232. */
  40233. constructor();
  40234. /**
  40235. * Call this method to start monitoring a new frame.
  40236. * 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.
  40237. */
  40238. fetchNewFrame(): void;
  40239. /**
  40240. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  40241. * @param newCount the count value to add to the monitored count
  40242. * @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.
  40243. */
  40244. addCount(newCount: number, fetchResult: boolean): void;
  40245. /**
  40246. * Start monitoring this performance counter
  40247. */
  40248. beginMonitoring(): void;
  40249. /**
  40250. * Compute the time lapsed since the previous beginMonitoring() call.
  40251. * @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
  40252. */
  40253. endMonitoring(newFrame?: boolean): void;
  40254. private _fetchResult;
  40255. private _startMonitoringTime;
  40256. private _min;
  40257. private _max;
  40258. private _average;
  40259. private _current;
  40260. private _totalValueCount;
  40261. private _totalAccumulated;
  40262. private _lastSecAverage;
  40263. private _lastSecAccumulated;
  40264. private _lastSecTime;
  40265. private _lastSecValueCount;
  40266. }
  40267. /**
  40268. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  40269. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  40270. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  40271. * @param name The name of the class, case should be preserved
  40272. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  40273. */
  40274. function className(name: string, module?: string): (target: Object) => void;
  40275. /**
  40276. * An implementation of a loop for asynchronous functions.
  40277. */
  40278. class AsyncLoop {
  40279. /**
  40280. * Defines the number of iterations for the loop
  40281. */
  40282. iterations: number;
  40283. /**
  40284. * Defines the current index of the loop.
  40285. */
  40286. index: number;
  40287. private _done;
  40288. private _fn;
  40289. private _successCallback;
  40290. /**
  40291. * Constructor.
  40292. * @param iterations the number of iterations.
  40293. * @param func the function to run each iteration
  40294. * @param successCallback the callback that will be called upon succesful execution
  40295. * @param offset starting offset.
  40296. */
  40297. constructor(
  40298. /**
  40299. * Defines the number of iterations for the loop
  40300. */
  40301. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  40302. /**
  40303. * Execute the next iteration. Must be called after the last iteration was finished.
  40304. */
  40305. executeNext(): void;
  40306. /**
  40307. * Break the loop and run the success callback.
  40308. */
  40309. breakLoop(): void;
  40310. /**
  40311. * Create and run an async loop.
  40312. * @param iterations the number of iterations.
  40313. * @param fn the function to run each iteration
  40314. * @param successCallback the callback that will be called upon succesful execution
  40315. * @param offset starting offset.
  40316. * @returns the created async loop object
  40317. */
  40318. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  40319. /**
  40320. * A for-loop that will run a given number of iterations synchronous and the rest async.
  40321. * @param iterations total number of iterations
  40322. * @param syncedIterations number of synchronous iterations in each async iteration.
  40323. * @param fn the function to call each iteration.
  40324. * @param callback a success call back that will be called when iterating stops.
  40325. * @param breakFunction a break condition (optional)
  40326. * @param timeout timeout settings for the setTimeout function. default - 0.
  40327. * @returns the created async loop object
  40328. */
  40329. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  40330. }
  40331. }
  40332. interface HTMLCanvasElement {
  40333. /** Track wether a record is in progress */
  40334. isRecording: boolean;
  40335. /** Capture Stream method defined by some browsers */
  40336. captureStream(fps?: number): MediaStream;
  40337. }
  40338. interface MediaRecorder {
  40339. /** Starts recording */
  40340. start(timeSlice: number): void;
  40341. /** Stops recording */
  40342. stop(): void;
  40343. /** Event raised when an error arised. */
  40344. onerror: (event: ErrorEvent) => void;
  40345. /** Event raised when the recording stops. */
  40346. onstop: (event: Event) => void;
  40347. /** Event raised when a new chunk of data is available and should be tracked. */
  40348. ondataavailable: (event: Event) => void;
  40349. }
  40350. interface MediaRecorderOptions {
  40351. /** The mime type you want to use as the recording container for the new MediaRecorder */
  40352. mimeType?: string;
  40353. /** The chosen bitrate for the audio component of the media. */
  40354. audioBitsPerSecond?: number;
  40355. /** The chosen bitrate for the video component of the media. */
  40356. videoBitsPerSecond?: number;
  40357. /** 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. */
  40358. bitsPerSecond?: number;
  40359. }
  40360. interface MediaRecorderConstructor {
  40361. /**
  40362. * A reference to the prototype.
  40363. */
  40364. readonly prototype: MediaRecorder;
  40365. /**
  40366. * Creates a new MediaRecorder.
  40367. * @param stream Defines the stream to record.
  40368. * @param options Defines the options for the recorder available in the type MediaRecorderOptions.
  40369. */
  40370. new (stream: MediaStream, options?: MediaRecorderOptions): MediaRecorder;
  40371. }
  40372. /**
  40373. * MediaRecoreder object available in some browsers.
  40374. */
  40375. declare var MediaRecorder: MediaRecorderConstructor;
  40376. declare module BABYLON {
  40377. /**
  40378. * This represents the different options avilable for the video capture.
  40379. */
  40380. interface VideoRecorderOptions {
  40381. /** Defines the mime type of the video */
  40382. mimeType: string;
  40383. /** Defines the video the video should be recorded at */
  40384. fps: number;
  40385. /** Defines the chunk size for the recording data */
  40386. recordChunckSize: number;
  40387. }
  40388. /**
  40389. * This can helps recording videos from BabylonJS.
  40390. * This is based on the available WebRTC functionalities of the browser.
  40391. *
  40392. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  40393. */
  40394. class VideoRecorder {
  40395. private static readonly _defaultOptions;
  40396. /**
  40397. * Returns wehther or not the VideoRecorder is available in your browser.
  40398. * @param engine Defines the Babylon Engine to check the support for
  40399. * @returns true if supported otherwise false
  40400. */
  40401. static IsSupported(engine: Engine): boolean;
  40402. private readonly _options;
  40403. private _canvas;
  40404. private _mediaRecorder;
  40405. private _recordedChunks;
  40406. private _fileName;
  40407. private _resolve;
  40408. private _reject;
  40409. /**
  40410. * True wether a recording is already in progress.
  40411. */
  40412. readonly isRecording: boolean;
  40413. /**
  40414. * Create a new VideoCapture object which can help converting what you see in Babylon to
  40415. * a video file.
  40416. * @param engine Defines the BabylonJS Engine you wish to record
  40417. * @param options Defines options that can be used to customized the capture
  40418. */
  40419. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  40420. /**
  40421. * Stops the current recording before the default capture timeout passed in the startRecording
  40422. * functions.
  40423. */
  40424. stopRecording(): void;
  40425. /**
  40426. * Starts recording the canvas for a max duration specified in parameters.
  40427. * @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.
  40428. * @param maxDuration Defines the maximum recording time in seconds.
  40429. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  40430. * @return a promise callback at the end of the recording with the video data in Blob.
  40431. */
  40432. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  40433. /**
  40434. * Releases internal resources used during the recording.
  40435. */
  40436. dispose(): void;
  40437. private _handleDataAvailable;
  40438. private _handleError;
  40439. private _handleStop;
  40440. }
  40441. }
  40442. declare module BABYLON {
  40443. /**
  40444. * Defines the potential axis of a Joystick
  40445. */
  40446. enum JoystickAxis {
  40447. /** X axis */
  40448. X = 0,
  40449. /** Y axis */
  40450. Y = 1,
  40451. /** Z axis */
  40452. Z = 2
  40453. }
  40454. /**
  40455. * Class used to define virtual joystick (used in touch mode)
  40456. */
  40457. class VirtualJoystick {
  40458. /**
  40459. * Gets or sets a boolean indicating that left and right values must be inverted
  40460. */
  40461. reverseLeftRight: boolean;
  40462. /**
  40463. * Gets or sets a boolean indicating that up and down values must be inverted
  40464. */
  40465. reverseUpDown: boolean;
  40466. /**
  40467. * Gets the offset value for the position (ie. the change of the position value)
  40468. */
  40469. deltaPosition: Vector3;
  40470. /**
  40471. * Gets a boolean indicating if the virtual joystick was pressed
  40472. */
  40473. pressed: boolean;
  40474. /**
  40475. * Canvas the virtual joystick will render onto, default z-index of this is 5
  40476. */
  40477. static Canvas: Nullable<HTMLCanvasElement>;
  40478. private static _globalJoystickIndex;
  40479. private static vjCanvasContext;
  40480. private static vjCanvasWidth;
  40481. private static vjCanvasHeight;
  40482. private static halfWidth;
  40483. private _action;
  40484. private _axisTargetedByLeftAndRight;
  40485. private _axisTargetedByUpAndDown;
  40486. private _joystickSensibility;
  40487. private _inversedSensibility;
  40488. private _joystickPointerID;
  40489. private _joystickColor;
  40490. private _joystickPointerPos;
  40491. private _joystickPreviousPointerPos;
  40492. private _joystickPointerStartPos;
  40493. private _deltaJoystickVector;
  40494. private _leftJoystick;
  40495. private _touches;
  40496. private _onPointerDownHandlerRef;
  40497. private _onPointerMoveHandlerRef;
  40498. private _onPointerUpHandlerRef;
  40499. private _onResize;
  40500. /**
  40501. * Creates a new virtual joystick
  40502. * @param leftJoystick defines that the joystick is for left hand (false by default)
  40503. */
  40504. constructor(leftJoystick?: boolean);
  40505. /**
  40506. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  40507. * @param newJoystickSensibility defines the new sensibility
  40508. */
  40509. setJoystickSensibility(newJoystickSensibility: number): void;
  40510. private _onPointerDown;
  40511. private _onPointerMove;
  40512. private _onPointerUp;
  40513. /**
  40514. * Change the color of the virtual joystick
  40515. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  40516. */
  40517. setJoystickColor(newColor: string): void;
  40518. /**
  40519. * Defines a callback to call when the joystick is touched
  40520. * @param action defines the callback
  40521. */
  40522. setActionOnTouch(action: () => any): void;
  40523. /**
  40524. * Defines which axis you'd like to control for left & right
  40525. * @param axis defines the axis to use
  40526. */
  40527. setAxisForLeftRight(axis: JoystickAxis): void;
  40528. /**
  40529. * Defines which axis you'd like to control for up & down
  40530. * @param axis defines the axis to use
  40531. */
  40532. setAxisForUpDown(axis: JoystickAxis): void;
  40533. private _drawVirtualJoystick;
  40534. /**
  40535. * Release internal HTML canvas
  40536. */
  40537. releaseCanvas(): void;
  40538. }
  40539. }
  40540. declare module BABYLON {
  40541. /**
  40542. * Helper class to push actions to a pool of workers.
  40543. */
  40544. class WorkerPool implements IDisposable {
  40545. private _workerInfos;
  40546. private _pendingActions;
  40547. /**
  40548. * Constructor
  40549. * @param workers Array of workers to use for actions
  40550. */
  40551. constructor(workers: Array<Worker>);
  40552. /**
  40553. * Terminates all workers and clears any pending actions.
  40554. */
  40555. dispose(): void;
  40556. /**
  40557. * Pushes an action to the worker pool. If all the workers are active, the action will be
  40558. * pended until a worker has completed its action.
  40559. * @param action The action to perform. Call onComplete when the action is complete.
  40560. */
  40561. push(action: (worker: Worker, onComplete: () => void) => void): void;
  40562. private _execute;
  40563. }
  40564. }
  40565. declare module BABYLON {
  40566. /**
  40567. * The autoRotation behavior (BABYLON.AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  40568. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  40569. */
  40570. class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  40571. /**
  40572. * Gets the name of the behavior.
  40573. */
  40574. readonly name: string;
  40575. private _zoomStopsAnimation;
  40576. private _idleRotationSpeed;
  40577. private _idleRotationWaitTime;
  40578. private _idleRotationSpinupTime;
  40579. /**
  40580. * Sets the flag that indicates if user zooming should stop animation.
  40581. */
  40582. /**
  40583. * Gets the flag that indicates if user zooming should stop animation.
  40584. */
  40585. zoomStopsAnimation: boolean;
  40586. /**
  40587. * Sets the default speed at which the camera rotates around the model.
  40588. */
  40589. /**
  40590. * Gets the default speed at which the camera rotates around the model.
  40591. */
  40592. idleRotationSpeed: number;
  40593. /**
  40594. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  40595. */
  40596. /**
  40597. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  40598. */
  40599. idleRotationWaitTime: number;
  40600. /**
  40601. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40602. */
  40603. /**
  40604. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40605. */
  40606. idleRotationSpinupTime: number;
  40607. /**
  40608. * Gets a value indicating if the camera is currently rotating because of this behavior
  40609. */
  40610. readonly rotationInProgress: boolean;
  40611. private _onPrePointerObservableObserver;
  40612. private _onAfterCheckInputsObserver;
  40613. private _attachedCamera;
  40614. private _isPointerDown;
  40615. private _lastFrameTime;
  40616. private _lastInteractionTime;
  40617. private _cameraRotationSpeed;
  40618. /**
  40619. * Initializes the behavior.
  40620. */
  40621. init(): void;
  40622. /**
  40623. * Attaches the behavior to its arc rotate camera.
  40624. * @param camera Defines the camera to attach the behavior to
  40625. */
  40626. attach(camera: ArcRotateCamera): void;
  40627. /**
  40628. * Detaches the behavior from its current arc rotate camera.
  40629. */
  40630. detach(): void;
  40631. /**
  40632. * Returns true if user is scrolling.
  40633. * @return true if user is scrolling.
  40634. */
  40635. private _userIsZooming;
  40636. private _lastFrameRadius;
  40637. private _shouldAnimationStopForInteraction;
  40638. /**
  40639. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  40640. */
  40641. private _applyUserInteraction;
  40642. private _userIsMoving;
  40643. }
  40644. }
  40645. declare module BABYLON {
  40646. /**
  40647. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  40648. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  40649. */
  40650. class BouncingBehavior implements Behavior<ArcRotateCamera> {
  40651. /**
  40652. * Gets the name of the behavior.
  40653. */
  40654. readonly name: string;
  40655. /**
  40656. * The easing function used by animations
  40657. */
  40658. static EasingFunction: BackEase;
  40659. /**
  40660. * The easing mode used by animations
  40661. */
  40662. static EasingMode: number;
  40663. /**
  40664. * The duration of the animation, in milliseconds
  40665. */
  40666. transitionDuration: number;
  40667. /**
  40668. * Length of the distance animated by the transition when lower radius is reached
  40669. */
  40670. lowerRadiusTransitionRange: number;
  40671. /**
  40672. * Length of the distance animated by the transition when upper radius is reached
  40673. */
  40674. upperRadiusTransitionRange: number;
  40675. private _autoTransitionRange;
  40676. /**
  40677. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  40678. */
  40679. /**
  40680. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  40681. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  40682. */
  40683. autoTransitionRange: boolean;
  40684. private _attachedCamera;
  40685. private _onAfterCheckInputsObserver;
  40686. private _onMeshTargetChangedObserver;
  40687. /**
  40688. * Initializes the behavior.
  40689. */
  40690. init(): void;
  40691. /**
  40692. * Attaches the behavior to its arc rotate camera.
  40693. * @param camera Defines the camera to attach the behavior to
  40694. */
  40695. attach(camera: ArcRotateCamera): void;
  40696. /**
  40697. * Detaches the behavior from its current arc rotate camera.
  40698. */
  40699. detach(): void;
  40700. private _radiusIsAnimating;
  40701. private _radiusBounceTransition;
  40702. private _animatables;
  40703. private _cachedWheelPrecision;
  40704. /**
  40705. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  40706. * @param radiusLimit The limit to check against.
  40707. * @return Bool to indicate if at limit.
  40708. */
  40709. private _isRadiusAtLimit;
  40710. /**
  40711. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  40712. * @param radiusDelta The delta by which to animate to. Can be negative.
  40713. */
  40714. private _applyBoundRadiusAnimation;
  40715. /**
  40716. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  40717. */
  40718. protected _clearAnimationLocks(): void;
  40719. /**
  40720. * Stops and removes all animations that have been applied to the camera
  40721. */
  40722. stopAllAnimations(): void;
  40723. }
  40724. }
  40725. declare module BABYLON {
  40726. /**
  40727. * 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.
  40728. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  40729. */
  40730. class FramingBehavior implements Behavior<ArcRotateCamera> {
  40731. /**
  40732. * Gets the name of the behavior.
  40733. */
  40734. readonly name: string;
  40735. private _mode;
  40736. private _radiusScale;
  40737. private _positionScale;
  40738. private _defaultElevation;
  40739. private _elevationReturnTime;
  40740. private _elevationReturnWaitTime;
  40741. private _zoomStopsAnimation;
  40742. private _framingTime;
  40743. /**
  40744. * The easing function used by animations
  40745. */
  40746. static EasingFunction: ExponentialEase;
  40747. /**
  40748. * The easing mode used by animations
  40749. */
  40750. static EasingMode: number;
  40751. /**
  40752. * Sets the current mode used by the behavior
  40753. */
  40754. /**
  40755. * Gets current mode used by the behavior.
  40756. */
  40757. mode: number;
  40758. /**
  40759. * Sets the scale applied to the radius (1 by default)
  40760. */
  40761. /**
  40762. * Gets the scale applied to the radius
  40763. */
  40764. radiusScale: number;
  40765. /**
  40766. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  40767. */
  40768. /**
  40769. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  40770. */
  40771. positionScale: number;
  40772. /**
  40773. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  40774. * behaviour is triggered, in radians.
  40775. */
  40776. /**
  40777. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  40778. * behaviour is triggered, in radians.
  40779. */
  40780. defaultElevation: number;
  40781. /**
  40782. * Sets the time (in milliseconds) taken to return to the default beta position.
  40783. * Negative value indicates camera should not return to default.
  40784. */
  40785. /**
  40786. * Gets the time (in milliseconds) taken to return to the default beta position.
  40787. * Negative value indicates camera should not return to default.
  40788. */
  40789. elevationReturnTime: number;
  40790. /**
  40791. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  40792. */
  40793. /**
  40794. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  40795. */
  40796. elevationReturnWaitTime: number;
  40797. /**
  40798. * Sets the flag that indicates if user zooming should stop animation.
  40799. */
  40800. /**
  40801. * Gets the flag that indicates if user zooming should stop animation.
  40802. */
  40803. zoomStopsAnimation: boolean;
  40804. /**
  40805. * Sets the transition time when framing the mesh, in milliseconds
  40806. */
  40807. /**
  40808. * Gets the transition time when framing the mesh, in milliseconds
  40809. */
  40810. framingTime: number;
  40811. /**
  40812. * Define if the behavior should automatically change the configured
  40813. * camera limits and sensibilities.
  40814. */
  40815. autoCorrectCameraLimitsAndSensibility: boolean;
  40816. private _onPrePointerObservableObserver;
  40817. private _onAfterCheckInputsObserver;
  40818. private _onMeshTargetChangedObserver;
  40819. private _attachedCamera;
  40820. private _isPointerDown;
  40821. private _lastInteractionTime;
  40822. /**
  40823. * Initializes the behavior.
  40824. */
  40825. init(): void;
  40826. /**
  40827. * Attaches the behavior to its arc rotate camera.
  40828. * @param camera Defines the camera to attach the behavior to
  40829. */
  40830. attach(camera: ArcRotateCamera): void;
  40831. /**
  40832. * Detaches the behavior from its current arc rotate camera.
  40833. */
  40834. detach(): void;
  40835. private _animatables;
  40836. private _betaIsAnimating;
  40837. private _betaTransition;
  40838. private _radiusTransition;
  40839. private _vectorTransition;
  40840. /**
  40841. * Targets the given mesh and updates zoom level accordingly.
  40842. * @param mesh The mesh to target.
  40843. * @param radius Optional. If a cached radius position already exists, overrides default.
  40844. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  40845. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  40846. * @param onAnimationEnd Callback triggered at the end of the framing animation
  40847. */
  40848. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  40849. /**
  40850. * Targets the given mesh with its children and updates zoom level accordingly.
  40851. * @param mesh The mesh to target.
  40852. * @param radius Optional. If a cached radius position already exists, overrides default.
  40853. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  40854. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  40855. * @param onAnimationEnd Callback triggered at the end of the framing animation
  40856. */
  40857. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  40858. /**
  40859. * Targets the given meshes with their children and updates zoom level accordingly.
  40860. * @param meshes The mesh to target.
  40861. * @param radius Optional. If a cached radius position already exists, overrides default.
  40862. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  40863. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  40864. * @param onAnimationEnd Callback triggered at the end of the framing animation
  40865. */
  40866. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  40867. /**
  40868. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  40869. * @param minimumWorld Determines the smaller position of the bounding box extend
  40870. * @param maximumWorld Determines the bigger position of the bounding box extend
  40871. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  40872. * @param onAnimationEnd Callback triggered at the end of the framing animation
  40873. */
  40874. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  40875. /**
  40876. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  40877. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  40878. * frustum width.
  40879. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  40880. * to fully enclose the mesh in the viewing frustum.
  40881. */
  40882. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  40883. /**
  40884. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  40885. * is automatically returned to its default position (expected to be above ground plane).
  40886. */
  40887. private _maintainCameraAboveGround;
  40888. /**
  40889. * Returns the frustum slope based on the canvas ratio and camera FOV
  40890. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  40891. */
  40892. private _getFrustumSlope;
  40893. /**
  40894. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  40895. */
  40896. private _clearAnimationLocks;
  40897. /**
  40898. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  40899. */
  40900. private _applyUserInteraction;
  40901. /**
  40902. * Stops and removes all animations that have been applied to the camera
  40903. */
  40904. stopAllAnimations(): void;
  40905. /**
  40906. * Gets a value indicating if the user is moving the camera
  40907. */
  40908. readonly isUserIsMoving: boolean;
  40909. /**
  40910. * The camera can move all the way towards the mesh.
  40911. */
  40912. static IgnoreBoundsSizeMode: number;
  40913. /**
  40914. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  40915. */
  40916. static FitFrustumSidesMode: number;
  40917. }
  40918. }
  40919. declare module BABYLON {
  40920. /**
  40921. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  40922. */
  40923. class AttachToBoxBehavior implements BABYLON.Behavior<BABYLON.Mesh> {
  40924. private ui;
  40925. /**
  40926. * The name of the behavior
  40927. */
  40928. name: string;
  40929. /**
  40930. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  40931. */
  40932. distanceAwayFromFace: number;
  40933. /**
  40934. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  40935. */
  40936. distanceAwayFromBottomOfFace: number;
  40937. private _faceVectors;
  40938. private _target;
  40939. private _scene;
  40940. private _onRenderObserver;
  40941. private _tmpMatrix;
  40942. private _tmpVector;
  40943. /**
  40944. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  40945. * @param ui The transform node that should be attched to the mesh
  40946. */
  40947. constructor(ui: BABYLON.TransformNode);
  40948. /**
  40949. * Initializes the behavior
  40950. */
  40951. init(): void;
  40952. private _closestFace;
  40953. private _zeroVector;
  40954. private _lookAtTmpMatrix;
  40955. private _lookAtToRef;
  40956. /**
  40957. * Attaches the AttachToBoxBehavior to the passed in mesh
  40958. * @param target The mesh that the specified node will be attached to
  40959. */
  40960. attach(target: BABYLON.Mesh): void;
  40961. /**
  40962. * Detaches the behavior from the mesh
  40963. */
  40964. detach(): void;
  40965. }
  40966. }
  40967. declare module BABYLON {
  40968. /**
  40969. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  40970. */
  40971. class FadeInOutBehavior implements Behavior<Mesh> {
  40972. /**
  40973. * Time in milliseconds to delay before fading in (Default: 0)
  40974. */
  40975. delay: number;
  40976. /**
  40977. * Time in milliseconds for the mesh to fade in (Default: 300)
  40978. */
  40979. fadeInTime: number;
  40980. private _millisecondsPerFrame;
  40981. private _hovered;
  40982. private _hoverValue;
  40983. private _ownerNode;
  40984. /**
  40985. * Instatiates the FadeInOutBehavior
  40986. */
  40987. constructor();
  40988. /**
  40989. * The name of the behavior
  40990. */
  40991. readonly name: string;
  40992. /**
  40993. * Initializes the behavior
  40994. */
  40995. init(): void;
  40996. /**
  40997. * Attaches the fade behavior on the passed in mesh
  40998. * @param ownerNode The mesh that will be faded in/out once attached
  40999. */
  41000. attach(ownerNode: Mesh): void;
  41001. /**
  41002. * Detaches the behavior from the mesh
  41003. */
  41004. detach(): void;
  41005. /**
  41006. * Triggers the mesh to begin fading in or out
  41007. * @param value if the object should fade in or out (true to fade in)
  41008. */
  41009. fadeIn(value: boolean): void;
  41010. private _update;
  41011. private _setAllVisibility;
  41012. }
  41013. }
  41014. declare module BABYLON {
  41015. /**
  41016. * A behavior that when attached to a mesh will allow the mesh to be scaled
  41017. */
  41018. class MultiPointerScaleBehavior implements Behavior<Mesh> {
  41019. private _dragBehaviorA;
  41020. private _dragBehaviorB;
  41021. private _startDistance;
  41022. private _initialScale;
  41023. private _targetScale;
  41024. private _ownerNode;
  41025. private _sceneRenderObserver;
  41026. /**
  41027. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  41028. */
  41029. constructor();
  41030. /**
  41031. * The name of the behavior
  41032. */
  41033. readonly name: string;
  41034. /**
  41035. * Initializes the behavior
  41036. */
  41037. init(): void;
  41038. private _getCurrentDistance;
  41039. /**
  41040. * Attaches the scale behavior the passed in mesh
  41041. * @param ownerNode The mesh that will be scaled around once attached
  41042. */
  41043. attach(ownerNode: Mesh): void;
  41044. /**
  41045. * Detaches the behavior from the mesh
  41046. */
  41047. detach(): void;
  41048. }
  41049. }
  41050. declare module BABYLON {
  41051. /**
  41052. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  41053. */
  41054. class PointerDragBehavior implements Behavior<AbstractMesh> {
  41055. private static _AnyMouseID;
  41056. private _attachedNode;
  41057. private _dragPlane;
  41058. private _scene;
  41059. private _pointerObserver;
  41060. private _beforeRenderObserver;
  41061. private static _planeScene;
  41062. /**
  41063. * 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)
  41064. */
  41065. maxDragAngle: number;
  41066. /**
  41067. * @hidden
  41068. */
  41069. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  41070. /**
  41071. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  41072. */
  41073. currentDraggingPointerID: number;
  41074. /**
  41075. * The last position where the pointer hit the drag plane in world space
  41076. */
  41077. lastDragPosition: Vector3;
  41078. /**
  41079. * If the behavior is currently in a dragging state
  41080. */
  41081. dragging: boolean;
  41082. /**
  41083. * 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)
  41084. */
  41085. dragDeltaRatio: number;
  41086. /**
  41087. * If the drag plane orientation should be updated during the dragging (Default: true)
  41088. */
  41089. updateDragPlane: boolean;
  41090. private _debugMode;
  41091. private _moving;
  41092. /**
  41093. * Fires each time the attached mesh is dragged with the pointer
  41094. * * delta between last drag position and current drag position in world space
  41095. * * dragDistance along the drag axis
  41096. * * dragPlaneNormal normal of the current drag plane used during the drag
  41097. * * dragPlanePoint in world space where the drag intersects the drag plane
  41098. */
  41099. onDragObservable: Observable<{
  41100. delta: Vector3;
  41101. dragPlanePoint: Vector3;
  41102. dragPlaneNormal: Vector3;
  41103. dragDistance: number;
  41104. pointerId: number;
  41105. }>;
  41106. /**
  41107. * Fires each time a drag begins (eg. mouse down on mesh)
  41108. */
  41109. onDragStartObservable: Observable<{
  41110. dragPlanePoint: Vector3;
  41111. pointerId: number;
  41112. }>;
  41113. /**
  41114. * Fires each time a drag ends (eg. mouse release after drag)
  41115. */
  41116. onDragEndObservable: Observable<{
  41117. dragPlanePoint: Vector3;
  41118. pointerId: number;
  41119. }>;
  41120. /**
  41121. * If the attached mesh should be moved when dragged
  41122. */
  41123. moveAttached: boolean;
  41124. /**
  41125. * If the drag behavior will react to drag events (Default: true)
  41126. */
  41127. enabled: boolean;
  41128. /**
  41129. * If camera controls should be detached during the drag
  41130. */
  41131. detachCameraControls: boolean;
  41132. /**
  41133. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  41134. */
  41135. useObjectOrienationForDragging: boolean;
  41136. private _options;
  41137. /**
  41138. * Creates a pointer drag behavior that can be attached to a mesh
  41139. * @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)
  41140. */
  41141. constructor(options?: {
  41142. dragAxis?: Vector3;
  41143. dragPlaneNormal?: Vector3;
  41144. });
  41145. /**
  41146. * The name of the behavior
  41147. */
  41148. readonly name: string;
  41149. /**
  41150. * Initializes the behavior
  41151. */
  41152. init(): void;
  41153. private _tmpVector;
  41154. private _alternatePickedPoint;
  41155. private _worldDragAxis;
  41156. private _targetPosition;
  41157. private _attachedElement;
  41158. /**
  41159. * Attaches the drag behavior the passed in mesh
  41160. * @param ownerNode The mesh that will be dragged around once attached
  41161. */
  41162. attach(ownerNode: AbstractMesh): void;
  41163. /**
  41164. * Force relase the drag action by code.
  41165. */
  41166. releaseDrag(): void;
  41167. private _startDragRay;
  41168. private _lastPointerRay;
  41169. /**
  41170. * Simulates the start of a pointer drag event on the behavior
  41171. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  41172. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  41173. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  41174. */
  41175. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  41176. private _startDrag;
  41177. private _dragDelta;
  41178. private _moveDrag;
  41179. private _pickWithRayOnDragPlane;
  41180. private _pointA;
  41181. private _pointB;
  41182. private _pointC;
  41183. private _lineA;
  41184. private _lineB;
  41185. private _localAxis;
  41186. private _lookAt;
  41187. private _updateDragPlanePosition;
  41188. /**
  41189. * Detaches the behavior from the mesh
  41190. */
  41191. detach(): void;
  41192. }
  41193. }
  41194. declare module BABYLON {
  41195. /**
  41196. * 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
  41197. */
  41198. class SixDofDragBehavior implements Behavior<Mesh> {
  41199. private static _virtualScene;
  41200. private _ownerNode;
  41201. private _sceneRenderObserver;
  41202. private _scene;
  41203. private _targetPosition;
  41204. private _virtualOriginMesh;
  41205. private _virtualDragMesh;
  41206. private _pointerObserver;
  41207. private _moving;
  41208. private _startingOrientation;
  41209. /**
  41210. * 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)
  41211. */
  41212. private zDragFactor;
  41213. /**
  41214. * If the object should rotate to face the drag origin
  41215. */
  41216. rotateDraggedObject: boolean;
  41217. /**
  41218. * If the behavior is currently in a dragging state
  41219. */
  41220. dragging: boolean;
  41221. /**
  41222. * 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)
  41223. */
  41224. dragDeltaRatio: number;
  41225. /**
  41226. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  41227. */
  41228. currentDraggingPointerID: number;
  41229. /**
  41230. * If camera controls should be detached during the drag
  41231. */
  41232. detachCameraControls: boolean;
  41233. /**
  41234. * Fires each time a drag starts
  41235. */
  41236. onDragStartObservable: Observable<{}>;
  41237. /**
  41238. * Fires each time a drag ends (eg. mouse release after drag)
  41239. */
  41240. onDragEndObservable: Observable<{}>;
  41241. /**
  41242. * 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
  41243. */
  41244. constructor();
  41245. /**
  41246. * The name of the behavior
  41247. */
  41248. readonly name: string;
  41249. /**
  41250. * Initializes the behavior
  41251. */
  41252. init(): void;
  41253. /**
  41254. * Attaches the scale behavior the passed in mesh
  41255. * @param ownerNode The mesh that will be scaled around once attached
  41256. */
  41257. attach(ownerNode: Mesh): void;
  41258. /**
  41259. * Detaches the behavior from the mesh
  41260. */
  41261. detach(): void;
  41262. }
  41263. }
  41264. declare module BABYLON {
  41265. /**
  41266. * Manage the gamepad inputs to control an arc rotate camera.
  41267. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41268. */
  41269. class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  41270. /**
  41271. * Defines the camera the input is attached to.
  41272. */
  41273. camera: ArcRotateCamera;
  41274. /**
  41275. * Defines the gamepad the input is gathering event from.
  41276. */
  41277. gamepad: Nullable<Gamepad>;
  41278. /**
  41279. * Defines the gamepad rotation sensiblity.
  41280. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41281. */
  41282. gamepadRotationSensibility: number;
  41283. /**
  41284. * Defines the gamepad move sensiblity.
  41285. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41286. */
  41287. gamepadMoveSensibility: number;
  41288. private _onGamepadConnectedObserver;
  41289. private _onGamepadDisconnectedObserver;
  41290. /**
  41291. * Attach the input controls to a specific dom element to get the input from.
  41292. * @param element Defines the element the controls should be listened from
  41293. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41294. */
  41295. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41296. /**
  41297. * Detach the current controls from the specified dom element.
  41298. * @param element Defines the element to stop listening the inputs from
  41299. */
  41300. detachControl(element: Nullable<HTMLElement>): void;
  41301. /**
  41302. * Update the current camera state depending on the inputs that have been used this frame.
  41303. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41304. */
  41305. checkInputs(): void;
  41306. /**
  41307. * Gets the class name of the current intput.
  41308. * @returns the class name
  41309. */
  41310. getClassName(): string;
  41311. /**
  41312. * Get the friendly name associated with the input class.
  41313. * @returns the input friendly name
  41314. */
  41315. getSimpleName(): string;
  41316. }
  41317. }
  41318. declare module BABYLON {
  41319. /**
  41320. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  41321. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41322. */
  41323. class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  41324. /**
  41325. * Defines the camera the input is attached to.
  41326. */
  41327. camera: ArcRotateCamera;
  41328. /**
  41329. * Defines the list of key codes associated with the up action (increase alpha)
  41330. */
  41331. keysUp: number[];
  41332. /**
  41333. * Defines the list of key codes associated with the down action (decrease alpha)
  41334. */
  41335. keysDown: number[];
  41336. /**
  41337. * Defines the list of key codes associated with the left action (increase beta)
  41338. */
  41339. keysLeft: number[];
  41340. /**
  41341. * Defines the list of key codes associated with the right action (decrease beta)
  41342. */
  41343. keysRight: number[];
  41344. /**
  41345. * Defines the list of key codes associated with the reset action.
  41346. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  41347. */
  41348. keysReset: number[];
  41349. /**
  41350. * Defines the panning sensibility of the inputs.
  41351. * (How fast is the camera paning)
  41352. */
  41353. panningSensibility: number;
  41354. /**
  41355. * Defines the zooming sensibility of the inputs.
  41356. * (How fast is the camera zooming)
  41357. */
  41358. zoomingSensibility: number;
  41359. /**
  41360. * Defines wether maintaining the alt key down switch the movement mode from
  41361. * orientation to zoom.
  41362. */
  41363. useAltToZoom: boolean;
  41364. /**
  41365. * Rotation speed of the camera
  41366. */
  41367. angularSpeed: number;
  41368. private _keys;
  41369. private _ctrlPressed;
  41370. private _altPressed;
  41371. private _onCanvasBlurObserver;
  41372. private _onKeyboardObserver;
  41373. private _engine;
  41374. private _scene;
  41375. /**
  41376. * Attach the input controls to a specific dom element to get the input from.
  41377. * @param element Defines the element the controls should be listened from
  41378. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41379. */
  41380. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41381. /**
  41382. * Detach the current controls from the specified dom element.
  41383. * @param element Defines the element to stop listening the inputs from
  41384. */
  41385. detachControl(element: Nullable<HTMLElement>): void;
  41386. /**
  41387. * Update the current camera state depending on the inputs that have been used this frame.
  41388. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41389. */
  41390. checkInputs(): void;
  41391. /**
  41392. * Gets the class name of the current intput.
  41393. * @returns the class name
  41394. */
  41395. getClassName(): string;
  41396. /**
  41397. * Get the friendly name associated with the input class.
  41398. * @returns the input friendly name
  41399. */
  41400. getSimpleName(): string;
  41401. }
  41402. }
  41403. declare module BABYLON {
  41404. /**
  41405. * Manage the mouse wheel inputs to control an arc rotate camera.
  41406. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41407. */
  41408. class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  41409. /**
  41410. * Defines the camera the input is attached to.
  41411. */
  41412. camera: ArcRotateCamera;
  41413. /**
  41414. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  41415. */
  41416. wheelPrecision: number;
  41417. /**
  41418. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  41419. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  41420. */
  41421. wheelDeltaPercentage: number;
  41422. private _wheel;
  41423. private _observer;
  41424. /**
  41425. * Attach the input controls to a specific dom element to get the input from.
  41426. * @param element Defines the element the controls should be listened from
  41427. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41428. */
  41429. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41430. /**
  41431. * Detach the current controls from the specified dom element.
  41432. * @param element Defines the element to stop listening the inputs from
  41433. */
  41434. detachControl(element: Nullable<HTMLElement>): void;
  41435. /**
  41436. * Gets the class name of the current intput.
  41437. * @returns the class name
  41438. */
  41439. getClassName(): string;
  41440. /**
  41441. * Get the friendly name associated with the input class.
  41442. * @returns the input friendly name
  41443. */
  41444. getSimpleName(): string;
  41445. }
  41446. }
  41447. declare module BABYLON {
  41448. /**
  41449. * Manage the pointers inputs to control an arc rotate camera.
  41450. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41451. */
  41452. class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  41453. /**
  41454. * Defines the camera the input is attached to.
  41455. */
  41456. camera: ArcRotateCamera;
  41457. /**
  41458. * Defines the buttons associated with the input to handle camera move.
  41459. */
  41460. buttons: number[];
  41461. /**
  41462. * Defines the pointer angular sensibility along the X axis or how fast is the camera rotating.
  41463. */
  41464. angularSensibilityX: number;
  41465. /**
  41466. * Defines the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  41467. */
  41468. angularSensibilityY: number;
  41469. /**
  41470. * Defines the pointer pinch precision or how fast is the camera zooming.
  41471. */
  41472. pinchPrecision: number;
  41473. /**
  41474. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  41475. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  41476. */
  41477. pinchDeltaPercentage: number;
  41478. /**
  41479. * Defines the pointer panning sensibility or how fast is the camera moving.
  41480. */
  41481. panningSensibility: number;
  41482. /**
  41483. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  41484. */
  41485. multiTouchPanning: boolean;
  41486. /**
  41487. * Defines whether panning is enabled for both pan (2 fingers swipe) and zoom (pinch) through multitouch.
  41488. */
  41489. multiTouchPanAndZoom: boolean;
  41490. /**
  41491. * Revers pinch action direction.
  41492. */
  41493. pinchInwards: boolean;
  41494. private _isPanClick;
  41495. private _pointerInput;
  41496. private _observer;
  41497. private _onMouseMove;
  41498. private _onGestureStart;
  41499. private _onGesture;
  41500. private _MSGestureHandler;
  41501. private _onLostFocus;
  41502. private _onContextMenu;
  41503. /**
  41504. * Attach the input controls to a specific dom element to get the input from.
  41505. * @param element Defines the element the controls should be listened from
  41506. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41507. */
  41508. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41509. /**
  41510. * Detach the current controls from the specified dom element.
  41511. * @param element Defines the element to stop listening the inputs from
  41512. */
  41513. detachControl(element: Nullable<HTMLElement>): void;
  41514. /**
  41515. * Gets the class name of the current intput.
  41516. * @returns the class name
  41517. */
  41518. getClassName(): string;
  41519. /**
  41520. * Get the friendly name associated with the input class.
  41521. * @returns the input friendly name
  41522. */
  41523. getSimpleName(): string;
  41524. }
  41525. }
  41526. declare module BABYLON {
  41527. /**
  41528. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  41529. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41530. */
  41531. class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  41532. /**
  41533. * Defines the camera the input is attached to.
  41534. */
  41535. camera: ArcRotateCamera;
  41536. /**
  41537. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  41538. */
  41539. alphaCorrection: number;
  41540. /**
  41541. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  41542. */
  41543. gammaCorrection: number;
  41544. private _alpha;
  41545. private _gamma;
  41546. private _dirty;
  41547. private _deviceOrientationHandler;
  41548. /**
  41549. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  41550. */
  41551. constructor();
  41552. /**
  41553. * Attach the input controls to a specific dom element to get the input from.
  41554. * @param element Defines the element the controls should be listened from
  41555. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41556. */
  41557. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41558. /** @hidden */
  41559. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  41560. /**
  41561. * Update the current camera state depending on the inputs that have been used this frame.
  41562. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41563. */
  41564. checkInputs(): void;
  41565. /**
  41566. * Detach the current controls from the specified dom element.
  41567. * @param element Defines the element to stop listening the inputs from
  41568. */
  41569. detachControl(element: Nullable<HTMLElement>): void;
  41570. /**
  41571. * Gets the class name of the current intput.
  41572. * @returns the class name
  41573. */
  41574. getClassName(): string;
  41575. /**
  41576. * Get the friendly name associated with the input class.
  41577. * @returns the input friendly name
  41578. */
  41579. getSimpleName(): string;
  41580. }
  41581. }
  41582. declare module BABYLON {
  41583. /**
  41584. * Listen to keyboard events to control the camera.
  41585. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41586. */
  41587. class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  41588. /**
  41589. * Defines the camera the input is attached to.
  41590. */
  41591. camera: FlyCamera;
  41592. /**
  41593. * The list of keyboard keys used to control the forward move of the camera.
  41594. */
  41595. keysForward: number[];
  41596. /**
  41597. * The list of keyboard keys used to control the backward move of the camera.
  41598. */
  41599. keysBackward: number[];
  41600. /**
  41601. * The list of keyboard keys used to control the forward move of the camera.
  41602. */
  41603. keysUp: number[];
  41604. /**
  41605. * The list of keyboard keys used to control the backward move of the camera.
  41606. */
  41607. keysDown: number[];
  41608. /**
  41609. * The list of keyboard keys used to control the right strafe move of the camera.
  41610. */
  41611. keysRight: number[];
  41612. /**
  41613. * The list of keyboard keys used to control the left strafe move of the camera.
  41614. */
  41615. keysLeft: number[];
  41616. private _keys;
  41617. private _onCanvasBlurObserver;
  41618. private _onKeyboardObserver;
  41619. private _engine;
  41620. private _scene;
  41621. /**
  41622. * Attach the input controls to a specific dom element to get the input from.
  41623. * @param element Defines the element the controls should be listened from
  41624. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41625. */
  41626. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41627. /**
  41628. * Detach the current controls from the specified dom element.
  41629. * @param element Defines the element to stop listening the inputs from
  41630. */
  41631. detachControl(element: Nullable<HTMLElement>): void;
  41632. /**
  41633. * Gets the class name of the current intput.
  41634. * @returns the class name
  41635. */
  41636. getClassName(): string;
  41637. /** @hidden */
  41638. _onLostFocus(e: FocusEvent): void;
  41639. /**
  41640. * Get the friendly name associated with the input class.
  41641. * @returns the input friendly name
  41642. */
  41643. getSimpleName(): string;
  41644. /**
  41645. * Update the current camera state depending on the inputs that have been used this frame.
  41646. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41647. */
  41648. checkInputs(): void;
  41649. }
  41650. }
  41651. declare module BABYLON {
  41652. /**
  41653. * Listen to mouse events to control the camera.
  41654. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41655. */
  41656. class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  41657. /**
  41658. * Defines the camera the input is attached to.
  41659. */
  41660. camera: FlyCamera;
  41661. /**
  41662. * Defines if touch is enabled. (Default is true.)
  41663. */
  41664. touchEnabled: boolean;
  41665. /**
  41666. * Defines the buttons associated with the input to handle camera rotation.
  41667. */
  41668. buttons: number[];
  41669. /**
  41670. * Assign buttons for Yaw control.
  41671. */
  41672. buttonsYaw: number[];
  41673. /**
  41674. * Assign buttons for Pitch control.
  41675. */
  41676. buttonsPitch: number[];
  41677. /**
  41678. * Assign buttons for Roll control.
  41679. */
  41680. buttonsRoll: number[];
  41681. /**
  41682. * Detect if any button is being pressed while mouse is moved.
  41683. * -1 = Mouse locked.
  41684. * 0 = Left button.
  41685. * 1 = Middle Button.
  41686. * 2 = Right Button.
  41687. */
  41688. activeButton: number;
  41689. /**
  41690. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  41691. * Higher values reduce its sensitivity.
  41692. */
  41693. angularSensibility: number;
  41694. private _mousemoveCallback;
  41695. private _observer;
  41696. private _rollObserver;
  41697. private previousPosition;
  41698. private noPreventDefault;
  41699. private element;
  41700. /**
  41701. * Listen to mouse events to control the camera.
  41702. * @param touchEnabled Define if touch is enabled. (Default is true.)
  41703. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41704. */
  41705. constructor(touchEnabled?: boolean);
  41706. /**
  41707. * Attach the mouse control to the HTML DOM element.
  41708. * @param element Defines the element that listens to the input events.
  41709. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  41710. */
  41711. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41712. /**
  41713. * Detach the current controls from the specified dom element.
  41714. * @param element Defines the element to stop listening the inputs from
  41715. */
  41716. detachControl(element: Nullable<HTMLElement>): void;
  41717. /**
  41718. * Gets the class name of the current input.
  41719. * @returns the class name.
  41720. */
  41721. getClassName(): string;
  41722. /**
  41723. * Get the friendly name associated with the input class.
  41724. * @returns the input's friendly name.
  41725. */
  41726. getSimpleName(): string;
  41727. private _pointerInput;
  41728. private _onMouseMove;
  41729. /**
  41730. * Rotate camera by mouse offset.
  41731. */
  41732. private rotateCamera;
  41733. }
  41734. }
  41735. declare module BABYLON {
  41736. /**
  41737. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  41738. * Screen rotation is taken into account.
  41739. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41740. */
  41741. class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  41742. private _camera;
  41743. private _screenOrientationAngle;
  41744. private _constantTranform;
  41745. private _screenQuaternion;
  41746. private _alpha;
  41747. private _beta;
  41748. private _gamma;
  41749. /**
  41750. * Instantiates a new input
  41751. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41752. */
  41753. constructor();
  41754. /**
  41755. * Define the camera controlled by the input.
  41756. */
  41757. camera: FreeCamera;
  41758. /**
  41759. * Attach the input controls to a specific dom element to get the input from.
  41760. * @param element Defines the element the controls should be listened from
  41761. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41762. */
  41763. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41764. private _orientationChanged;
  41765. private _deviceOrientation;
  41766. /**
  41767. * Detach the current controls from the specified dom element.
  41768. * @param element Defines the element to stop listening the inputs from
  41769. */
  41770. detachControl(element: Nullable<HTMLElement>): void;
  41771. /**
  41772. * Update the current camera state depending on the inputs that have been used this frame.
  41773. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41774. */
  41775. checkInputs(): void;
  41776. /**
  41777. * Gets the class name of the current intput.
  41778. * @returns the class name
  41779. */
  41780. getClassName(): string;
  41781. /**
  41782. * Get the friendly name associated with the input class.
  41783. * @returns the input friendly name
  41784. */
  41785. getSimpleName(): string;
  41786. }
  41787. }
  41788. declare module BABYLON {
  41789. /**
  41790. * Manage the gamepad inputs to control a free camera.
  41791. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41792. */
  41793. class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  41794. /**
  41795. * Define the camera the input is attached to.
  41796. */
  41797. camera: FreeCamera;
  41798. /**
  41799. * Define the Gamepad controlling the input
  41800. */
  41801. gamepad: Nullable<Gamepad>;
  41802. /**
  41803. * Defines the gamepad rotation sensiblity.
  41804. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41805. */
  41806. gamepadAngularSensibility: number;
  41807. /**
  41808. * Defines the gamepad move sensiblity.
  41809. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41810. */
  41811. gamepadMoveSensibility: number;
  41812. private _onGamepadConnectedObserver;
  41813. private _onGamepadDisconnectedObserver;
  41814. private _cameraTransform;
  41815. private _deltaTransform;
  41816. private _vector3;
  41817. private _vector2;
  41818. /**
  41819. * Attach the input controls to a specific dom element to get the input from.
  41820. * @param element Defines the element the controls should be listened from
  41821. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41822. */
  41823. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41824. /**
  41825. * Detach the current controls from the specified dom element.
  41826. * @param element Defines the element to stop listening the inputs from
  41827. */
  41828. detachControl(element: Nullable<HTMLElement>): void;
  41829. /**
  41830. * Update the current camera state depending on the inputs that have been used this frame.
  41831. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41832. */
  41833. checkInputs(): void;
  41834. /**
  41835. * Gets the class name of the current intput.
  41836. * @returns the class name
  41837. */
  41838. getClassName(): string;
  41839. /**
  41840. * Get the friendly name associated with the input class.
  41841. * @returns the input friendly name
  41842. */
  41843. getSimpleName(): string;
  41844. }
  41845. }
  41846. declare module BABYLON {
  41847. /**
  41848. * Manage the keyboard inputs to control the movement of a free camera.
  41849. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41850. */
  41851. class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  41852. /**
  41853. * Defines the camera the input is attached to.
  41854. */
  41855. camera: FreeCamera;
  41856. /**
  41857. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  41858. */
  41859. keysUp: number[];
  41860. /**
  41861. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  41862. */
  41863. keysDown: number[];
  41864. /**
  41865. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  41866. */
  41867. keysLeft: number[];
  41868. /**
  41869. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  41870. */
  41871. keysRight: number[];
  41872. private _keys;
  41873. private _onCanvasBlurObserver;
  41874. private _onKeyboardObserver;
  41875. private _engine;
  41876. private _scene;
  41877. /**
  41878. * Attach the input controls to a specific dom element to get the input from.
  41879. * @param element Defines the element the controls should be listened from
  41880. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41881. */
  41882. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41883. /**
  41884. * Detach the current controls from the specified dom element.
  41885. * @param element Defines the element to stop listening the inputs from
  41886. */
  41887. detachControl(element: Nullable<HTMLElement>): void;
  41888. /**
  41889. * Update the current camera state depending on the inputs that have been used this frame.
  41890. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41891. */
  41892. checkInputs(): void;
  41893. /**
  41894. * Gets the class name of the current intput.
  41895. * @returns the class name
  41896. */
  41897. getClassName(): string;
  41898. /** @hidden */
  41899. _onLostFocus(e: FocusEvent): void;
  41900. /**
  41901. * Get the friendly name associated with the input class.
  41902. * @returns the input friendly name
  41903. */
  41904. getSimpleName(): string;
  41905. }
  41906. }
  41907. declare module BABYLON {
  41908. /**
  41909. * Manage the mouse inputs to control the movement of a free camera.
  41910. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41911. */
  41912. class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  41913. /**
  41914. * Define if touch is enabled in the mouse input
  41915. */
  41916. touchEnabled: boolean;
  41917. /**
  41918. * Defines the camera the input is attached to.
  41919. */
  41920. camera: FreeCamera;
  41921. /**
  41922. * Defines the buttons associated with the input to handle camera move.
  41923. */
  41924. buttons: number[];
  41925. /**
  41926. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  41927. */
  41928. angularSensibility: number;
  41929. private _pointerInput;
  41930. private _onMouseMove;
  41931. private _observer;
  41932. private previousPosition;
  41933. /**
  41934. * Manage the mouse inputs to control the movement of a free camera.
  41935. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41936. * @param touchEnabled Defines if touch is enabled or not
  41937. */
  41938. constructor(
  41939. /**
  41940. * Define if touch is enabled in the mouse input
  41941. */
  41942. touchEnabled?: boolean);
  41943. /**
  41944. * Attach the input controls to a specific dom element to get the input from.
  41945. * @param element Defines the element the controls should be listened from
  41946. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41947. */
  41948. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41949. /**
  41950. * Detach the current controls from the specified dom element.
  41951. * @param element Defines the element to stop listening the inputs from
  41952. */
  41953. detachControl(element: Nullable<HTMLElement>): void;
  41954. /**
  41955. * Gets the class name of the current intput.
  41956. * @returns the class name
  41957. */
  41958. getClassName(): string;
  41959. /**
  41960. * Get the friendly name associated with the input class.
  41961. * @returns the input friendly name
  41962. */
  41963. getSimpleName(): string;
  41964. }
  41965. }
  41966. declare module BABYLON {
  41967. /**
  41968. * Manage the touch inputs to control the movement of a free camera.
  41969. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41970. */
  41971. class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  41972. /**
  41973. * Defines the camera the input is attached to.
  41974. */
  41975. camera: FreeCamera;
  41976. /**
  41977. * Defines the touch sensibility for rotation.
  41978. * The higher the faster.
  41979. */
  41980. touchAngularSensibility: number;
  41981. /**
  41982. * Defines the touch sensibility for move.
  41983. * The higher the faster.
  41984. */
  41985. touchMoveSensibility: number;
  41986. private _offsetX;
  41987. private _offsetY;
  41988. private _pointerPressed;
  41989. private _pointerInput;
  41990. private _observer;
  41991. private _onLostFocus;
  41992. /**
  41993. * Attach the input controls to a specific dom element to get the input from.
  41994. * @param element Defines the element the controls should be listened from
  41995. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41996. */
  41997. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41998. /**
  41999. * Detach the current controls from the specified dom element.
  42000. * @param element Defines the element to stop listening the inputs from
  42001. */
  42002. detachControl(element: Nullable<HTMLElement>): void;
  42003. /**
  42004. * Update the current camera state depending on the inputs that have been used this frame.
  42005. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42006. */
  42007. checkInputs(): void;
  42008. /**
  42009. * Gets the class name of the current intput.
  42010. * @returns the class name
  42011. */
  42012. getClassName(): string;
  42013. /**
  42014. * Get the friendly name associated with the input class.
  42015. * @returns the input friendly name
  42016. */
  42017. getSimpleName(): string;
  42018. }
  42019. }
  42020. declare module BABYLON {
  42021. /**
  42022. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  42023. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42024. */
  42025. class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  42026. /**
  42027. * Defines the camera the input is attached to.
  42028. */
  42029. camera: FreeCamera;
  42030. private _leftjoystick;
  42031. private _rightjoystick;
  42032. /**
  42033. * Gets the left stick of the virtual joystick.
  42034. * @returns The virtual Joystick
  42035. */
  42036. getLeftJoystick(): VirtualJoystick;
  42037. /**
  42038. * Gets the right stick of the virtual joystick.
  42039. * @returns The virtual Joystick
  42040. */
  42041. getRightJoystick(): VirtualJoystick;
  42042. /**
  42043. * Update the current camera state depending on the inputs that have been used this frame.
  42044. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42045. */
  42046. checkInputs(): void;
  42047. /**
  42048. * Attach the input controls to a specific dom element to get the input from.
  42049. * @param element Defines the element the controls should be listened from
  42050. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42051. */
  42052. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42053. /**
  42054. * Detach the current controls from the specified dom element.
  42055. * @param element Defines the element to stop listening the inputs from
  42056. */
  42057. detachControl(element: Nullable<HTMLElement>): void;
  42058. /**
  42059. * Gets the class name of the current intput.
  42060. * @returns the class name
  42061. */
  42062. getClassName(): string;
  42063. /**
  42064. * Get the friendly name associated with the input class.
  42065. * @returns the input friendly name
  42066. */
  42067. getSimpleName(): string;
  42068. }
  42069. }
  42070. declare module BABYLON {
  42071. /**
  42072. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  42073. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42074. */
  42075. class AnaglyphArcRotateCamera extends ArcRotateCamera {
  42076. /**
  42077. * Creates a new AnaglyphArcRotateCamera
  42078. * @param name defines camera name
  42079. * @param alpha defines alpha angle (in radians)
  42080. * @param beta defines beta angle (in radians)
  42081. * @param radius defines radius
  42082. * @param target defines camera target
  42083. * @param interaxialDistance defines distance between each color axis
  42084. * @param scene defines the hosting scene
  42085. */
  42086. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  42087. /**
  42088. * Gets camera class name
  42089. * @returns AnaglyphArcRotateCamera
  42090. */
  42091. getClassName(): string;
  42092. }
  42093. }
  42094. declare module BABYLON {
  42095. /**
  42096. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  42097. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42098. */
  42099. class AnaglyphFreeCamera extends FreeCamera {
  42100. /**
  42101. * Creates a new AnaglyphFreeCamera
  42102. * @param name defines camera name
  42103. * @param position defines initial position
  42104. * @param interaxialDistance defines distance between each color axis
  42105. * @param scene defines the hosting scene
  42106. */
  42107. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42108. /**
  42109. * Gets camera class name
  42110. * @returns AnaglyphFreeCamera
  42111. */
  42112. getClassName(): string;
  42113. }
  42114. }
  42115. declare module BABYLON {
  42116. /**
  42117. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  42118. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42119. */
  42120. class AnaglyphGamepadCamera extends GamepadCamera {
  42121. /**
  42122. * Creates a new AnaglyphGamepadCamera
  42123. * @param name defines camera name
  42124. * @param position defines initial position
  42125. * @param interaxialDistance defines distance between each color axis
  42126. * @param scene defines the hosting scene
  42127. */
  42128. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42129. /**
  42130. * Gets camera class name
  42131. * @returns AnaglyphGamepadCamera
  42132. */
  42133. getClassName(): string;
  42134. }
  42135. }
  42136. declare module BABYLON {
  42137. /**
  42138. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  42139. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42140. */
  42141. class AnaglyphUniversalCamera extends UniversalCamera {
  42142. /**
  42143. * Creates a new AnaglyphUniversalCamera
  42144. * @param name defines camera name
  42145. * @param position defines initial position
  42146. * @param interaxialDistance defines distance between each color axis
  42147. * @param scene defines the hosting scene
  42148. */
  42149. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42150. /**
  42151. * Gets camera class name
  42152. * @returns AnaglyphUniversalCamera
  42153. */
  42154. getClassName(): string;
  42155. }
  42156. }
  42157. declare module BABYLON {
  42158. /**
  42159. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  42160. * @see http://doc.babylonjs.com/features/cameras
  42161. */
  42162. class StereoscopicArcRotateCamera extends ArcRotateCamera {
  42163. /**
  42164. * Creates a new StereoscopicArcRotateCamera
  42165. * @param name defines camera name
  42166. * @param alpha defines alpha angle (in radians)
  42167. * @param beta defines beta angle (in radians)
  42168. * @param radius defines radius
  42169. * @param target defines camera target
  42170. * @param interaxialDistance defines distance between each color axis
  42171. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42172. * @param scene defines the hosting scene
  42173. */
  42174. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42175. /**
  42176. * Gets camera class name
  42177. * @returns StereoscopicArcRotateCamera
  42178. */
  42179. getClassName(): string;
  42180. }
  42181. }
  42182. declare module BABYLON {
  42183. /**
  42184. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  42185. * @see http://doc.babylonjs.com/features/cameras
  42186. */
  42187. class StereoscopicFreeCamera extends FreeCamera {
  42188. /**
  42189. * Creates a new StereoscopicFreeCamera
  42190. * @param name defines camera name
  42191. * @param position defines initial position
  42192. * @param interaxialDistance defines distance between each color axis
  42193. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42194. * @param scene defines the hosting scene
  42195. */
  42196. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42197. /**
  42198. * Gets camera class name
  42199. * @returns StereoscopicFreeCamera
  42200. */
  42201. getClassName(): string;
  42202. }
  42203. }
  42204. declare module BABYLON {
  42205. /**
  42206. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  42207. * @see http://doc.babylonjs.com/features/cameras
  42208. */
  42209. class StereoscopicGamepadCamera extends GamepadCamera {
  42210. /**
  42211. * Creates a new StereoscopicGamepadCamera
  42212. * @param name defines camera name
  42213. * @param position defines initial position
  42214. * @param interaxialDistance defines distance between each color axis
  42215. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42216. * @param scene defines the hosting scene
  42217. */
  42218. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42219. /**
  42220. * Gets camera class name
  42221. * @returns StereoscopicGamepadCamera
  42222. */
  42223. getClassName(): string;
  42224. }
  42225. }
  42226. declare module BABYLON {
  42227. /**
  42228. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  42229. * @see http://doc.babylonjs.com/features/cameras
  42230. */
  42231. class StereoscopicUniversalCamera extends UniversalCamera {
  42232. /**
  42233. * Creates a new StereoscopicUniversalCamera
  42234. * @param name defines camera name
  42235. * @param position defines initial position
  42236. * @param interaxialDistance defines distance between each color axis
  42237. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42238. * @param scene defines the hosting scene
  42239. */
  42240. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42241. /**
  42242. * Gets camera class name
  42243. * @returns StereoscopicUniversalCamera
  42244. */
  42245. getClassName(): string;
  42246. }
  42247. }
  42248. declare module BABYLON {
  42249. /**
  42250. * This represents all the required metrics to create a VR camera.
  42251. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  42252. */
  42253. class VRCameraMetrics {
  42254. /**
  42255. * Define the horizontal resolution off the screen.
  42256. */
  42257. hResolution: number;
  42258. /**
  42259. * Define the vertical resolution off the screen.
  42260. */
  42261. vResolution: number;
  42262. /**
  42263. * Define the horizontal screen size.
  42264. */
  42265. hScreenSize: number;
  42266. /**
  42267. * Define the vertical screen size.
  42268. */
  42269. vScreenSize: number;
  42270. /**
  42271. * Define the vertical screen center position.
  42272. */
  42273. vScreenCenter: number;
  42274. /**
  42275. * Define the distance of the eyes to the screen.
  42276. */
  42277. eyeToScreenDistance: number;
  42278. /**
  42279. * Define the distance between both lenses
  42280. */
  42281. lensSeparationDistance: number;
  42282. /**
  42283. * Define the distance between both viewer's eyes.
  42284. */
  42285. interpupillaryDistance: number;
  42286. /**
  42287. * Define the distortion factor of the VR postprocess.
  42288. * Please, touch with care.
  42289. */
  42290. distortionK: number[];
  42291. /**
  42292. * Define the chromatic aberration correction factors for the VR post process.
  42293. */
  42294. chromaAbCorrection: number[];
  42295. /**
  42296. * Define the scale factor of the post process.
  42297. * The smaller the better but the slower.
  42298. */
  42299. postProcessScaleFactor: number;
  42300. /**
  42301. * Define an offset for the lens center.
  42302. */
  42303. lensCenterOffset: number;
  42304. /**
  42305. * Define if the current vr camera should compensate the distortion of the lense or not.
  42306. */
  42307. compensateDistortion: boolean;
  42308. /**
  42309. * Gets the rendering aspect ratio based on the provided resolutions.
  42310. */
  42311. readonly aspectRatio: number;
  42312. /**
  42313. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  42314. */
  42315. readonly aspectRatioFov: number;
  42316. /**
  42317. * @hidden
  42318. */
  42319. readonly leftHMatrix: Matrix;
  42320. /**
  42321. * @hidden
  42322. */
  42323. readonly rightHMatrix: Matrix;
  42324. /**
  42325. * @hidden
  42326. */
  42327. readonly leftPreViewMatrix: Matrix;
  42328. /**
  42329. * @hidden
  42330. */
  42331. readonly rightPreViewMatrix: Matrix;
  42332. /**
  42333. * Get the default VRMetrics based on the most generic setup.
  42334. * @returns the default vr metrics
  42335. */
  42336. static GetDefault(): VRCameraMetrics;
  42337. }
  42338. }
  42339. declare module BABYLON {
  42340. /**
  42341. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  42342. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42343. */
  42344. class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  42345. /**
  42346. * Creates a new VRDeviceOrientationArcRotateCamera
  42347. * @param name defines camera name
  42348. * @param alpha defines the camera rotation along the logitudinal axis
  42349. * @param beta defines the camera rotation along the latitudinal axis
  42350. * @param radius defines the camera distance from its target
  42351. * @param target defines the camera target
  42352. * @param scene defines the scene the camera belongs to
  42353. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42354. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42355. */
  42356. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42357. /**
  42358. * Gets camera class name
  42359. * @returns VRDeviceOrientationArcRotateCamera
  42360. */
  42361. getClassName(): string;
  42362. }
  42363. }
  42364. declare module BABYLON {
  42365. /**
  42366. * Camera used to simulate VR rendering (based on FreeCamera)
  42367. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42368. */
  42369. class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  42370. /**
  42371. * Creates a new VRDeviceOrientationFreeCamera
  42372. * @param name defines camera name
  42373. * @param position defines the start position of the camera
  42374. * @param scene defines the scene the camera belongs to
  42375. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42376. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42377. */
  42378. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42379. /**
  42380. * Gets camera class name
  42381. * @returns VRDeviceOrientationFreeCamera
  42382. */
  42383. getClassName(): string;
  42384. }
  42385. }
  42386. declare module BABYLON {
  42387. /**
  42388. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  42389. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42390. */
  42391. class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  42392. /**
  42393. * Creates a new VRDeviceOrientationGamepadCamera
  42394. * @param name defines camera name
  42395. * @param position defines the start position of the camera
  42396. * @param scene defines the scene the camera belongs to
  42397. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42398. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42399. */
  42400. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42401. /**
  42402. * Gets camera class name
  42403. * @returns VRDeviceOrientationGamepadCamera
  42404. */
  42405. getClassName(): string;
  42406. }
  42407. }
  42408. declare module BABYLON {
  42409. /**
  42410. * Options to modify the vr teleportation behavior.
  42411. */
  42412. interface VRTeleportationOptions {
  42413. /**
  42414. * The name of the mesh which should be used as the teleportation floor. (default: null)
  42415. */
  42416. floorMeshName?: string;
  42417. /**
  42418. * A list of meshes to be used as the teleportation floor. (default: empty)
  42419. */
  42420. floorMeshes?: Mesh[];
  42421. }
  42422. /**
  42423. * Options to modify the vr experience helper's behavior.
  42424. */
  42425. interface VRExperienceHelperOptions extends WebVROptions {
  42426. /**
  42427. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  42428. */
  42429. createDeviceOrientationCamera?: boolean;
  42430. /**
  42431. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  42432. */
  42433. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  42434. /**
  42435. * Uses the main button on the controller to toggle the laser casted. (default: true)
  42436. */
  42437. laserToggle?: boolean;
  42438. /**
  42439. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  42440. */
  42441. floorMeshes?: Mesh[];
  42442. }
  42443. /**
  42444. * Helps to quickly add VR support to an existing scene.
  42445. * See http://doc.babylonjs.com/how_to/webvr_helper
  42446. */
  42447. class VRExperienceHelper {
  42448. /** Options to modify the vr experience helper's behavior. */
  42449. webVROptions: VRExperienceHelperOptions;
  42450. private _scene;
  42451. private _position;
  42452. private _btnVR;
  42453. private _btnVRDisplayed;
  42454. private _webVRsupported;
  42455. private _webVRready;
  42456. private _webVRrequesting;
  42457. private _webVRpresenting;
  42458. private _hasEnteredVR;
  42459. private _fullscreenVRpresenting;
  42460. private _canvas;
  42461. private _webVRCamera;
  42462. private _vrDeviceOrientationCamera;
  42463. private _deviceOrientationCamera;
  42464. private _existingCamera;
  42465. private _onKeyDown;
  42466. private _onVrDisplayPresentChange;
  42467. private _onVRDisplayChanged;
  42468. private _onVRRequestPresentStart;
  42469. private _onVRRequestPresentComplete;
  42470. /**
  42471. * Observable raised when entering VR.
  42472. */
  42473. onEnteringVRObservable: Observable<VRExperienceHelper>;
  42474. /**
  42475. * Observable raised when exiting VR.
  42476. */
  42477. onExitingVRObservable: Observable<VRExperienceHelper>;
  42478. /**
  42479. * Observable raised when controller mesh is loaded.
  42480. */
  42481. onControllerMeshLoadedObservable: Observable<WebVRController>;
  42482. /** Return this.onEnteringVRObservable
  42483. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  42484. */
  42485. readonly onEnteringVR: Observable<VRExperienceHelper>;
  42486. /** Return this.onExitingVRObservable
  42487. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  42488. */
  42489. readonly onExitingVR: Observable<VRExperienceHelper>;
  42490. /** Return this.onControllerMeshLoadedObservable
  42491. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  42492. */
  42493. readonly onControllerMeshLoaded: Observable<WebVRController>;
  42494. private _rayLength;
  42495. private _useCustomVRButton;
  42496. private _teleportationRequested;
  42497. private _teleportActive;
  42498. private _floorMeshName;
  42499. private _floorMeshesCollection;
  42500. private _rotationAllowed;
  42501. private _teleportBackwardsVector;
  42502. private _teleportationTarget;
  42503. private _isDefaultTeleportationTarget;
  42504. private _postProcessMove;
  42505. private _teleportationFillColor;
  42506. private _teleportationBorderColor;
  42507. private _rotationAngle;
  42508. private _haloCenter;
  42509. private _cameraGazer;
  42510. private _padSensibilityUp;
  42511. private _padSensibilityDown;
  42512. private _leftController;
  42513. private _rightController;
  42514. /**
  42515. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  42516. */
  42517. onNewMeshSelected: Observable<AbstractMesh>;
  42518. /**
  42519. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  42520. */
  42521. onNewMeshPicked: Observable<PickingInfo>;
  42522. private _circleEase;
  42523. /**
  42524. * Observable raised before camera teleportation
  42525. */
  42526. onBeforeCameraTeleport: Observable<Vector3>;
  42527. /**
  42528. * Observable raised after camera teleportation
  42529. */
  42530. onAfterCameraTeleport: Observable<Vector3>;
  42531. /**
  42532. * Observable raised when current selected mesh gets unselected
  42533. */
  42534. onSelectedMeshUnselected: Observable<AbstractMesh>;
  42535. private _raySelectionPredicate;
  42536. /**
  42537. * To be optionaly changed by user to define custom ray selection
  42538. */
  42539. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  42540. /**
  42541. * To be optionaly changed by user to define custom selection logic (after ray selection)
  42542. */
  42543. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  42544. /**
  42545. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  42546. */
  42547. teleportationEnabled: boolean;
  42548. private _defaultHeight;
  42549. private _teleportationInitialized;
  42550. private _interactionsEnabled;
  42551. private _interactionsRequested;
  42552. private _displayGaze;
  42553. private _displayLaserPointer;
  42554. /**
  42555. * The mesh used to display where the user is going to teleport.
  42556. */
  42557. /**
  42558. * Sets the mesh to be used to display where the user is going to teleport.
  42559. */
  42560. teleportationTarget: Mesh;
  42561. /**
  42562. * 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
  42563. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  42564. * See http://doc.babylonjs.com/resources/baking_transformations
  42565. */
  42566. gazeTrackerMesh: Mesh;
  42567. /**
  42568. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  42569. */
  42570. updateGazeTrackerScale: boolean;
  42571. /**
  42572. * The gaze tracking mesh corresponding to the left controller
  42573. */
  42574. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  42575. /**
  42576. * The gaze tracking mesh corresponding to the right controller
  42577. */
  42578. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  42579. /**
  42580. * If the ray of the gaze should be displayed.
  42581. */
  42582. /**
  42583. * Sets if the ray of the gaze should be displayed.
  42584. */
  42585. displayGaze: boolean;
  42586. /**
  42587. * If the ray of the LaserPointer should be displayed.
  42588. */
  42589. /**
  42590. * Sets if the ray of the LaserPointer should be displayed.
  42591. */
  42592. displayLaserPointer: boolean;
  42593. /**
  42594. * The deviceOrientationCamera used as the camera when not in VR.
  42595. */
  42596. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  42597. /**
  42598. * Based on the current WebVR support, returns the current VR camera used.
  42599. */
  42600. readonly currentVRCamera: Nullable<Camera>;
  42601. /**
  42602. * The webVRCamera which is used when in VR.
  42603. */
  42604. readonly webVRCamera: WebVRFreeCamera;
  42605. /**
  42606. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  42607. */
  42608. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  42609. private readonly _teleportationRequestInitiated;
  42610. /**
  42611. * Instantiates a VRExperienceHelper.
  42612. * Helps to quickly add VR support to an existing scene.
  42613. * @param scene The scene the VRExperienceHelper belongs to.
  42614. * @param webVROptions Options to modify the vr experience helper's behavior.
  42615. */
  42616. constructor(scene: Scene,
  42617. /** Options to modify the vr experience helper's behavior. */
  42618. webVROptions?: VRExperienceHelperOptions);
  42619. private _onDefaultMeshLoaded;
  42620. private _onResize;
  42621. private _onFullscreenChange;
  42622. /**
  42623. * Gets a value indicating if we are currently in VR mode.
  42624. */
  42625. readonly isInVRMode: boolean;
  42626. private onVrDisplayPresentChange;
  42627. private onVRDisplayChanged;
  42628. private moveButtonToBottomRight;
  42629. private displayVRButton;
  42630. private updateButtonVisibility;
  42631. private _cachedAngularSensibility;
  42632. /**
  42633. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  42634. * Otherwise, will use the fullscreen API.
  42635. */
  42636. enterVR(): void;
  42637. /**
  42638. * Attempt to exit VR, or fullscreen.
  42639. */
  42640. exitVR(): void;
  42641. /**
  42642. * The position of the vr experience helper.
  42643. */
  42644. /**
  42645. * Sets the position of the vr experience helper.
  42646. */
  42647. position: Vector3;
  42648. /**
  42649. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  42650. */
  42651. enableInteractions(): void;
  42652. private readonly _noControllerIsActive;
  42653. private beforeRender;
  42654. private _isTeleportationFloor;
  42655. /**
  42656. * Adds a floor mesh to be used for teleportation.
  42657. * @param floorMesh the mesh to be used for teleportation.
  42658. */
  42659. addFloorMesh(floorMesh: Mesh): void;
  42660. /**
  42661. * Removes a floor mesh from being used for teleportation.
  42662. * @param floorMesh the mesh to be removed.
  42663. */
  42664. removeFloorMesh(floorMesh: Mesh): void;
  42665. /**
  42666. * Enables interactions and teleportation using the VR controllers and gaze.
  42667. * @param vrTeleportationOptions options to modify teleportation behavior.
  42668. */
  42669. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  42670. private _onNewGamepadConnected;
  42671. private _tryEnableInteractionOnController;
  42672. private _onNewGamepadDisconnected;
  42673. private _enableInteractionOnController;
  42674. private _checkTeleportWithRay;
  42675. private _checkRotate;
  42676. private _checkTeleportBackwards;
  42677. private _enableTeleportationOnController;
  42678. private _createTeleportationCircles;
  42679. private _displayTeleportationTarget;
  42680. private _hideTeleportationTarget;
  42681. private _rotateCamera;
  42682. private _moveTeleportationSelectorTo;
  42683. private _workingVector;
  42684. private _workingQuaternion;
  42685. private _workingMatrix;
  42686. /**
  42687. * Teleports the users feet to the desired location
  42688. * @param location The location where the user's feet should be placed
  42689. */
  42690. teleportCamera(location: Vector3): void;
  42691. private _convertNormalToDirectionOfRay;
  42692. private _castRayAndSelectObject;
  42693. private _notifySelectedMeshUnselected;
  42694. /**
  42695. * Sets the color of the laser ray from the vr controllers.
  42696. * @param color new color for the ray.
  42697. */
  42698. changeLaserColor(color: Color3): void;
  42699. /**
  42700. * Sets the color of the ray from the vr headsets gaze.
  42701. * @param color new color for the ray.
  42702. */
  42703. changeGazeColor(color: Color3): void;
  42704. /**
  42705. * Exits VR and disposes of the vr experience helper
  42706. */
  42707. dispose(): void;
  42708. /**
  42709. * Gets the name of the VRExperienceHelper class
  42710. * @returns "VRExperienceHelper"
  42711. */
  42712. getClassName(): string;
  42713. }
  42714. }
  42715. declare module BABYLON {
  42716. /**
  42717. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  42718. * IMPORTANT!! The data is right-hand data.
  42719. * @export
  42720. * @interface DevicePose
  42721. */
  42722. interface DevicePose {
  42723. /**
  42724. * The position of the device, values in array are [x,y,z].
  42725. */
  42726. readonly position: Nullable<Float32Array>;
  42727. /**
  42728. * The linearVelocity of the device, values in array are [x,y,z].
  42729. */
  42730. readonly linearVelocity: Nullable<Float32Array>;
  42731. /**
  42732. * The linearAcceleration of the device, values in array are [x,y,z].
  42733. */
  42734. readonly linearAcceleration: Nullable<Float32Array>;
  42735. /**
  42736. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  42737. */
  42738. readonly orientation: Nullable<Float32Array>;
  42739. /**
  42740. * The angularVelocity of the device, values in array are [x,y,z].
  42741. */
  42742. readonly angularVelocity: Nullable<Float32Array>;
  42743. /**
  42744. * The angularAcceleration of the device, values in array are [x,y,z].
  42745. */
  42746. readonly angularAcceleration: Nullable<Float32Array>;
  42747. }
  42748. /**
  42749. * Interface representing a pose controlled object in Babylon.
  42750. * A pose controlled object has both regular pose values as well as pose values
  42751. * from an external device such as a VR head mounted display
  42752. */
  42753. interface PoseControlled {
  42754. /**
  42755. * The position of the object in babylon space.
  42756. */
  42757. position: Vector3;
  42758. /**
  42759. * The rotation quaternion of the object in babylon space.
  42760. */
  42761. rotationQuaternion: Quaternion;
  42762. /**
  42763. * The position of the device in babylon space.
  42764. */
  42765. devicePosition?: Vector3;
  42766. /**
  42767. * The rotation quaternion of the device in babylon space.
  42768. */
  42769. deviceRotationQuaternion: Quaternion;
  42770. /**
  42771. * The raw pose coming from the device.
  42772. */
  42773. rawPose: Nullable<DevicePose>;
  42774. /**
  42775. * The scale of the device to be used when translating from device space to babylon space.
  42776. */
  42777. deviceScaleFactor: number;
  42778. /**
  42779. * Updates the poseControlled values based on the input device pose.
  42780. * @param poseData the pose data to update the object with
  42781. */
  42782. updateFromDevice(poseData: DevicePose): void;
  42783. }
  42784. /**
  42785. * Set of options to customize the webVRCamera
  42786. */
  42787. interface WebVROptions {
  42788. /**
  42789. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  42790. */
  42791. trackPosition?: boolean;
  42792. /**
  42793. * Sets the scale of the vrDevice in babylon space. (default: 1)
  42794. */
  42795. positionScale?: number;
  42796. /**
  42797. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  42798. */
  42799. displayName?: string;
  42800. /**
  42801. * Should the native controller meshes be initialized. (default: true)
  42802. */
  42803. controllerMeshes?: boolean;
  42804. /**
  42805. * Creating a default HemiLight only on controllers. (default: true)
  42806. */
  42807. defaultLightingOnControllers?: boolean;
  42808. /**
  42809. * If you don't want to use the default VR button of the helper. (default: false)
  42810. */
  42811. useCustomVRButton?: boolean;
  42812. /**
  42813. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  42814. */
  42815. customVRButton?: HTMLButtonElement;
  42816. /**
  42817. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  42818. */
  42819. rayLength?: number;
  42820. /**
  42821. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  42822. */
  42823. defaultHeight?: number;
  42824. }
  42825. /**
  42826. * This represents a WebVR camera.
  42827. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  42828. * @example http://doc.babylonjs.com/how_to/webvr_camera
  42829. */
  42830. class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  42831. private webVROptions;
  42832. /**
  42833. * @hidden
  42834. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  42835. */
  42836. _vrDevice: any;
  42837. /**
  42838. * The rawPose of the vrDevice.
  42839. */
  42840. rawPose: Nullable<DevicePose>;
  42841. private _onVREnabled;
  42842. private _specsVersion;
  42843. private _attached;
  42844. private _frameData;
  42845. protected _descendants: Array<Node>;
  42846. private _deviceRoomPosition;
  42847. /** @hidden */
  42848. _deviceRoomRotationQuaternion: Quaternion;
  42849. private _standingMatrix;
  42850. /**
  42851. * Represents device position in babylon space.
  42852. */
  42853. devicePosition: Vector3;
  42854. /**
  42855. * Represents device rotation in babylon space.
  42856. */
  42857. deviceRotationQuaternion: Quaternion;
  42858. /**
  42859. * The scale of the device to be used when translating from device space to babylon space.
  42860. */
  42861. deviceScaleFactor: number;
  42862. private _deviceToWorld;
  42863. private _worldToDevice;
  42864. /**
  42865. * References to the webVR controllers for the vrDevice.
  42866. */
  42867. controllers: Array<WebVRController>;
  42868. /**
  42869. * Emits an event when a controller is attached.
  42870. */
  42871. onControllersAttachedObservable: Observable<WebVRController[]>;
  42872. /**
  42873. * Emits an event when a controller's mesh has been loaded;
  42874. */
  42875. onControllerMeshLoadedObservable: Observable<WebVRController>;
  42876. /**
  42877. * Emits an event when the HMD's pose has been updated.
  42878. */
  42879. onPoseUpdatedFromDeviceObservable: Observable<any>;
  42880. private _poseSet;
  42881. /**
  42882. * If the rig cameras be used as parent instead of this camera.
  42883. */
  42884. rigParenting: boolean;
  42885. private _lightOnControllers;
  42886. private _defaultHeight?;
  42887. /**
  42888. * Instantiates a WebVRFreeCamera.
  42889. * @param name The name of the WebVRFreeCamera
  42890. * @param position The starting anchor position for the camera
  42891. * @param scene The scene the camera belongs to
  42892. * @param webVROptions a set of customizable options for the webVRCamera
  42893. */
  42894. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  42895. /**
  42896. * Gets the device distance from the ground in meters.
  42897. * @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.
  42898. */
  42899. deviceDistanceToRoomGround(): number;
  42900. /**
  42901. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  42902. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  42903. */
  42904. useStandingMatrix(callback?: (bool: boolean) => void): void;
  42905. /**
  42906. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  42907. * @returns A promise with a boolean set to if the standing matrix is supported.
  42908. */
  42909. useStandingMatrixAsync(): Promise<boolean>;
  42910. /**
  42911. * Disposes the camera
  42912. */
  42913. dispose(): void;
  42914. /**
  42915. * Gets a vrController by name.
  42916. * @param name The name of the controller to retreive
  42917. * @returns the controller matching the name specified or null if not found
  42918. */
  42919. getControllerByName(name: string): Nullable<WebVRController>;
  42920. private _leftController;
  42921. /**
  42922. * The controller corrisponding to the users left hand.
  42923. */
  42924. readonly leftController: Nullable<WebVRController>;
  42925. private _rightController;
  42926. /**
  42927. * The controller corrisponding to the users right hand.
  42928. */
  42929. readonly rightController: Nullable<WebVRController>;
  42930. /**
  42931. * Casts a ray forward from the vrCamera's gaze.
  42932. * @param length Length of the ray (default: 100)
  42933. * @returns the ray corrisponding to the gaze
  42934. */
  42935. getForwardRay(length?: number): Ray;
  42936. /**
  42937. * @hidden
  42938. * Updates the camera based on device's frame data
  42939. */
  42940. _checkInputs(): void;
  42941. /**
  42942. * Updates the poseControlled values based on the input device pose.
  42943. * @param poseData Pose coming from the device
  42944. */
  42945. updateFromDevice(poseData: DevicePose): void;
  42946. private _htmlElementAttached;
  42947. private _detachIfAttached;
  42948. /**
  42949. * WebVR's attach control will start broadcasting frames to the device.
  42950. * Note that in certain browsers (chrome for example) this function must be called
  42951. * within a user-interaction callback. Example:
  42952. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  42953. *
  42954. * @param element html element to attach the vrDevice to
  42955. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  42956. */
  42957. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42958. /**
  42959. * Detaches the camera from the html element and disables VR
  42960. *
  42961. * @param element html element to detach from
  42962. */
  42963. detachControl(element: HTMLElement): void;
  42964. /**
  42965. * @returns the name of this class
  42966. */
  42967. getClassName(): string;
  42968. /**
  42969. * Calls resetPose on the vrDisplay
  42970. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  42971. */
  42972. resetToCurrentRotation(): void;
  42973. /**
  42974. * @hidden
  42975. * Updates the rig cameras (left and right eye)
  42976. */
  42977. _updateRigCameras(): void;
  42978. private _workingVector;
  42979. private _oneVector;
  42980. private _workingMatrix;
  42981. private updateCacheCalled;
  42982. private _correctPositionIfNotTrackPosition;
  42983. /**
  42984. * @hidden
  42985. * Updates the cached values of the camera
  42986. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  42987. */
  42988. _updateCache(ignoreParentClass?: boolean): void;
  42989. /**
  42990. * @hidden
  42991. * Get current device position in babylon world
  42992. */
  42993. _computeDevicePosition(): void;
  42994. /**
  42995. * Updates the current device position and rotation in the babylon world
  42996. */
  42997. update(): void;
  42998. /**
  42999. * @hidden
  43000. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  43001. * @returns an identity matrix
  43002. */
  43003. _getViewMatrix(): Matrix;
  43004. private _tmpMatrix;
  43005. /**
  43006. * This function is called by the two RIG cameras.
  43007. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  43008. */
  43009. protected _getWebVRViewMatrix(): Matrix;
  43010. protected _getWebVRProjectionMatrix(): Matrix;
  43011. private _onGamepadConnectedObserver;
  43012. private _onGamepadDisconnectedObserver;
  43013. private _updateCacheWhenTrackingDisabledObserver;
  43014. /**
  43015. * Initializes the controllers and their meshes
  43016. */
  43017. initControllers(): void;
  43018. }
  43019. }
  43020. declare module BABYLON {
  43021. /**
  43022. * WebXR Camera which holds the views for the xrSession
  43023. * @see https://doc.babylonjs.com/how_to/webxr
  43024. */
  43025. class WebXRCamera extends FreeCamera {
  43026. private static _TmpMatrix;
  43027. /**
  43028. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  43029. * @param name the name of the camera
  43030. * @param scene the scene to add the camera to
  43031. */
  43032. constructor(name: string, scene: BABYLON.Scene);
  43033. private _updateNumberOfRigCameras;
  43034. /** @hidden */
  43035. _updateForDualEyeDebugging(pupilDistance?: number): void;
  43036. /**
  43037. * Updates the cameras position from the current pose information of the XR session
  43038. * @param xrSessionManager the session containing pose information
  43039. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  43040. */
  43041. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  43042. }
  43043. }
  43044. declare module BABYLON {
  43045. /**
  43046. * Button which can be used to enter a different mode of XR
  43047. */
  43048. class WebXREnterExitUIButton {
  43049. /** button element */
  43050. element: HTMLElement;
  43051. /** XR initialization options for the button */
  43052. initializationOptions: XRSessionCreationOptions;
  43053. /**
  43054. * Creates a WebXREnterExitUIButton
  43055. * @param element button element
  43056. * @param initializationOptions XR initialization options for the button
  43057. */
  43058. constructor(
  43059. /** button element */
  43060. element: HTMLElement,
  43061. /** XR initialization options for the button */
  43062. initializationOptions: XRSessionCreationOptions);
  43063. /**
  43064. * Overwritable function which can be used to update the button's visuals when the state changes
  43065. * @param activeButton the current active button in the UI
  43066. */
  43067. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  43068. }
  43069. /**
  43070. * Options to create the webXR UI
  43071. */
  43072. class WebXREnterExitUIOptions {
  43073. /**
  43074. * Context to enter xr with
  43075. */
  43076. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  43077. /**
  43078. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  43079. */
  43080. customButtons?: Array<WebXREnterExitUIButton>;
  43081. }
  43082. /**
  43083. * UI to allow the user to enter/exit XR mode
  43084. */
  43085. class WebXREnterExitUI implements IDisposable {
  43086. private scene;
  43087. private _overlay;
  43088. private _buttons;
  43089. private _activeButton;
  43090. /**
  43091. * Fired every time the active button is changed.
  43092. *
  43093. * When xr is entered via a button that launches xr that button will be the callback parameter
  43094. *
  43095. * When exiting xr the callback parameter will be null)
  43096. */
  43097. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  43098. /**
  43099. * Creates UI to allow the user to enter/exit XR mode
  43100. * @param scene the scene to add the ui to
  43101. * @param helper the xr experience helper to enter/exit xr with
  43102. * @param options options to configure the UI
  43103. * @returns the created ui
  43104. */
  43105. static CreateAsync(scene: BABYLON.Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  43106. private constructor();
  43107. private _updateButtons;
  43108. /**
  43109. * Disposes of the object
  43110. */
  43111. dispose(): void;
  43112. }
  43113. }
  43114. declare module BABYLON {
  43115. /**
  43116. * States of the webXR experience
  43117. */
  43118. enum WebXRState {
  43119. /**
  43120. * Transitioning to being in XR mode
  43121. */
  43122. ENTERING_XR = 0,
  43123. /**
  43124. * Transitioning to non XR mode
  43125. */
  43126. EXITING_XR = 1,
  43127. /**
  43128. * In XR mode and presenting
  43129. */
  43130. IN_XR = 2,
  43131. /**
  43132. * Not entered XR mode
  43133. */
  43134. NOT_IN_XR = 3
  43135. }
  43136. /**
  43137. * Helper class used to enable XR
  43138. * @see https://doc.babylonjs.com/how_to/webxr
  43139. */
  43140. class WebXRExperienceHelper implements IDisposable {
  43141. private scene;
  43142. /**
  43143. * 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
  43144. */
  43145. container: AbstractMesh;
  43146. /**
  43147. * Camera used to render xr content
  43148. */
  43149. camera: WebXRCamera;
  43150. /**
  43151. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  43152. */
  43153. state: WebXRState;
  43154. private _setState;
  43155. private static _TmpVector;
  43156. /**
  43157. * Fires when the state of the experience helper has changed
  43158. */
  43159. onStateChangedObservable: Observable<WebXRState>;
  43160. /** @hidden */
  43161. _sessionManager: WebXRSessionManager;
  43162. private _nonVRCamera;
  43163. private _originalSceneAutoClear;
  43164. private _supported;
  43165. /**
  43166. * Creates the experience helper
  43167. * @param scene the scene to attach the experience helper to
  43168. * @returns a promise for the experience helper
  43169. */
  43170. static CreateAsync(scene: BABYLON.Scene): Promise<WebXRExperienceHelper>;
  43171. /**
  43172. * Creates a WebXRExperienceHelper
  43173. * @param scene The scene the helper should be created in
  43174. */
  43175. private constructor();
  43176. /**
  43177. * Exits XR mode and returns the scene to its original state
  43178. * @returns promise that resolves after xr mode has exited
  43179. */
  43180. exitXRAsync(): Promise<void>;
  43181. /**
  43182. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  43183. * @param sessionCreationOptions options for the XR session
  43184. * @param frameOfReference frame of reference of the XR session
  43185. * @returns promise that resolves after xr mode has entered
  43186. */
  43187. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  43188. /**
  43189. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  43190. * @param ray ray to cast into the environment
  43191. * @returns Promise which resolves with a collision point in the environment if it exists
  43192. */
  43193. environmentPointHitTestAsync(ray: BABYLON.Ray): Promise<Nullable<Vector3>>;
  43194. /**
  43195. * Updates the global position of the camera by moving the camera's container
  43196. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  43197. * @param position The desired global position of the camera
  43198. */
  43199. setPositionOfCameraUsingContainer(position: Vector3): void;
  43200. /**
  43201. * Rotates the xr camera by rotating the camera's container around the camera's position
  43202. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  43203. * @param rotation the desired quaternion rotation to apply to the camera
  43204. */
  43205. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  43206. /**
  43207. * Checks if the creation options are supported by the xr session
  43208. * @param options creation options
  43209. * @returns true if supported
  43210. */
  43211. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  43212. /**
  43213. * Disposes of the experience helper
  43214. */
  43215. dispose(): void;
  43216. }
  43217. }
  43218. declare module BABYLON {
  43219. /**
  43220. * Represents an XR input
  43221. */
  43222. class WebXRController {
  43223. /**
  43224. * 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
  43225. */
  43226. grip?: BABYLON.AbstractMesh;
  43227. /**
  43228. * Pointer which can be used to select objects or attach a visible laser to
  43229. */
  43230. pointer: BABYLON.AbstractMesh;
  43231. /**
  43232. * Creates the controller
  43233. * @see https://doc.babylonjs.com/how_to/webxr
  43234. * @param scene the scene which the controller should be associated to
  43235. */
  43236. constructor(scene: BABYLON.Scene);
  43237. /**
  43238. * Disposes of the object
  43239. */
  43240. dispose(): void;
  43241. }
  43242. /**
  43243. * XR input used to track XR inputs such as controllers/rays
  43244. */
  43245. class WebXRInput implements IDisposable {
  43246. private helper;
  43247. /**
  43248. * XR controllers being tracked
  43249. */
  43250. controllers: Array<WebXRController>;
  43251. private _tmpMatrix;
  43252. private _frameObserver;
  43253. /**
  43254. * Initializes the WebXRInput
  43255. * @param helper experience helper which the input should be created for
  43256. */
  43257. constructor(helper: WebXRExperienceHelper);
  43258. /**
  43259. * Disposes of the object
  43260. */
  43261. dispose(): void;
  43262. }
  43263. }
  43264. declare module BABYLON {
  43265. /**
  43266. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  43267. */
  43268. class WebXRManagedOutputCanvas implements IDisposable {
  43269. private _canvas;
  43270. /**
  43271. * xrpresent context of the canvas which can be used to display/mirror xr content
  43272. */
  43273. canvasContext: Nullable<WebGLRenderingContext>;
  43274. /**
  43275. * Initializes the canvas to be added/removed upon entering/exiting xr
  43276. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  43277. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  43278. */
  43279. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  43280. /**
  43281. * Disposes of the object
  43282. */
  43283. dispose(): void;
  43284. private _setManagedOutputCanvas;
  43285. private _addCanvas;
  43286. private _removeCanvas;
  43287. }
  43288. }
  43289. declare module BABYLON {
  43290. /**
  43291. * Manages an XRSession
  43292. * @see https://doc.babylonjs.com/how_to/webxr
  43293. */
  43294. class WebXRSessionManager implements IDisposable {
  43295. private scene;
  43296. /**
  43297. * Fires every time a new xrFrame arrives which can be used to update the camera
  43298. */
  43299. onXRFrameObservable: Observable<any>;
  43300. /**
  43301. * Fires when the xr session is ended either by the device or manually done
  43302. */
  43303. onXRSessionEnded: Observable<any>;
  43304. /** @hidden */
  43305. _xrSession: XRSession;
  43306. /** @hidden */
  43307. _frameOfReference: XRFrameOfReference;
  43308. /** @hidden */
  43309. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  43310. /** @hidden */
  43311. _currentXRFrame: Nullable<XRFrame>;
  43312. private _xrNavigator;
  43313. private _xrDevice;
  43314. private _tmpMatrix;
  43315. /**
  43316. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  43317. * @param scene The scene which the session should be created for
  43318. */
  43319. constructor(scene: BABYLON.Scene);
  43320. /**
  43321. * Initializes the manager
  43322. * After initialization enterXR can be called to start an XR session
  43323. * @returns Promise which resolves after it is initialized
  43324. */
  43325. initializeAsync(): Promise<void>;
  43326. /**
  43327. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  43328. * @param sessionCreationOptions xr options to create the session with
  43329. * @param frameOfReferenceType option to configure how the xr pose is expressed
  43330. * @returns Promise which resolves after it enters XR
  43331. */
  43332. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  43333. /**
  43334. * Stops the xrSession and restores the renderloop
  43335. * @returns Promise which resolves after it exits XR
  43336. */
  43337. exitXRAsync(): Promise<void>;
  43338. /**
  43339. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  43340. * @param ray ray to cast into the environment
  43341. * @returns Promise which resolves with a collision point in the environment if it exists
  43342. */
  43343. environmentPointHitTestAsync(ray: BABYLON.Ray): Promise<Nullable<Vector3>>;
  43344. /**
  43345. * Checks if a session would be supported for the creation options specified
  43346. * @param options creation options to check if they are supported
  43347. * @returns true if supported
  43348. */
  43349. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  43350. /**
  43351. * @hidden
  43352. * Converts the render layer of xrSession to a render target
  43353. * @param session session to create render target for
  43354. * @param scene scene the new render target should be created for
  43355. */
  43356. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: BABYLON.Scene): RenderTargetTexture;
  43357. /**
  43358. * Disposes of the session manager
  43359. */
  43360. dispose(): void;
  43361. }
  43362. }
  43363. declare module BABYLON {
  43364. /**
  43365. * Contains an array of blocks representing the octree
  43366. */
  43367. interface IOctreeContainer<T> {
  43368. /**
  43369. * Blocks within the octree
  43370. */
  43371. blocks: Array<OctreeBlock<T>>;
  43372. }
  43373. /**
  43374. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  43375. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43376. */
  43377. class Octree<T> {
  43378. /** 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.) */
  43379. maxDepth: number;
  43380. /**
  43381. * Blocks within the octree containing objects
  43382. */
  43383. blocks: Array<OctreeBlock<T>>;
  43384. /**
  43385. * Content stored in the octree
  43386. */
  43387. dynamicContent: T[];
  43388. private _maxBlockCapacity;
  43389. private _selectionContent;
  43390. private _creationFunc;
  43391. /**
  43392. * Creates a octree
  43393. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43394. * @param creationFunc function to be used to instatiate the octree
  43395. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  43396. * @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.)
  43397. */
  43398. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  43399. /** 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.) */
  43400. maxDepth?: number);
  43401. /**
  43402. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  43403. * @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);
  43404. * @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);
  43405. * @param entries meshes to be added to the octree blocks
  43406. */
  43407. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  43408. /**
  43409. * Adds a mesh to the octree
  43410. * @param entry Mesh to add to the octree
  43411. */
  43412. addMesh(entry: T): void;
  43413. /**
  43414. * Selects an array of meshes within the frustum
  43415. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  43416. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  43417. * @returns array of meshes within the frustum
  43418. */
  43419. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  43420. /**
  43421. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  43422. * @param sphereCenter defines the bounding sphere center
  43423. * @param sphereRadius defines the bounding sphere radius
  43424. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43425. * @returns an array of objects that intersect the sphere
  43426. */
  43427. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  43428. /**
  43429. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  43430. * @param ray defines the ray to test with
  43431. * @returns array of intersected objects
  43432. */
  43433. intersectsRay(ray: Ray): SmartArray<T>;
  43434. /**
  43435. * @hidden
  43436. */
  43437. 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;
  43438. /**
  43439. * Adds a mesh into the octree block if it intersects the block
  43440. */
  43441. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  43442. /**
  43443. * Adds a submesh into the octree block if it intersects the block
  43444. */
  43445. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  43446. }
  43447. }
  43448. declare module BABYLON {
  43449. /**
  43450. * Class used to store a cell in an octree
  43451. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43452. */
  43453. class OctreeBlock<T> {
  43454. /**
  43455. * Gets the content of the current block
  43456. */
  43457. entries: T[];
  43458. /**
  43459. * Gets the list of block children
  43460. */
  43461. blocks: Array<OctreeBlock<T>>;
  43462. private _depth;
  43463. private _maxDepth;
  43464. private _capacity;
  43465. private _minPoint;
  43466. private _maxPoint;
  43467. private _boundingVectors;
  43468. private _creationFunc;
  43469. /**
  43470. * Creates a new block
  43471. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  43472. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  43473. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  43474. * @param depth defines the current depth of this block in the octree
  43475. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  43476. * @param creationFunc defines a callback to call when an element is added to the block
  43477. */
  43478. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  43479. /**
  43480. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  43481. */
  43482. readonly capacity: number;
  43483. /**
  43484. * Gets the minimum vector (in world space) of the block's bounding box
  43485. */
  43486. readonly minPoint: Vector3;
  43487. /**
  43488. * Gets the maximum vector (in world space) of the block's bounding box
  43489. */
  43490. readonly maxPoint: Vector3;
  43491. /**
  43492. * Add a new element to this block
  43493. * @param entry defines the element to add
  43494. */
  43495. addEntry(entry: T): void;
  43496. /**
  43497. * Add an array of elements to this block
  43498. * @param entries defines the array of elements to add
  43499. */
  43500. addEntries(entries: T[]): void;
  43501. /**
  43502. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  43503. * @param frustumPlanes defines the frustum planes to test
  43504. * @param selection defines the array to store current content if selection is positive
  43505. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43506. */
  43507. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  43508. /**
  43509. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  43510. * @param sphereCenter defines the bounding sphere center
  43511. * @param sphereRadius defines the bounding sphere radius
  43512. * @param selection defines the array to store current content if selection is positive
  43513. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43514. */
  43515. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  43516. /**
  43517. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  43518. * @param ray defines the ray to test with
  43519. * @param selection defines the array to store current content if selection is positive
  43520. */
  43521. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  43522. /**
  43523. * Subdivide the content into child blocks (this block will then be empty)
  43524. */
  43525. createInnerBlocks(): void;
  43526. }
  43527. }
  43528. declare module BABYLON {
  43529. interface Scene {
  43530. /**
  43531. * @hidden
  43532. * Backing Filed
  43533. */
  43534. _selectionOctree: Octree<AbstractMesh>;
  43535. /**
  43536. * Gets the octree used to boost mesh selection (picking)
  43537. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43538. */
  43539. selectionOctree: Octree<AbstractMesh>;
  43540. /**
  43541. * Creates or updates the octree used to boost selection (picking)
  43542. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43543. * @param maxCapacity defines the maximum capacity per leaf
  43544. * @param maxDepth defines the maximum depth of the octree
  43545. * @returns an octree of AbstractMesh
  43546. */
  43547. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  43548. }
  43549. interface AbstractMesh {
  43550. /**
  43551. * @hidden
  43552. * Backing Field
  43553. */
  43554. _submeshesOctree: Octree<SubMesh>;
  43555. /**
  43556. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  43557. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  43558. * @param maxCapacity defines the maximum size of each block (64 by default)
  43559. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  43560. * @returns the new octree
  43561. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  43562. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43563. */
  43564. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  43565. }
  43566. /**
  43567. * Defines the octree scene component responsible to manage any octrees
  43568. * in a given scene.
  43569. */
  43570. class OctreeSceneComponent {
  43571. /**
  43572. * The component name helpfull to identify the component in the list of scene components.
  43573. */
  43574. readonly name: string;
  43575. /**
  43576. * The scene the component belongs to.
  43577. */
  43578. scene: Scene;
  43579. /**
  43580. * Indicates if the meshes have been checked to make sure they are isEnabled()
  43581. */
  43582. readonly checksIsEnabled: boolean;
  43583. /**
  43584. * Creates a new instance of the component for the given scene
  43585. * @param scene Defines the scene to register the component in
  43586. */
  43587. constructor(scene: Scene);
  43588. /**
  43589. * Registers the component in a given scene
  43590. */
  43591. register(): void;
  43592. /**
  43593. * Return the list of active meshes
  43594. * @returns the list of active meshes
  43595. */
  43596. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  43597. /**
  43598. * Return the list of active sub meshes
  43599. * @param mesh The mesh to get the candidates sub meshes from
  43600. * @returns the list of active sub meshes
  43601. */
  43602. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  43603. private _tempRay;
  43604. /**
  43605. * Return the list of sub meshes intersecting with a given local ray
  43606. * @param mesh defines the mesh to find the submesh for
  43607. * @param localRay defines the ray in local space
  43608. * @returns the list of intersecting sub meshes
  43609. */
  43610. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  43611. /**
  43612. * Return the list of sub meshes colliding with a collider
  43613. * @param mesh defines the mesh to find the submesh for
  43614. * @param collider defines the collider to evaluate the collision against
  43615. * @returns the list of colliding sub meshes
  43616. */
  43617. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  43618. /**
  43619. * Rebuilds the elements related to this component in case of
  43620. * context lost for instance.
  43621. */
  43622. rebuild(): void;
  43623. /**
  43624. * Disposes the component and the associated ressources.
  43625. */
  43626. dispose(): void;
  43627. }
  43628. }
  43629. declare module BABYLON {
  43630. /** @hidden */
  43631. class _OcclusionDataStorage {
  43632. /** @hidden */
  43633. occlusionInternalRetryCounter: number;
  43634. /** @hidden */
  43635. isOcclusionQueryInProgress: boolean;
  43636. /** @hidden */
  43637. isOccluded: boolean;
  43638. /** @hidden */
  43639. occlusionRetryCount: number;
  43640. /** @hidden */
  43641. occlusionType: number;
  43642. /** @hidden */
  43643. occlusionQueryAlgorithmType: number;
  43644. }
  43645. interface Engine {
  43646. /**
  43647. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  43648. * @return the new query
  43649. */
  43650. createQuery(): WebGLQuery;
  43651. /**
  43652. * Delete and release a webGL query
  43653. * @param query defines the query to delete
  43654. * @return the current engine
  43655. */
  43656. deleteQuery(query: WebGLQuery): Engine;
  43657. /**
  43658. * Check if a given query has resolved and got its value
  43659. * @param query defines the query to check
  43660. * @returns true if the query got its value
  43661. */
  43662. isQueryResultAvailable(query: WebGLQuery): boolean;
  43663. /**
  43664. * Gets the value of a given query
  43665. * @param query defines the query to check
  43666. * @returns the value of the query
  43667. */
  43668. getQueryResult(query: WebGLQuery): number;
  43669. /**
  43670. * Initiates an occlusion query
  43671. * @param algorithmType defines the algorithm to use
  43672. * @param query defines the query to use
  43673. * @returns the current engine
  43674. * @see http://doc.babylonjs.com/features/occlusionquery
  43675. */
  43676. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  43677. /**
  43678. * Ends an occlusion query
  43679. * @see http://doc.babylonjs.com/features/occlusionquery
  43680. * @param algorithmType defines the algorithm to use
  43681. * @returns the current engine
  43682. */
  43683. endOcclusionQuery(algorithmType: number): Engine;
  43684. /**
  43685. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  43686. * Please note that only one query can be issued at a time
  43687. * @returns a time token used to track the time span
  43688. */
  43689. startTimeQuery(): Nullable<_TimeToken>;
  43690. /**
  43691. * Ends a time query
  43692. * @param token defines the token used to measure the time span
  43693. * @returns the time spent (in ns)
  43694. */
  43695. endTimeQuery(token: _TimeToken): int;
  43696. /** @hidden */
  43697. _currentNonTimestampToken: Nullable<_TimeToken>;
  43698. /** @hidden */
  43699. _createTimeQuery(): WebGLQuery;
  43700. /** @hidden */
  43701. _deleteTimeQuery(query: WebGLQuery): void;
  43702. /** @hidden */
  43703. _getGlAlgorithmType(algorithmType: number): number;
  43704. /** @hidden */
  43705. _getTimeQueryResult(query: WebGLQuery): any;
  43706. /** @hidden */
  43707. _getTimeQueryAvailability(query: WebGLQuery): any;
  43708. }
  43709. interface AbstractMesh {
  43710. /**
  43711. * Backing filed
  43712. * @hidden
  43713. */
  43714. __occlusionDataStorage: _OcclusionDataStorage;
  43715. /**
  43716. * Access property
  43717. * @hidden
  43718. */
  43719. _occlusionDataStorage: _OcclusionDataStorage;
  43720. /**
  43721. * 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.
  43722. * The default value is -1 which means don't break the query and wait till the result
  43723. * @see http://doc.babylonjs.com/features/occlusionquery
  43724. */
  43725. occlusionRetryCount: number;
  43726. /**
  43727. * 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:
  43728. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  43729. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  43730. * * 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.
  43731. * @see http://doc.babylonjs.com/features/occlusionquery
  43732. */
  43733. occlusionType: number;
  43734. /**
  43735. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  43736. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  43737. * * 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.
  43738. * @see http://doc.babylonjs.com/features/occlusionquery
  43739. */
  43740. occlusionQueryAlgorithmType: number;
  43741. /**
  43742. * 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
  43743. * @see http://doc.babylonjs.com/features/occlusionquery
  43744. */
  43745. isOccluded: boolean;
  43746. /**
  43747. * Flag to check the progress status of the query
  43748. * @see http://doc.babylonjs.com/features/occlusionquery
  43749. */
  43750. isOcclusionQueryInProgress: boolean;
  43751. }
  43752. }
  43753. declare module BABYLON {
  43754. interface Engine {
  43755. /**
  43756. * Creates a webGL transform feedback object
  43757. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  43758. * @returns the webGL transform feedback object
  43759. */
  43760. createTransformFeedback(): WebGLTransformFeedback;
  43761. /**
  43762. * Delete a webGL transform feedback object
  43763. * @param value defines the webGL transform feedback object to delete
  43764. */
  43765. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  43766. /**
  43767. * Bind a webGL transform feedback object to the webgl context
  43768. * @param value defines the webGL transform feedback object to bind
  43769. */
  43770. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  43771. /**
  43772. * Begins a transform feedback operation
  43773. * @param usePoints defines if points or triangles must be used
  43774. */
  43775. beginTransformFeedback(usePoints: boolean): void;
  43776. /**
  43777. * Ends a transform feedback operation
  43778. */
  43779. endTransformFeedback(): void;
  43780. /**
  43781. * Specify the varyings to use with transform feedback
  43782. * @param program defines the associated webGL program
  43783. * @param value defines the list of strings representing the varying names
  43784. */
  43785. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  43786. /**
  43787. * Bind a webGL buffer for a transform feedback operation
  43788. * @param value defines the webGL buffer to bind
  43789. */
  43790. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  43791. }
  43792. }
  43793. declare module BABYLON {
  43794. /**
  43795. * Google Daydream controller
  43796. */
  43797. class DaydreamController extends WebVRController {
  43798. /**
  43799. * Base Url for the controller model.
  43800. */
  43801. static MODEL_BASE_URL: string;
  43802. /**
  43803. * File name for the controller model.
  43804. */
  43805. static MODEL_FILENAME: string;
  43806. /**
  43807. * Gamepad Id prefix used to identify Daydream Controller.
  43808. */
  43809. static readonly GAMEPAD_ID_PREFIX: string;
  43810. /**
  43811. * Creates a new DaydreamController from a gamepad
  43812. * @param vrGamepad the gamepad that the controller should be created from
  43813. */
  43814. constructor(vrGamepad: any);
  43815. /**
  43816. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43817. * @param scene scene in which to add meshes
  43818. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43819. */
  43820. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43821. /**
  43822. * Called once for each button that changed state since the last frame
  43823. * @param buttonIdx Which button index changed
  43824. * @param state New state of the button
  43825. * @param changes Which properties on the state changed since last frame
  43826. */
  43827. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43828. }
  43829. }
  43830. declare module BABYLON {
  43831. /**
  43832. * Gear VR Controller
  43833. */
  43834. class GearVRController extends WebVRController {
  43835. /**
  43836. * Base Url for the controller model.
  43837. */
  43838. static MODEL_BASE_URL: string;
  43839. /**
  43840. * File name for the controller model.
  43841. */
  43842. static MODEL_FILENAME: string;
  43843. /**
  43844. * Gamepad Id prefix used to identify this controller.
  43845. */
  43846. static readonly GAMEPAD_ID_PREFIX: string;
  43847. private readonly _buttonIndexToObservableNameMap;
  43848. /**
  43849. * Creates a new GearVRController from a gamepad
  43850. * @param vrGamepad the gamepad that the controller should be created from
  43851. */
  43852. constructor(vrGamepad: any);
  43853. /**
  43854. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43855. * @param scene scene in which to add meshes
  43856. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43857. */
  43858. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43859. /**
  43860. * Called once for each button that changed state since the last frame
  43861. * @param buttonIdx Which button index changed
  43862. * @param state New state of the button
  43863. * @param changes Which properties on the state changed since last frame
  43864. */
  43865. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43866. }
  43867. }
  43868. declare module BABYLON {
  43869. /**
  43870. * Generic Controller
  43871. */
  43872. class GenericController extends WebVRController {
  43873. /**
  43874. * Base Url for the controller model.
  43875. */
  43876. static readonly MODEL_BASE_URL: string;
  43877. /**
  43878. * File name for the controller model.
  43879. */
  43880. static readonly MODEL_FILENAME: string;
  43881. /**
  43882. * Creates a new GenericController from a gamepad
  43883. * @param vrGamepad the gamepad that the controller should be created from
  43884. */
  43885. constructor(vrGamepad: any);
  43886. /**
  43887. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43888. * @param scene scene in which to add meshes
  43889. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43890. */
  43891. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43892. /**
  43893. * Called once for each button that changed state since the last frame
  43894. * @param buttonIdx Which button index changed
  43895. * @param state New state of the button
  43896. * @param changes Which properties on the state changed since last frame
  43897. */
  43898. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43899. }
  43900. }
  43901. declare module BABYLON {
  43902. /**
  43903. * Oculus Touch Controller
  43904. */
  43905. class OculusTouchController extends WebVRController {
  43906. /**
  43907. * Base Url for the controller model.
  43908. */
  43909. static MODEL_BASE_URL: string;
  43910. /**
  43911. * File name for the left controller model.
  43912. */
  43913. static MODEL_LEFT_FILENAME: string;
  43914. /**
  43915. * File name for the right controller model.
  43916. */
  43917. static MODEL_RIGHT_FILENAME: string;
  43918. /**
  43919. * Fired when the secondary trigger on this controller is modified
  43920. */
  43921. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43922. /**
  43923. * Fired when the thumb rest on this controller is modified
  43924. */
  43925. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43926. /**
  43927. * Creates a new OculusTouchController from a gamepad
  43928. * @param vrGamepad the gamepad that the controller should be created from
  43929. */
  43930. constructor(vrGamepad: any);
  43931. /**
  43932. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43933. * @param scene scene in which to add meshes
  43934. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43935. */
  43936. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43937. /**
  43938. * Fired when the A button on this controller is modified
  43939. */
  43940. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43941. /**
  43942. * Fired when the B button on this controller is modified
  43943. */
  43944. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43945. /**
  43946. * Fired when the X button on this controller is modified
  43947. */
  43948. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43949. /**
  43950. * Fired when the Y button on this controller is modified
  43951. */
  43952. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43953. /**
  43954. * Called once for each button that changed state since the last frame
  43955. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43956. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43957. * 2) secondary trigger (same)
  43958. * 3) A (right) X (left), touch, pressed = value
  43959. * 4) B / Y
  43960. * 5) thumb rest
  43961. * @param buttonIdx Which button index changed
  43962. * @param state New state of the button
  43963. * @param changes Which properties on the state changed since last frame
  43964. */
  43965. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43966. }
  43967. }
  43968. declare module BABYLON {
  43969. /**
  43970. * Defines the types of pose enabled controllers that are supported
  43971. */
  43972. enum PoseEnabledControllerType {
  43973. /**
  43974. * HTC Vive
  43975. */
  43976. VIVE = 0,
  43977. /**
  43978. * Oculus Rift
  43979. */
  43980. OCULUS = 1,
  43981. /**
  43982. * Windows mixed reality
  43983. */
  43984. WINDOWS = 2,
  43985. /**
  43986. * Samsung gear VR
  43987. */
  43988. GEAR_VR = 3,
  43989. /**
  43990. * Google Daydream
  43991. */
  43992. DAYDREAM = 4,
  43993. /**
  43994. * Generic
  43995. */
  43996. GENERIC = 5
  43997. }
  43998. /**
  43999. * Defines the MutableGamepadButton interface for the state of a gamepad button
  44000. */
  44001. interface MutableGamepadButton {
  44002. /**
  44003. * Value of the button/trigger
  44004. */
  44005. value: number;
  44006. /**
  44007. * If the button/trigger is currently touched
  44008. */
  44009. touched: boolean;
  44010. /**
  44011. * If the button/trigger is currently pressed
  44012. */
  44013. pressed: boolean;
  44014. }
  44015. /**
  44016. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  44017. * @hidden
  44018. */
  44019. interface ExtendedGamepadButton extends GamepadButton {
  44020. /**
  44021. * If the button/trigger is currently pressed
  44022. */
  44023. readonly pressed: boolean;
  44024. /**
  44025. * If the button/trigger is currently touched
  44026. */
  44027. readonly touched: boolean;
  44028. /**
  44029. * Value of the button/trigger
  44030. */
  44031. readonly value: number;
  44032. }
  44033. /**
  44034. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  44035. */
  44036. class PoseEnabledControllerHelper {
  44037. /**
  44038. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  44039. * @param vrGamepad the gamepad to initialized
  44040. * @returns a vr controller of the type the gamepad identified as
  44041. */
  44042. static InitiateController(vrGamepad: any): OculusTouchController | WindowsMotionController | ViveController | GearVRController | DaydreamController | GenericController;
  44043. }
  44044. /**
  44045. * Defines the PoseEnabledController object that contains state of a vr capable controller
  44046. */
  44047. class PoseEnabledController extends Gamepad implements PoseControlled {
  44048. private _deviceRoomPosition;
  44049. private _deviceRoomRotationQuaternion;
  44050. /**
  44051. * The device position in babylon space
  44052. */
  44053. devicePosition: Vector3;
  44054. /**
  44055. * The device rotation in babylon space
  44056. */
  44057. deviceRotationQuaternion: Quaternion;
  44058. /**
  44059. * The scale factor of the device in babylon space
  44060. */
  44061. deviceScaleFactor: number;
  44062. /**
  44063. * (Likely devicePosition should be used instead) The device position in its room space
  44064. */
  44065. position: Vector3;
  44066. /**
  44067. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  44068. */
  44069. rotationQuaternion: Quaternion;
  44070. /**
  44071. * The type of controller (Eg. Windows mixed reality)
  44072. */
  44073. controllerType: PoseEnabledControllerType;
  44074. protected _calculatedPosition: Vector3;
  44075. private _calculatedRotation;
  44076. /**
  44077. * The raw pose from the device
  44078. */
  44079. rawPose: DevicePose;
  44080. private _trackPosition;
  44081. private _maxRotationDistFromHeadset;
  44082. private _draggedRoomRotation;
  44083. /**
  44084. * @hidden
  44085. */
  44086. _disableTrackPosition(fixedPosition: Vector3): void;
  44087. /**
  44088. * Internal, the mesh attached to the controller
  44089. * @hidden
  44090. */
  44091. _mesh: Nullable<AbstractMesh>;
  44092. private _poseControlledCamera;
  44093. private _leftHandSystemQuaternion;
  44094. /**
  44095. * Internal, matrix used to convert room space to babylon space
  44096. * @hidden
  44097. */
  44098. _deviceToWorld: Matrix;
  44099. /**
  44100. * Node to be used when casting a ray from the controller
  44101. * @hidden
  44102. */
  44103. _pointingPoseNode: Nullable<TransformNode>;
  44104. /**
  44105. * Name of the child mesh that can be used to cast a ray from the controller
  44106. */
  44107. static readonly POINTING_POSE: string;
  44108. /**
  44109. * Creates a new PoseEnabledController from a gamepad
  44110. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  44111. */
  44112. constructor(browserGamepad: any);
  44113. private _workingMatrix;
  44114. /**
  44115. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  44116. */
  44117. update(): void;
  44118. /**
  44119. * Updates only the pose device and mesh without doing any button event checking
  44120. */
  44121. protected _updatePoseAndMesh(): void;
  44122. /**
  44123. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  44124. * @param poseData raw pose fromthe device
  44125. */
  44126. updateFromDevice(poseData: DevicePose): void;
  44127. /**
  44128. * @hidden
  44129. */
  44130. _meshAttachedObservable: Observable<AbstractMesh>;
  44131. /**
  44132. * Attaches a mesh to the controller
  44133. * @param mesh the mesh to be attached
  44134. */
  44135. attachToMesh(mesh: AbstractMesh): void;
  44136. /**
  44137. * Attaches the controllers mesh to a camera
  44138. * @param camera the camera the mesh should be attached to
  44139. */
  44140. attachToPoseControlledCamera(camera: TargetCamera): void;
  44141. /**
  44142. * Disposes of the controller
  44143. */
  44144. dispose(): void;
  44145. /**
  44146. * The mesh that is attached to the controller
  44147. */
  44148. readonly mesh: Nullable<AbstractMesh>;
  44149. /**
  44150. * Gets the ray of the controller in the direction the controller is pointing
  44151. * @param length the length the resulting ray should be
  44152. * @returns a ray in the direction the controller is pointing
  44153. */
  44154. getForwardRay(length?: number): Ray;
  44155. }
  44156. }
  44157. declare module BABYLON {
  44158. /**
  44159. * Vive Controller
  44160. */
  44161. class ViveController extends WebVRController {
  44162. /**
  44163. * Base Url for the controller model.
  44164. */
  44165. static MODEL_BASE_URL: string;
  44166. /**
  44167. * File name for the controller model.
  44168. */
  44169. static MODEL_FILENAME: string;
  44170. /**
  44171. * Creates a new ViveController from a gamepad
  44172. * @param vrGamepad the gamepad that the controller should be created from
  44173. */
  44174. constructor(vrGamepad: any);
  44175. /**
  44176. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44177. * @param scene scene in which to add meshes
  44178. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44179. */
  44180. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44181. /**
  44182. * Fired when the left button on this controller is modified
  44183. */
  44184. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44185. /**
  44186. * Fired when the right button on this controller is modified
  44187. */
  44188. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44189. /**
  44190. * Fired when the menu button on this controller is modified
  44191. */
  44192. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44193. /**
  44194. * Called once for each button that changed state since the last frame
  44195. * Vive mapping:
  44196. * 0: touchpad
  44197. * 1: trigger
  44198. * 2: left AND right buttons
  44199. * 3: menu button
  44200. * @param buttonIdx Which button index changed
  44201. * @param state New state of the button
  44202. * @param changes Which properties on the state changed since last frame
  44203. */
  44204. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44205. }
  44206. }
  44207. declare module BABYLON {
  44208. /**
  44209. * Defines the WebVRController object that represents controllers tracked in 3D space
  44210. */
  44211. abstract class WebVRController extends PoseEnabledController {
  44212. /**
  44213. * Internal, the default controller model for the controller
  44214. */
  44215. protected _defaultModel: AbstractMesh;
  44216. /**
  44217. * Fired when the trigger state has changed
  44218. */
  44219. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  44220. /**
  44221. * Fired when the main button state has changed
  44222. */
  44223. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44224. /**
  44225. * Fired when the secondary button state has changed
  44226. */
  44227. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44228. /**
  44229. * Fired when the pad state has changed
  44230. */
  44231. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  44232. /**
  44233. * Fired when controllers stick values have changed
  44234. */
  44235. onPadValuesChangedObservable: Observable<StickValues>;
  44236. /**
  44237. * Array of button availible on the controller
  44238. */
  44239. protected _buttons: Array<MutableGamepadButton>;
  44240. private _onButtonStateChange;
  44241. /**
  44242. * Fired when a controller button's state has changed
  44243. * @param callback the callback containing the button that was modified
  44244. */
  44245. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  44246. /**
  44247. * X and Y axis corrisponding to the controllers joystick
  44248. */
  44249. pad: StickValues;
  44250. /**
  44251. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  44252. */
  44253. hand: string;
  44254. /**
  44255. * The default controller model for the controller
  44256. */
  44257. readonly defaultModel: AbstractMesh;
  44258. /**
  44259. * Creates a new WebVRController from a gamepad
  44260. * @param vrGamepad the gamepad that the WebVRController should be created from
  44261. */
  44262. constructor(vrGamepad: any);
  44263. /**
  44264. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  44265. */
  44266. update(): void;
  44267. /**
  44268. * Function to be called when a button is modified
  44269. */
  44270. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44271. /**
  44272. * Loads a mesh and attaches it to the controller
  44273. * @param scene the scene the mesh should be added to
  44274. * @param meshLoaded callback for when the mesh has been loaded
  44275. */
  44276. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44277. private _setButtonValue;
  44278. private _changes;
  44279. private _checkChanges;
  44280. /**
  44281. * Disposes of th webVRCOntroller
  44282. */
  44283. dispose(): void;
  44284. }
  44285. }
  44286. declare module BABYLON {
  44287. /**
  44288. * Defines the WindowsMotionController object that the state of the windows motion controller
  44289. */
  44290. class WindowsMotionController extends WebVRController {
  44291. /**
  44292. * The base url used to load the left and right controller models
  44293. */
  44294. static MODEL_BASE_URL: string;
  44295. /**
  44296. * The name of the left controller model file
  44297. */
  44298. static MODEL_LEFT_FILENAME: string;
  44299. /**
  44300. * The name of the right controller model file
  44301. */
  44302. static MODEL_RIGHT_FILENAME: string;
  44303. /**
  44304. * The controller name prefix for this controller type
  44305. */
  44306. static readonly GAMEPAD_ID_PREFIX: string;
  44307. /**
  44308. * The controller id pattern for this controller type
  44309. */
  44310. private static readonly GAMEPAD_ID_PATTERN;
  44311. private _loadedMeshInfo;
  44312. private readonly _mapping;
  44313. /**
  44314. * Fired when the trackpad on this controller is clicked
  44315. */
  44316. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  44317. /**
  44318. * Fired when the trackpad on this controller is modified
  44319. */
  44320. onTrackpadValuesChangedObservable: Observable<StickValues>;
  44321. /**
  44322. * The current x and y values of this controller's trackpad
  44323. */
  44324. trackpad: StickValues;
  44325. /**
  44326. * Creates a new WindowsMotionController from a gamepad
  44327. * @param vrGamepad the gamepad that the controller should be created from
  44328. */
  44329. constructor(vrGamepad: any);
  44330. /**
  44331. * Fired when the trigger on this controller is modified
  44332. */
  44333. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44334. /**
  44335. * Fired when the menu button on this controller is modified
  44336. */
  44337. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44338. /**
  44339. * Fired when the grip button on this controller is modified
  44340. */
  44341. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44342. /**
  44343. * Fired when the thumbstick button on this controller is modified
  44344. */
  44345. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44346. /**
  44347. * Fired when the touchpad button on this controller is modified
  44348. */
  44349. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44350. /**
  44351. * Fired when the touchpad values on this controller are modified
  44352. */
  44353. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  44354. private _updateTrackpad;
  44355. /**
  44356. * Called once per frame by the engine.
  44357. */
  44358. update(): void;
  44359. /**
  44360. * Called once for each button that changed state since the last frame
  44361. * @param buttonIdx Which button index changed
  44362. * @param state New state of the button
  44363. * @param changes Which properties on the state changed since last frame
  44364. */
  44365. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44366. /**
  44367. * Moves the buttons on the controller mesh based on their current state
  44368. * @param buttonName the name of the button to move
  44369. * @param buttonValue the value of the button which determines the buttons new position
  44370. */
  44371. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  44372. /**
  44373. * Moves the axis on the controller mesh based on its current state
  44374. * @param axis the index of the axis
  44375. * @param axisValue the value of the axis which determines the meshes new position
  44376. * @hidden
  44377. */
  44378. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  44379. /**
  44380. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44381. * @param scene scene in which to add meshes
  44382. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44383. */
  44384. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  44385. /**
  44386. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  44387. * can be transformed by button presses and axes values, based on this._mapping.
  44388. *
  44389. * @param scene scene in which the meshes exist
  44390. * @param meshes list of meshes that make up the controller model to process
  44391. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  44392. */
  44393. private processModel;
  44394. private createMeshInfo;
  44395. /**
  44396. * Gets the ray of the controller in the direction the controller is pointing
  44397. * @param length the length the resulting ray should be
  44398. * @returns a ray in the direction the controller is pointing
  44399. */
  44400. getForwardRay(length?: number): Ray;
  44401. /**
  44402. * Disposes of the controller
  44403. */
  44404. dispose(): void;
  44405. }
  44406. }
  44407. declare module BABYLON {
  44408. /**
  44409. * Interface to implement to create a shadow generator compatible with BJS.
  44410. */
  44411. interface IShadowGenerator {
  44412. /**
  44413. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  44414. * @returns The render target texture if present otherwise, null
  44415. */
  44416. getShadowMap(): Nullable<RenderTargetTexture>;
  44417. /**
  44418. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  44419. * @returns The render target texture if the shadow map is present otherwise, null
  44420. */
  44421. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  44422. /**
  44423. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  44424. * @param subMesh The submesh we want to render in the shadow map
  44425. * @param useInstances Defines wether will draw in the map using instances
  44426. * @returns true if ready otherwise, false
  44427. */
  44428. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  44429. /**
  44430. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  44431. * @param defines Defines of the material we want to update
  44432. * @param lightIndex Index of the light in the enabled light list of the material
  44433. */
  44434. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  44435. /**
  44436. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  44437. * defined in the generator but impacting the effect).
  44438. * It implies the unifroms available on the materials are the standard BJS ones.
  44439. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  44440. * @param effect The effect we are binfing the information for
  44441. */
  44442. bindShadowLight(lightIndex: string, effect: Effect): void;
  44443. /**
  44444. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  44445. * (eq to shadow prjection matrix * light transform matrix)
  44446. * @returns The transform matrix used to create the shadow map
  44447. */
  44448. getTransformMatrix(): Matrix;
  44449. /**
  44450. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  44451. * Cube and 2D textures for instance.
  44452. */
  44453. recreateShadowMap(): void;
  44454. /**
  44455. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  44456. * @param onCompiled Callback triggered at the and of the effects compilation
  44457. * @param options Sets of optional options forcing the compilation with different modes
  44458. */
  44459. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  44460. useInstances: boolean;
  44461. }>): void;
  44462. /**
  44463. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  44464. * @param options Sets of optional options forcing the compilation with different modes
  44465. * @returns A promise that resolves when the compilation completes
  44466. */
  44467. forceCompilationAsync(options?: Partial<{
  44468. useInstances: boolean;
  44469. }>): Promise<void>;
  44470. /**
  44471. * Serializes the shadow generator setup to a json object.
  44472. * @returns The serialized JSON object
  44473. */
  44474. serialize(): any;
  44475. /**
  44476. * Disposes the Shadow map and related Textures and effects.
  44477. */
  44478. dispose(): void;
  44479. }
  44480. /**
  44481. * Default implementation IShadowGenerator.
  44482. * This is the main object responsible of generating shadows in the framework.
  44483. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  44484. */
  44485. class ShadowGenerator implements IShadowGenerator {
  44486. /**
  44487. * Shadow generator mode None: no filtering applied.
  44488. */
  44489. static readonly FILTER_NONE: number;
  44490. /**
  44491. * Shadow generator mode ESM: Exponential Shadow Mapping.
  44492. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  44493. */
  44494. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  44495. /**
  44496. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  44497. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  44498. */
  44499. static readonly FILTER_POISSONSAMPLING: number;
  44500. /**
  44501. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  44502. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  44503. */
  44504. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  44505. /**
  44506. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  44507. * edge artifacts on steep falloff.
  44508. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  44509. */
  44510. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  44511. /**
  44512. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  44513. * edge artifacts on steep falloff.
  44514. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  44515. */
  44516. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  44517. /**
  44518. * Shadow generator mode PCF: Percentage Closer Filtering
  44519. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  44520. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  44521. */
  44522. static readonly FILTER_PCF: number;
  44523. /**
  44524. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  44525. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  44526. * Contact Hardening
  44527. */
  44528. static readonly FILTER_PCSS: number;
  44529. /**
  44530. * Reserved for PCF and PCSS
  44531. * Highest Quality.
  44532. *
  44533. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  44534. *
  44535. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  44536. */
  44537. static readonly QUALITY_HIGH: number;
  44538. /**
  44539. * Reserved for PCF and PCSS
  44540. * Good tradeoff for quality/perf cross devices
  44541. *
  44542. * Execute PCF on a 3*3 kernel.
  44543. *
  44544. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  44545. */
  44546. static readonly QUALITY_MEDIUM: number;
  44547. /**
  44548. * Reserved for PCF and PCSS
  44549. * The lowest quality but the fastest.
  44550. *
  44551. * Execute PCF on a 1*1 kernel.
  44552. *
  44553. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  44554. */
  44555. static readonly QUALITY_LOW: number;
  44556. private _bias;
  44557. /**
  44558. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  44559. */
  44560. /**
  44561. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  44562. */
  44563. bias: number;
  44564. private _normalBias;
  44565. /**
  44566. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  44567. */
  44568. /**
  44569. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  44570. */
  44571. normalBias: number;
  44572. private _blurBoxOffset;
  44573. /**
  44574. * Gets the blur box offset: offset applied during the blur pass.
  44575. * Only useful if useKernelBlur = false
  44576. */
  44577. /**
  44578. * Sets the blur box offset: offset applied during the blur pass.
  44579. * Only useful if useKernelBlur = false
  44580. */
  44581. blurBoxOffset: number;
  44582. private _blurScale;
  44583. /**
  44584. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  44585. * 2 means half of the size.
  44586. */
  44587. /**
  44588. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  44589. * 2 means half of the size.
  44590. */
  44591. blurScale: number;
  44592. private _blurKernel;
  44593. /**
  44594. * Gets the blur kernel: kernel size of the blur pass.
  44595. * Only useful if useKernelBlur = true
  44596. */
  44597. /**
  44598. * Sets the blur kernel: kernel size of the blur pass.
  44599. * Only useful if useKernelBlur = true
  44600. */
  44601. blurKernel: number;
  44602. private _useKernelBlur;
  44603. /**
  44604. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  44605. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  44606. */
  44607. /**
  44608. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  44609. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  44610. */
  44611. useKernelBlur: boolean;
  44612. private _depthScale;
  44613. /**
  44614. * Gets the depth scale used in ESM mode.
  44615. */
  44616. /**
  44617. * Sets the depth scale used in ESM mode.
  44618. * This can override the scale stored on the light.
  44619. */
  44620. depthScale: number;
  44621. private _filter;
  44622. /**
  44623. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  44624. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  44625. */
  44626. /**
  44627. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  44628. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  44629. */
  44630. filter: number;
  44631. /**
  44632. * Gets if the current filter is set to Poisson Sampling.
  44633. */
  44634. /**
  44635. * Sets the current filter to Poisson Sampling.
  44636. */
  44637. usePoissonSampling: boolean;
  44638. /**
  44639. * Gets if the current filter is set to ESM.
  44640. */
  44641. /**
  44642. * Sets the current filter is to ESM.
  44643. */
  44644. useExponentialShadowMap: boolean;
  44645. /**
  44646. * Gets if the current filter is set to filtered ESM.
  44647. */
  44648. /**
  44649. * Gets if the current filter is set to filtered ESM.
  44650. */
  44651. useBlurExponentialShadowMap: boolean;
  44652. /**
  44653. * Gets if the current filter is set to "close ESM" (using the inverse of the
  44654. * exponential to prevent steep falloff artifacts).
  44655. */
  44656. /**
  44657. * Sets the current filter to "close ESM" (using the inverse of the
  44658. * exponential to prevent steep falloff artifacts).
  44659. */
  44660. useCloseExponentialShadowMap: boolean;
  44661. /**
  44662. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  44663. * exponential to prevent steep falloff artifacts).
  44664. */
  44665. /**
  44666. * Sets the current filter to filtered "close ESM" (using the inverse of the
  44667. * exponential to prevent steep falloff artifacts).
  44668. */
  44669. useBlurCloseExponentialShadowMap: boolean;
  44670. /**
  44671. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  44672. */
  44673. /**
  44674. * Sets the current filter to "PCF" (percentage closer filtering).
  44675. */
  44676. usePercentageCloserFiltering: boolean;
  44677. private _filteringQuality;
  44678. /**
  44679. * Gets the PCF or PCSS Quality.
  44680. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  44681. */
  44682. /**
  44683. * Sets the PCF or PCSS Quality.
  44684. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  44685. */
  44686. filteringQuality: number;
  44687. /**
  44688. * Gets if the current filter is set to "PCSS" (contact hardening).
  44689. */
  44690. /**
  44691. * Sets the current filter to "PCSS" (contact hardening).
  44692. */
  44693. useContactHardeningShadow: boolean;
  44694. private _contactHardeningLightSizeUVRatio;
  44695. /**
  44696. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  44697. * Using a ratio helps keeping shape stability independently of the map size.
  44698. *
  44699. * It does not account for the light projection as it was having too much
  44700. * instability during the light setup or during light position changes.
  44701. *
  44702. * Only valid if useContactHardeningShadow is true.
  44703. */
  44704. /**
  44705. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  44706. * Using a ratio helps keeping shape stability independently of the map size.
  44707. *
  44708. * It does not account for the light projection as it was having too much
  44709. * instability during the light setup or during light position changes.
  44710. *
  44711. * Only valid if useContactHardeningShadow is true.
  44712. */
  44713. contactHardeningLightSizeUVRatio: number;
  44714. private _darkness;
  44715. /**
  44716. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  44717. * 0 means strongest and 1 would means no shadow.
  44718. * @returns the darkness.
  44719. */
  44720. getDarkness(): number;
  44721. /**
  44722. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  44723. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  44724. * @returns the shadow generator allowing fluent coding.
  44725. */
  44726. setDarkness(darkness: number): ShadowGenerator;
  44727. private _transparencyShadow;
  44728. /**
  44729. * Sets the ability to have transparent shadow (boolean).
  44730. * @param transparent True if transparent else False
  44731. * @returns the shadow generator allowing fluent coding
  44732. */
  44733. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  44734. private _shadowMap;
  44735. private _shadowMap2;
  44736. /**
  44737. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  44738. * @returns The render target texture if present otherwise, null
  44739. */
  44740. getShadowMap(): Nullable<RenderTargetTexture>;
  44741. /**
  44742. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  44743. * @returns The render target texture if the shadow map is present otherwise, null
  44744. */
  44745. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  44746. /**
  44747. * Helper function to add a mesh and its descendants to the list of shadow casters.
  44748. * @param mesh Mesh to add
  44749. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  44750. * @returns the Shadow Generator itself
  44751. */
  44752. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  44753. /**
  44754. * Helper function to remove a mesh and its descendants from the list of shadow casters
  44755. * @param mesh Mesh to remove
  44756. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  44757. * @returns the Shadow Generator itself
  44758. */
  44759. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  44760. /**
  44761. * Controls the extent to which the shadows fade out at the edge of the frustum
  44762. * Used only by directionals and spots
  44763. */
  44764. frustumEdgeFalloff: number;
  44765. private _light;
  44766. /**
  44767. * Returns the associated light object.
  44768. * @returns the light generating the shadow
  44769. */
  44770. getLight(): IShadowLight;
  44771. /**
  44772. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  44773. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  44774. * It might on the other hand introduce peter panning.
  44775. */
  44776. forceBackFacesOnly: boolean;
  44777. private _scene;
  44778. private _lightDirection;
  44779. private _effect;
  44780. private _viewMatrix;
  44781. private _projectionMatrix;
  44782. private _transformMatrix;
  44783. private _cachedPosition;
  44784. private _cachedDirection;
  44785. private _cachedDefines;
  44786. private _currentRenderID;
  44787. private _boxBlurPostprocess;
  44788. private _kernelBlurXPostprocess;
  44789. private _kernelBlurYPostprocess;
  44790. private _blurPostProcesses;
  44791. private _mapSize;
  44792. private _currentFaceIndex;
  44793. private _currentFaceIndexCache;
  44794. private _textureType;
  44795. private _defaultTextureMatrix;
  44796. /**
  44797. * Creates a ShadowGenerator object.
  44798. * A ShadowGenerator is the required tool to use the shadows.
  44799. * Each light casting shadows needs to use its own ShadowGenerator.
  44800. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  44801. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  44802. * @param light The light object generating the shadows.
  44803. * @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.
  44804. */
  44805. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  44806. private _initializeGenerator;
  44807. private _initializeShadowMap;
  44808. private _initializeBlurRTTAndPostProcesses;
  44809. private _renderForShadowMap;
  44810. private _renderSubMeshForShadowMap;
  44811. private _applyFilterValues;
  44812. /**
  44813. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  44814. * @param onCompiled Callback triggered at the and of the effects compilation
  44815. * @param options Sets of optional options forcing the compilation with different modes
  44816. */
  44817. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  44818. useInstances: boolean;
  44819. }>): void;
  44820. /**
  44821. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  44822. * @param options Sets of optional options forcing the compilation with different modes
  44823. * @returns A promise that resolves when the compilation completes
  44824. */
  44825. forceCompilationAsync(options?: Partial<{
  44826. useInstances: boolean;
  44827. }>): Promise<void>;
  44828. /**
  44829. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  44830. * @param subMesh The submesh we want to render in the shadow map
  44831. * @param useInstances Defines wether will draw in the map using instances
  44832. * @returns true if ready otherwise, false
  44833. */
  44834. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  44835. /**
  44836. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  44837. * @param defines Defines of the material we want to update
  44838. * @param lightIndex Index of the light in the enabled light list of the material
  44839. */
  44840. prepareDefines(defines: any, lightIndex: number): void;
  44841. /**
  44842. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  44843. * defined in the generator but impacting the effect).
  44844. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  44845. * @param effect The effect we are binfing the information for
  44846. */
  44847. bindShadowLight(lightIndex: string, effect: Effect): void;
  44848. /**
  44849. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  44850. * (eq to shadow prjection matrix * light transform matrix)
  44851. * @returns The transform matrix used to create the shadow map
  44852. */
  44853. getTransformMatrix(): Matrix;
  44854. /**
  44855. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  44856. * Cube and 2D textures for instance.
  44857. */
  44858. recreateShadowMap(): void;
  44859. private _disposeBlurPostProcesses;
  44860. private _disposeRTTandPostProcesses;
  44861. /**
  44862. * Disposes the ShadowGenerator.
  44863. * Returns nothing.
  44864. */
  44865. dispose(): void;
  44866. /**
  44867. * Serializes the shadow generator setup to a json object.
  44868. * @returns The serialized JSON object
  44869. */
  44870. serialize(): any;
  44871. /**
  44872. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  44873. * @param parsedShadowGenerator The JSON object to parse
  44874. * @param scene The scene to create the shadow map for
  44875. * @returns The parsed shadow generator
  44876. */
  44877. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  44878. }
  44879. }
  44880. declare module BABYLON {
  44881. /**
  44882. * Defines the shadow generator component responsible to manage any shadow generators
  44883. * in a given scene.
  44884. */
  44885. class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  44886. /**
  44887. * The component name helpfull to identify the component in the list of scene components.
  44888. */
  44889. readonly name: string;
  44890. /**
  44891. * The scene the component belongs to.
  44892. */
  44893. scene: Scene;
  44894. /**
  44895. * Creates a new instance of the component for the given scene
  44896. * @param scene Defines the scene to register the component in
  44897. */
  44898. constructor(scene: Scene);
  44899. /**
  44900. * Registers the component in a given scene
  44901. */
  44902. register(): void;
  44903. /**
  44904. * Rebuilds the elements related to this component in case of
  44905. * context lost for instance.
  44906. */
  44907. rebuild(): void;
  44908. /**
  44909. * Serializes the component data to the specified json object
  44910. * @param serializationObject The object to serialize to
  44911. */
  44912. serialize(serializationObject: any): void;
  44913. /**
  44914. * Adds all the element from the container to the scene
  44915. * @param container the container holding the elements
  44916. */
  44917. addFromContainer(container: AbstractScene): void;
  44918. /**
  44919. * Removes all the elements in the container from the scene
  44920. * @param container contains the elements to remove
  44921. */
  44922. removeFromContainer(container: AbstractScene): void;
  44923. /**
  44924. * Rebuilds the elements related to this component in case of
  44925. * context lost for instance.
  44926. */
  44927. dispose(): void;
  44928. private _gatherRenderTargets;
  44929. }
  44930. }
  44931. declare module BABYLON {
  44932. }
  44933. declare module BABYLON {
  44934. /**
  44935. * Background material used to create an efficient environement around your scene.
  44936. */
  44937. class BackgroundMaterial extends PushMaterial {
  44938. /**
  44939. * Standard reflectance value at parallel view angle.
  44940. */
  44941. static StandardReflectance0: number;
  44942. /**
  44943. * Standard reflectance value at grazing angle.
  44944. */
  44945. static StandardReflectance90: number;
  44946. protected _primaryColor: Color3;
  44947. /**
  44948. * Key light Color (multiply against the environement texture)
  44949. */
  44950. primaryColor: Color3;
  44951. protected __perceptualColor: Nullable<Color3>;
  44952. /**
  44953. * Experimental Internal Use Only.
  44954. *
  44955. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  44956. * This acts as a helper to set the primary color to a more "human friendly" value.
  44957. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  44958. * output color as close as possible from the chosen value.
  44959. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  44960. * part of lighting setup.)
  44961. */
  44962. _perceptualColor: Nullable<Color3>;
  44963. protected _primaryColorShadowLevel: float;
  44964. /**
  44965. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  44966. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  44967. */
  44968. primaryColorShadowLevel: float;
  44969. protected _primaryColorHighlightLevel: float;
  44970. /**
  44971. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  44972. * The primary color is used at the level chosen to define what the white area would look.
  44973. */
  44974. primaryColorHighlightLevel: float;
  44975. protected _reflectionTexture: Nullable<BaseTexture>;
  44976. /**
  44977. * Reflection Texture used in the material.
  44978. * Should be author in a specific way for the best result (refer to the documentation).
  44979. */
  44980. reflectionTexture: Nullable<BaseTexture>;
  44981. protected _reflectionBlur: float;
  44982. /**
  44983. * Reflection Texture level of blur.
  44984. *
  44985. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  44986. * texture twice.
  44987. */
  44988. reflectionBlur: float;
  44989. protected _diffuseTexture: Nullable<BaseTexture>;
  44990. /**
  44991. * Diffuse Texture used in the material.
  44992. * Should be author in a specific way for the best result (refer to the documentation).
  44993. */
  44994. diffuseTexture: Nullable<BaseTexture>;
  44995. protected _shadowLights: Nullable<IShadowLight[]>;
  44996. /**
  44997. * Specify the list of lights casting shadow on the material.
  44998. * All scene shadow lights will be included if null.
  44999. */
  45000. shadowLights: Nullable<IShadowLight[]>;
  45001. protected _shadowLevel: float;
  45002. /**
  45003. * Helps adjusting the shadow to a softer level if required.
  45004. * 0 means black shadows and 1 means no shadows.
  45005. */
  45006. shadowLevel: float;
  45007. protected _sceneCenter: Vector3;
  45008. /**
  45009. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  45010. * It is usually zero but might be interesting to modify according to your setup.
  45011. */
  45012. sceneCenter: Vector3;
  45013. protected _opacityFresnel: boolean;
  45014. /**
  45015. * This helps specifying that the material is falling off to the sky box at grazing angle.
  45016. * This helps ensuring a nice transition when the camera goes under the ground.
  45017. */
  45018. opacityFresnel: boolean;
  45019. protected _reflectionFresnel: boolean;
  45020. /**
  45021. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  45022. * This helps adding a mirror texture on the ground.
  45023. */
  45024. reflectionFresnel: boolean;
  45025. protected _reflectionFalloffDistance: number;
  45026. /**
  45027. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  45028. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  45029. */
  45030. reflectionFalloffDistance: number;
  45031. protected _reflectionAmount: number;
  45032. /**
  45033. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  45034. */
  45035. reflectionAmount: number;
  45036. protected _reflectionReflectance0: number;
  45037. /**
  45038. * This specifies the weight of the reflection at grazing angle.
  45039. */
  45040. reflectionReflectance0: number;
  45041. protected _reflectionReflectance90: number;
  45042. /**
  45043. * This specifies the weight of the reflection at a perpendicular point of view.
  45044. */
  45045. reflectionReflectance90: number;
  45046. /**
  45047. * Sets the reflection reflectance fresnel values according to the default standard
  45048. * empirically know to work well :-)
  45049. */
  45050. reflectionStandardFresnelWeight: number;
  45051. protected _useRGBColor: boolean;
  45052. /**
  45053. * Helps to directly use the maps channels instead of their level.
  45054. */
  45055. useRGBColor: boolean;
  45056. protected _enableNoise: boolean;
  45057. /**
  45058. * This helps reducing the banding effect that could occur on the background.
  45059. */
  45060. enableNoise: boolean;
  45061. /**
  45062. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45063. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  45064. * Recommended to be keep at 1.0 except for special cases.
  45065. */
  45066. fovMultiplier: number;
  45067. private _fovMultiplier;
  45068. /**
  45069. * Enable the FOV adjustment feature controlled by fovMultiplier.
  45070. */
  45071. useEquirectangularFOV: boolean;
  45072. private _maxSimultaneousLights;
  45073. /**
  45074. * Number of Simultaneous lights allowed on the material.
  45075. */
  45076. maxSimultaneousLights: int;
  45077. /**
  45078. * Default configuration related to image processing available in the Background Material.
  45079. */
  45080. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45081. /**
  45082. * Keep track of the image processing observer to allow dispose and replace.
  45083. */
  45084. private _imageProcessingObserver;
  45085. /**
  45086. * Attaches a new image processing configuration to the PBR Material.
  45087. * @param configuration (if null the scene configuration will be use)
  45088. */
  45089. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45090. /**
  45091. * Gets the image processing configuration used either in this material.
  45092. */
  45093. /**
  45094. * Sets the Default image processing configuration used either in the this material.
  45095. *
  45096. * If sets to null, the scene one is in use.
  45097. */
  45098. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  45099. /**
  45100. * Gets wether the color curves effect is enabled.
  45101. */
  45102. /**
  45103. * Sets wether the color curves effect is enabled.
  45104. */
  45105. cameraColorCurvesEnabled: boolean;
  45106. /**
  45107. * Gets wether the color grading effect is enabled.
  45108. */
  45109. /**
  45110. * Gets wether the color grading effect is enabled.
  45111. */
  45112. cameraColorGradingEnabled: boolean;
  45113. /**
  45114. * Gets wether tonemapping is enabled or not.
  45115. */
  45116. /**
  45117. * Sets wether tonemapping is enabled or not
  45118. */
  45119. cameraToneMappingEnabled: boolean;
  45120. /**
  45121. * The camera exposure used on this material.
  45122. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45123. * This corresponds to a photographic exposure.
  45124. */
  45125. /**
  45126. * The camera exposure used on this material.
  45127. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45128. * This corresponds to a photographic exposure.
  45129. */
  45130. cameraExposure: float;
  45131. /**
  45132. * Gets The camera contrast used on this material.
  45133. */
  45134. /**
  45135. * Sets The camera contrast used on this material.
  45136. */
  45137. cameraContrast: float;
  45138. /**
  45139. * Gets the Color Grading 2D Lookup Texture.
  45140. */
  45141. /**
  45142. * Sets the Color Grading 2D Lookup Texture.
  45143. */
  45144. cameraColorGradingTexture: Nullable<BaseTexture>;
  45145. /**
  45146. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45147. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45148. * 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;
  45149. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45150. */
  45151. /**
  45152. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45153. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45154. * 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;
  45155. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45156. */
  45157. cameraColorCurves: Nullable<ColorCurves>;
  45158. /**
  45159. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  45160. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  45161. */
  45162. switchToBGR: boolean;
  45163. private _renderTargets;
  45164. private _reflectionControls;
  45165. private _white;
  45166. private _primaryShadowColor;
  45167. private _primaryHighlightColor;
  45168. /**
  45169. * Instantiates a Background Material in the given scene
  45170. * @param name The friendly name of the material
  45171. * @param scene The scene to add the material to
  45172. */
  45173. constructor(name: string, scene: Scene);
  45174. /**
  45175. * Gets a boolean indicating that current material needs to register RTT
  45176. */
  45177. readonly hasRenderTargetTextures: boolean;
  45178. /**
  45179. * The entire material has been created in order to prevent overdraw.
  45180. * @returns false
  45181. */
  45182. needAlphaTesting(): boolean;
  45183. /**
  45184. * The entire material has been created in order to prevent overdraw.
  45185. * @returns true if blending is enable
  45186. */
  45187. needAlphaBlending(): boolean;
  45188. /**
  45189. * Checks wether the material is ready to be rendered for a given mesh.
  45190. * @param mesh The mesh to render
  45191. * @param subMesh The submesh to check against
  45192. * @param useInstances Specify wether or not the material is used with instances
  45193. * @returns true if all the dependencies are ready (Textures, Effects...)
  45194. */
  45195. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45196. /**
  45197. * Compute the primary color according to the chosen perceptual color.
  45198. */
  45199. private _computePrimaryColorFromPerceptualColor;
  45200. /**
  45201. * Compute the highlights and shadow colors according to their chosen levels.
  45202. */
  45203. private _computePrimaryColors;
  45204. /**
  45205. * Build the uniform buffer used in the material.
  45206. */
  45207. buildUniformLayout(): void;
  45208. /**
  45209. * Unbind the material.
  45210. */
  45211. unbind(): void;
  45212. /**
  45213. * Bind only the world matrix to the material.
  45214. * @param world The world matrix to bind.
  45215. */
  45216. bindOnlyWorldMatrix(world: Matrix): void;
  45217. /**
  45218. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  45219. * @param world The world matrix to bind.
  45220. * @param subMesh The submesh to bind for.
  45221. */
  45222. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45223. /**
  45224. * Dispose the material.
  45225. * @param forceDisposeEffect Force disposal of the associated effect.
  45226. * @param forceDisposeTextures Force disposal of the associated textures.
  45227. */
  45228. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45229. /**
  45230. * Clones the material.
  45231. * @param name The cloned name.
  45232. * @returns The cloned material.
  45233. */
  45234. clone(name: string): BackgroundMaterial;
  45235. /**
  45236. * Serializes the current material to its JSON representation.
  45237. * @returns The JSON representation.
  45238. */
  45239. serialize(): any;
  45240. /**
  45241. * Gets the class name of the material
  45242. * @returns "BackgroundMaterial"
  45243. */
  45244. getClassName(): string;
  45245. /**
  45246. * Parse a JSON input to create back a background material.
  45247. * @param source The JSON data to parse
  45248. * @param scene The scene to create the parsed material in
  45249. * @param rootUrl The root url of the assets the material depends upon
  45250. * @returns the instantiated BackgroundMaterial.
  45251. */
  45252. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  45253. }
  45254. }
  45255. declare module BABYLON {
  45256. /**
  45257. * The Physically based material base class of BJS.
  45258. *
  45259. * This offers the main features of a standard PBR material.
  45260. * For more information, please refer to the documentation :
  45261. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  45262. */
  45263. abstract class PBRBaseMaterial extends PushMaterial {
  45264. /**
  45265. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  45266. */
  45267. static readonly LIGHTFALLOFF_PHYSICAL: number;
  45268. /**
  45269. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  45270. * to enhance interoperability with other engines.
  45271. */
  45272. static readonly LIGHTFALLOFF_GLTF: number;
  45273. /**
  45274. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  45275. * to enhance interoperability with other materials.
  45276. */
  45277. static readonly LIGHTFALLOFF_STANDARD: number;
  45278. /**
  45279. * Intensity of the direct lights e.g. the four lights available in your scene.
  45280. * This impacts both the direct diffuse and specular highlights.
  45281. */
  45282. protected _directIntensity: number;
  45283. /**
  45284. * Intensity of the emissive part of the material.
  45285. * This helps controlling the emissive effect without modifying the emissive color.
  45286. */
  45287. protected _emissiveIntensity: number;
  45288. /**
  45289. * Intensity of the environment e.g. how much the environment will light the object
  45290. * either through harmonics for rough material or through the refelction for shiny ones.
  45291. */
  45292. protected _environmentIntensity: number;
  45293. /**
  45294. * This is a special control allowing the reduction of the specular highlights coming from the
  45295. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45296. */
  45297. protected _specularIntensity: number;
  45298. /**
  45299. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  45300. */
  45301. private _lightingInfos;
  45302. /**
  45303. * Debug Control allowing disabling the bump map on this material.
  45304. */
  45305. protected _disableBumpMap: boolean;
  45306. /**
  45307. * AKA Diffuse Texture in standard nomenclature.
  45308. */
  45309. protected _albedoTexture: BaseTexture;
  45310. /**
  45311. * AKA Occlusion Texture in other nomenclature.
  45312. */
  45313. protected _ambientTexture: BaseTexture;
  45314. /**
  45315. * AKA Occlusion Texture Intensity in other nomenclature.
  45316. */
  45317. protected _ambientTextureStrength: number;
  45318. /**
  45319. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45320. * 1 means it completely occludes it
  45321. * 0 mean it has no impact
  45322. */
  45323. protected _ambientTextureImpactOnAnalyticalLights: number;
  45324. /**
  45325. * Stores the alpha values in a texture.
  45326. */
  45327. protected _opacityTexture: BaseTexture;
  45328. /**
  45329. * Stores the reflection values in a texture.
  45330. */
  45331. protected _reflectionTexture: BaseTexture;
  45332. /**
  45333. * Stores the refraction values in a texture.
  45334. */
  45335. protected _refractionTexture: BaseTexture;
  45336. /**
  45337. * Stores the emissive values in a texture.
  45338. */
  45339. protected _emissiveTexture: BaseTexture;
  45340. /**
  45341. * AKA Specular texture in other nomenclature.
  45342. */
  45343. protected _reflectivityTexture: BaseTexture;
  45344. /**
  45345. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45346. */
  45347. protected _metallicTexture: BaseTexture;
  45348. /**
  45349. * Specifies the metallic scalar of the metallic/roughness workflow.
  45350. * Can also be used to scale the metalness values of the metallic texture.
  45351. */
  45352. protected _metallic: Nullable<number>;
  45353. /**
  45354. * Specifies the roughness scalar of the metallic/roughness workflow.
  45355. * Can also be used to scale the roughness values of the metallic texture.
  45356. */
  45357. protected _roughness: Nullable<number>;
  45358. /**
  45359. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45360. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45361. */
  45362. protected _microSurfaceTexture: BaseTexture;
  45363. /**
  45364. * Stores surface normal data used to displace a mesh in a texture.
  45365. */
  45366. protected _bumpTexture: BaseTexture;
  45367. /**
  45368. * Stores the pre-calculated light information of a mesh in a texture.
  45369. */
  45370. protected _lightmapTexture: BaseTexture;
  45371. /**
  45372. * The color of a material in ambient lighting.
  45373. */
  45374. protected _ambientColor: Color3;
  45375. /**
  45376. * AKA Diffuse Color in other nomenclature.
  45377. */
  45378. protected _albedoColor: Color3;
  45379. /**
  45380. * AKA Specular Color in other nomenclature.
  45381. */
  45382. protected _reflectivityColor: Color3;
  45383. /**
  45384. * The color applied when light is reflected from a material.
  45385. */
  45386. protected _reflectionColor: Color3;
  45387. /**
  45388. * The color applied when light is emitted from a material.
  45389. */
  45390. protected _emissiveColor: Color3;
  45391. /**
  45392. * AKA Glossiness in other nomenclature.
  45393. */
  45394. protected _microSurface: number;
  45395. /**
  45396. * source material index of refraction (IOR)' / 'destination material IOR.
  45397. */
  45398. protected _indexOfRefraction: number;
  45399. /**
  45400. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45401. */
  45402. protected _invertRefractionY: boolean;
  45403. /**
  45404. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45405. * Materials half opaque for instance using refraction could benefit from this control.
  45406. */
  45407. protected _linkRefractionWithTransparency: boolean;
  45408. /**
  45409. * Specifies that the material will use the light map as a show map.
  45410. */
  45411. protected _useLightmapAsShadowmap: boolean;
  45412. /**
  45413. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45414. * makes the reflect vector face the model (under horizon).
  45415. */
  45416. protected _useHorizonOcclusion: boolean;
  45417. /**
  45418. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45419. * too much the area relying on ambient texture to define their ambient occlusion.
  45420. */
  45421. protected _useRadianceOcclusion: boolean;
  45422. /**
  45423. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45424. */
  45425. protected _useAlphaFromAlbedoTexture: boolean;
  45426. /**
  45427. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  45428. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45429. */
  45430. protected _useSpecularOverAlpha: boolean;
  45431. /**
  45432. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45433. */
  45434. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45435. /**
  45436. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45437. */
  45438. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  45439. /**
  45440. * Specifies if the metallic texture contains the roughness information in its green channel.
  45441. */
  45442. protected _useRoughnessFromMetallicTextureGreen: boolean;
  45443. /**
  45444. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45445. */
  45446. protected _useMetallnessFromMetallicTextureBlue: boolean;
  45447. /**
  45448. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45449. */
  45450. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  45451. /**
  45452. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45453. */
  45454. protected _useAmbientInGrayScale: boolean;
  45455. /**
  45456. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45457. * The material will try to infer what glossiness each pixel should be.
  45458. */
  45459. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  45460. /**
  45461. * Defines the falloff type used in this material.
  45462. * It by default is Physical.
  45463. */
  45464. protected _lightFalloff: number;
  45465. /**
  45466. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45467. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45468. */
  45469. protected _useRadianceOverAlpha: boolean;
  45470. /**
  45471. * Allows using an object space normal map (instead of tangent space).
  45472. */
  45473. protected _useObjectSpaceNormalMap: boolean;
  45474. /**
  45475. * Allows using the bump map in parallax mode.
  45476. */
  45477. protected _useParallax: boolean;
  45478. /**
  45479. * Allows using the bump map in parallax occlusion mode.
  45480. */
  45481. protected _useParallaxOcclusion: boolean;
  45482. /**
  45483. * Controls the scale bias of the parallax mode.
  45484. */
  45485. protected _parallaxScaleBias: number;
  45486. /**
  45487. * If sets to true, disables all the lights affecting the material.
  45488. */
  45489. protected _disableLighting: boolean;
  45490. /**
  45491. * Number of Simultaneous lights allowed on the material.
  45492. */
  45493. protected _maxSimultaneousLights: number;
  45494. /**
  45495. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45496. */
  45497. protected _invertNormalMapX: boolean;
  45498. /**
  45499. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45500. */
  45501. protected _invertNormalMapY: boolean;
  45502. /**
  45503. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45504. */
  45505. protected _twoSidedLighting: boolean;
  45506. /**
  45507. * Defines the alpha limits in alpha test mode.
  45508. */
  45509. protected _alphaCutOff: number;
  45510. /**
  45511. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45512. */
  45513. protected _forceAlphaTest: boolean;
  45514. /**
  45515. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45516. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45517. */
  45518. protected _useAlphaFresnel: boolean;
  45519. /**
  45520. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45521. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45522. */
  45523. protected _useLinearAlphaFresnel: boolean;
  45524. /**
  45525. * The transparency mode of the material.
  45526. */
  45527. protected _transparencyMode: Nullable<number>;
  45528. /**
  45529. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  45530. * from cos thetav and roughness:
  45531. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  45532. */
  45533. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  45534. /**
  45535. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45536. */
  45537. protected _forceIrradianceInFragment: boolean;
  45538. /**
  45539. * Force normal to face away from face.
  45540. */
  45541. protected _forceNormalForward: boolean;
  45542. /**
  45543. * Enables specular anti aliasing in the PBR shader.
  45544. * It will both interacts on the Geometry for analytical and IBL lighting.
  45545. * It also prefilter the roughness map based on the bump values.
  45546. */
  45547. protected _enableSpecularAntiAliasing: boolean;
  45548. /**
  45549. * Default configuration related to image processing available in the PBR Material.
  45550. */
  45551. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45552. /**
  45553. * Keep track of the image processing observer to allow dispose and replace.
  45554. */
  45555. private _imageProcessingObserver;
  45556. /**
  45557. * Attaches a new image processing configuration to the PBR Material.
  45558. * @param configuration
  45559. */
  45560. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45561. /**
  45562. * Stores the available render targets.
  45563. */
  45564. private _renderTargets;
  45565. /**
  45566. * Sets the global ambient color for the material used in lighting calculations.
  45567. */
  45568. private _globalAmbientColor;
  45569. /**
  45570. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  45571. */
  45572. private _useLogarithmicDepth;
  45573. /**
  45574. * If set to true, no lighting calculations will be applied.
  45575. */
  45576. private _unlit;
  45577. /**
  45578. * Instantiates a new PBRMaterial instance.
  45579. *
  45580. * @param name The material name
  45581. * @param scene The scene the material will be use in.
  45582. */
  45583. constructor(name: string, scene: Scene);
  45584. /**
  45585. * Gets a boolean indicating that current material needs to register RTT
  45586. */
  45587. readonly hasRenderTargetTextures: boolean;
  45588. /**
  45589. * Gets the name of the material class.
  45590. */
  45591. getClassName(): string;
  45592. /**
  45593. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45594. */
  45595. /**
  45596. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45597. */
  45598. useLogarithmicDepth: boolean;
  45599. /**
  45600. * Gets the current transparency mode.
  45601. */
  45602. /**
  45603. * Sets the transparency mode of the material.
  45604. *
  45605. * | Value | Type | Description |
  45606. * | ----- | ----------------------------------- | ----------- |
  45607. * | 0 | OPAQUE | |
  45608. * | 1 | ALPHATEST | |
  45609. * | 2 | ALPHABLEND | |
  45610. * | 3 | ALPHATESTANDBLEND | |
  45611. *
  45612. */
  45613. transparencyMode: Nullable<number>;
  45614. /**
  45615. * Returns true if alpha blending should be disabled.
  45616. */
  45617. private readonly _disableAlphaBlending;
  45618. /**
  45619. * Specifies whether or not this material should be rendered in alpha blend mode.
  45620. */
  45621. needAlphaBlending(): boolean;
  45622. /**
  45623. * Specifies if the mesh will require alpha blending.
  45624. * @param mesh - BJS mesh.
  45625. */
  45626. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  45627. /**
  45628. * Specifies whether or not this material should be rendered in alpha test mode.
  45629. */
  45630. needAlphaTesting(): boolean;
  45631. /**
  45632. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  45633. */
  45634. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  45635. /**
  45636. * Gets the texture used for the alpha test.
  45637. */
  45638. getAlphaTestTexture(): BaseTexture;
  45639. /**
  45640. * Stores the reflectivity values based on metallic roughness workflow.
  45641. */
  45642. private static _scaledReflectivity;
  45643. /**
  45644. * Specifies that the submesh is ready to be used.
  45645. * @param mesh - BJS mesh.
  45646. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  45647. * @param useInstances - Specifies that instances should be used.
  45648. * @returns - boolean indicating that the submesh is ready or not.
  45649. */
  45650. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45651. /**
  45652. * Specifies if the material uses metallic roughness workflow.
  45653. * @returns boolean specifiying if the material uses metallic roughness workflow.
  45654. */
  45655. isMetallicWorkflow(): boolean;
  45656. private _prepareEffect;
  45657. private _prepareDefines;
  45658. /**
  45659. * Force shader compilation
  45660. */
  45661. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  45662. clipPlane: boolean;
  45663. }>): void;
  45664. /**
  45665. * Initializes the uniform buffer layout for the shader.
  45666. */
  45667. buildUniformLayout(): void;
  45668. /**
  45669. * Unbinds the textures.
  45670. */
  45671. unbind(): void;
  45672. /**
  45673. * Binds the submesh data.
  45674. * @param world - The world matrix.
  45675. * @param mesh - The BJS mesh.
  45676. * @param subMesh - A submesh of the BJS mesh.
  45677. */
  45678. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45679. /**
  45680. * Returns the animatable textures.
  45681. * @returns - Array of animatable textures.
  45682. */
  45683. getAnimatables(): IAnimatable[];
  45684. /**
  45685. * Returns the texture used for reflections.
  45686. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  45687. */
  45688. private _getReflectionTexture;
  45689. /**
  45690. * Returns the texture used for refraction or null if none is used.
  45691. * @returns - Refection texture if present. If no refraction texture and refraction
  45692. * is linked with transparency, returns environment texture. Otherwise, returns null.
  45693. */
  45694. private _getRefractionTexture;
  45695. /**
  45696. * Disposes the resources of the material.
  45697. * @param forceDisposeEffect - Forces the disposal of effects.
  45698. * @param forceDisposeTextures - Forces the disposal of all textures.
  45699. */
  45700. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45701. }
  45702. }
  45703. declare module BABYLON {
  45704. /**
  45705. * The Physically based simple base material of BJS.
  45706. *
  45707. * This enables better naming and convention enforcements on top of the pbrMaterial.
  45708. * It is used as the base class for both the specGloss and metalRough conventions.
  45709. */
  45710. abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  45711. /**
  45712. * Number of Simultaneous lights allowed on the material.
  45713. */
  45714. maxSimultaneousLights: number;
  45715. /**
  45716. * If sets to true, disables all the lights affecting the material.
  45717. */
  45718. disableLighting: boolean;
  45719. /**
  45720. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  45721. */
  45722. environmentTexture: BaseTexture;
  45723. /**
  45724. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  45725. */
  45726. invertNormalMapX: boolean;
  45727. /**
  45728. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  45729. */
  45730. invertNormalMapY: boolean;
  45731. /**
  45732. * Normal map used in the model.
  45733. */
  45734. normalTexture: BaseTexture;
  45735. /**
  45736. * Emissivie color used to self-illuminate the model.
  45737. */
  45738. emissiveColor: Color3;
  45739. /**
  45740. * Emissivie texture used to self-illuminate the model.
  45741. */
  45742. emissiveTexture: BaseTexture;
  45743. /**
  45744. * Occlusion Channel Strenght.
  45745. */
  45746. occlusionStrength: number;
  45747. /**
  45748. * Occlusion Texture of the material (adding extra occlusion effects).
  45749. */
  45750. occlusionTexture: BaseTexture;
  45751. /**
  45752. * Defines the alpha limits in alpha test mode.
  45753. */
  45754. alphaCutOff: number;
  45755. /**
  45756. * Gets the current double sided mode.
  45757. */
  45758. /**
  45759. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45760. */
  45761. doubleSided: boolean;
  45762. /**
  45763. * Stores the pre-calculated light information of a mesh in a texture.
  45764. */
  45765. lightmapTexture: BaseTexture;
  45766. /**
  45767. * If true, the light map contains occlusion information instead of lighting info.
  45768. */
  45769. useLightmapAsShadowmap: boolean;
  45770. /**
  45771. * Return the active textures of the material.
  45772. */
  45773. getActiveTextures(): BaseTexture[];
  45774. hasTexture(texture: BaseTexture): boolean;
  45775. /**
  45776. * Instantiates a new PBRMaterial instance.
  45777. *
  45778. * @param name The material name
  45779. * @param scene The scene the material will be use in.
  45780. */
  45781. constructor(name: string, scene: Scene);
  45782. getClassName(): string;
  45783. }
  45784. }
  45785. declare module BABYLON {
  45786. /**
  45787. * The Physically based material of BJS.
  45788. *
  45789. * This offers the main features of a standard PBR material.
  45790. * For more information, please refer to the documentation :
  45791. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  45792. */
  45793. class PBRMaterial extends PBRBaseMaterial {
  45794. /**
  45795. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  45796. */
  45797. static readonly PBRMATERIAL_OPAQUE: number;
  45798. /**
  45799. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  45800. */
  45801. static readonly PBRMATERIAL_ALPHATEST: number;
  45802. /**
  45803. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45804. */
  45805. static readonly PBRMATERIAL_ALPHABLEND: number;
  45806. /**
  45807. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45808. * They are also discarded below the alpha cutoff threshold to improve performances.
  45809. */
  45810. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  45811. /**
  45812. * Defines the default value of how much AO map is occluding the analytical lights
  45813. * (point spot...).
  45814. */
  45815. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  45816. /**
  45817. * Intensity of the direct lights e.g. the four lights available in your scene.
  45818. * This impacts both the direct diffuse and specular highlights.
  45819. */
  45820. directIntensity: number;
  45821. /**
  45822. * Intensity of the emissive part of the material.
  45823. * This helps controlling the emissive effect without modifying the emissive color.
  45824. */
  45825. emissiveIntensity: number;
  45826. /**
  45827. * Intensity of the environment e.g. how much the environment will light the object
  45828. * either through harmonics for rough material or through the refelction for shiny ones.
  45829. */
  45830. environmentIntensity: number;
  45831. /**
  45832. * This is a special control allowing the reduction of the specular highlights coming from the
  45833. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45834. */
  45835. specularIntensity: number;
  45836. /**
  45837. * Debug Control allowing disabling the bump map on this material.
  45838. */
  45839. disableBumpMap: boolean;
  45840. /**
  45841. * AKA Diffuse Texture in standard nomenclature.
  45842. */
  45843. albedoTexture: BaseTexture;
  45844. /**
  45845. * AKA Occlusion Texture in other nomenclature.
  45846. */
  45847. ambientTexture: BaseTexture;
  45848. /**
  45849. * AKA Occlusion Texture Intensity in other nomenclature.
  45850. */
  45851. ambientTextureStrength: number;
  45852. /**
  45853. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45854. * 1 means it completely occludes it
  45855. * 0 mean it has no impact
  45856. */
  45857. ambientTextureImpactOnAnalyticalLights: number;
  45858. /**
  45859. * Stores the alpha values in a texture.
  45860. */
  45861. opacityTexture: BaseTexture;
  45862. /**
  45863. * Stores the reflection values in a texture.
  45864. */
  45865. reflectionTexture: Nullable<BaseTexture>;
  45866. /**
  45867. * Stores the emissive values in a texture.
  45868. */
  45869. emissiveTexture: BaseTexture;
  45870. /**
  45871. * AKA Specular texture in other nomenclature.
  45872. */
  45873. reflectivityTexture: BaseTexture;
  45874. /**
  45875. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45876. */
  45877. metallicTexture: BaseTexture;
  45878. /**
  45879. * Specifies the metallic scalar of the metallic/roughness workflow.
  45880. * Can also be used to scale the metalness values of the metallic texture.
  45881. */
  45882. metallic: Nullable<number>;
  45883. /**
  45884. * Specifies the roughness scalar of the metallic/roughness workflow.
  45885. * Can also be used to scale the roughness values of the metallic texture.
  45886. */
  45887. roughness: Nullable<number>;
  45888. /**
  45889. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45890. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45891. */
  45892. microSurfaceTexture: BaseTexture;
  45893. /**
  45894. * Stores surface normal data used to displace a mesh in a texture.
  45895. */
  45896. bumpTexture: BaseTexture;
  45897. /**
  45898. * Stores the pre-calculated light information of a mesh in a texture.
  45899. */
  45900. lightmapTexture: BaseTexture;
  45901. /**
  45902. * Stores the refracted light information in a texture.
  45903. */
  45904. refractionTexture: BaseTexture;
  45905. /**
  45906. * The color of a material in ambient lighting.
  45907. */
  45908. ambientColor: Color3;
  45909. /**
  45910. * AKA Diffuse Color in other nomenclature.
  45911. */
  45912. albedoColor: Color3;
  45913. /**
  45914. * AKA Specular Color in other nomenclature.
  45915. */
  45916. reflectivityColor: Color3;
  45917. /**
  45918. * The color reflected from the material.
  45919. */
  45920. reflectionColor: Color3;
  45921. /**
  45922. * The color emitted from the material.
  45923. */
  45924. emissiveColor: Color3;
  45925. /**
  45926. * AKA Glossiness in other nomenclature.
  45927. */
  45928. microSurface: number;
  45929. /**
  45930. * source material index of refraction (IOR)' / 'destination material IOR.
  45931. */
  45932. indexOfRefraction: number;
  45933. /**
  45934. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45935. */
  45936. invertRefractionY: boolean;
  45937. /**
  45938. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45939. * Materials half opaque for instance using refraction could benefit from this control.
  45940. */
  45941. linkRefractionWithTransparency: boolean;
  45942. /**
  45943. * If true, the light map contains occlusion information instead of lighting info.
  45944. */
  45945. useLightmapAsShadowmap: boolean;
  45946. /**
  45947. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45948. */
  45949. useAlphaFromAlbedoTexture: boolean;
  45950. /**
  45951. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45952. */
  45953. forceAlphaTest: boolean;
  45954. /**
  45955. * Defines the alpha limits in alpha test mode.
  45956. */
  45957. alphaCutOff: number;
  45958. /**
  45959. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  45960. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45961. */
  45962. useSpecularOverAlpha: boolean;
  45963. /**
  45964. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45965. */
  45966. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45967. /**
  45968. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45969. */
  45970. useRoughnessFromMetallicTextureAlpha: boolean;
  45971. /**
  45972. * Specifies if the metallic texture contains the roughness information in its green channel.
  45973. */
  45974. useRoughnessFromMetallicTextureGreen: boolean;
  45975. /**
  45976. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45977. */
  45978. useMetallnessFromMetallicTextureBlue: boolean;
  45979. /**
  45980. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45981. */
  45982. useAmbientOcclusionFromMetallicTextureRed: boolean;
  45983. /**
  45984. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45985. */
  45986. useAmbientInGrayScale: boolean;
  45987. /**
  45988. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45989. * The material will try to infer what glossiness each pixel should be.
  45990. */
  45991. useAutoMicroSurfaceFromReflectivityMap: boolean;
  45992. /**
  45993. * BJS is using an harcoded light falloff based on a manually sets up range.
  45994. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45995. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45996. */
  45997. /**
  45998. * BJS is using an harcoded light falloff based on a manually sets up range.
  45999. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  46000. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  46001. */
  46002. usePhysicalLightFalloff: boolean;
  46003. /**
  46004. * In order to support the falloff compatibility with gltf, a special mode has been added
  46005. * to reproduce the gltf light falloff.
  46006. */
  46007. /**
  46008. * In order to support the falloff compatibility with gltf, a special mode has been added
  46009. * to reproduce the gltf light falloff.
  46010. */
  46011. useGLTFLightFalloff: boolean;
  46012. /**
  46013. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  46014. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  46015. */
  46016. useRadianceOverAlpha: boolean;
  46017. /**
  46018. * Allows using an object space normal map (instead of tangent space).
  46019. */
  46020. useObjectSpaceNormalMap: boolean;
  46021. /**
  46022. * Allows using the bump map in parallax mode.
  46023. */
  46024. useParallax: boolean;
  46025. /**
  46026. * Allows using the bump map in parallax occlusion mode.
  46027. */
  46028. useParallaxOcclusion: boolean;
  46029. /**
  46030. * Controls the scale bias of the parallax mode.
  46031. */
  46032. parallaxScaleBias: number;
  46033. /**
  46034. * If sets to true, disables all the lights affecting the material.
  46035. */
  46036. disableLighting: boolean;
  46037. /**
  46038. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  46039. */
  46040. forceIrradianceInFragment: boolean;
  46041. /**
  46042. * Number of Simultaneous lights allowed on the material.
  46043. */
  46044. maxSimultaneousLights: number;
  46045. /**
  46046. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  46047. */
  46048. invertNormalMapX: boolean;
  46049. /**
  46050. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  46051. */
  46052. invertNormalMapY: boolean;
  46053. /**
  46054. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  46055. */
  46056. twoSidedLighting: boolean;
  46057. /**
  46058. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46059. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  46060. */
  46061. useAlphaFresnel: boolean;
  46062. /**
  46063. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46064. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  46065. */
  46066. useLinearAlphaFresnel: boolean;
  46067. /**
  46068. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46069. * And/Or occlude the blended part.
  46070. */
  46071. environmentBRDFTexture: Nullable<BaseTexture>;
  46072. /**
  46073. * Force normal to face away from face.
  46074. */
  46075. forceNormalForward: boolean;
  46076. /**
  46077. * Enables specular anti aliasing in the PBR shader.
  46078. * It will both interacts on the Geometry for analytical and IBL lighting.
  46079. * It also prefilter the roughness map based on the bump values.
  46080. */
  46081. enableSpecularAntiAliasing: boolean;
  46082. /**
  46083. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  46084. * makes the reflect vector face the model (under horizon).
  46085. */
  46086. useHorizonOcclusion: boolean;
  46087. /**
  46088. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  46089. * too much the area relying on ambient texture to define their ambient occlusion.
  46090. */
  46091. useRadianceOcclusion: boolean;
  46092. /**
  46093. * If set to true, no lighting calculations will be applied.
  46094. */
  46095. unlit: boolean;
  46096. /**
  46097. * Gets the image processing configuration used either in this material.
  46098. */
  46099. /**
  46100. * Sets the Default image processing configuration used either in the this material.
  46101. *
  46102. * If sets to null, the scene one is in use.
  46103. */
  46104. imageProcessingConfiguration: ImageProcessingConfiguration;
  46105. /**
  46106. * Gets wether the color curves effect is enabled.
  46107. */
  46108. /**
  46109. * Sets wether the color curves effect is enabled.
  46110. */
  46111. cameraColorCurvesEnabled: boolean;
  46112. /**
  46113. * Gets wether the color grading effect is enabled.
  46114. */
  46115. /**
  46116. * Gets wether the color grading effect is enabled.
  46117. */
  46118. cameraColorGradingEnabled: boolean;
  46119. /**
  46120. * Gets wether tonemapping is enabled or not.
  46121. */
  46122. /**
  46123. * Sets wether tonemapping is enabled or not
  46124. */
  46125. cameraToneMappingEnabled: boolean;
  46126. /**
  46127. * The camera exposure used on this material.
  46128. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46129. * This corresponds to a photographic exposure.
  46130. */
  46131. /**
  46132. * The camera exposure used on this material.
  46133. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46134. * This corresponds to a photographic exposure.
  46135. */
  46136. cameraExposure: number;
  46137. /**
  46138. * Gets The camera contrast used on this material.
  46139. */
  46140. /**
  46141. * Sets The camera contrast used on this material.
  46142. */
  46143. cameraContrast: number;
  46144. /**
  46145. * Gets the Color Grading 2D Lookup Texture.
  46146. */
  46147. /**
  46148. * Sets the Color Grading 2D Lookup Texture.
  46149. */
  46150. cameraColorGradingTexture: Nullable<BaseTexture>;
  46151. /**
  46152. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46153. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46154. * 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;
  46155. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46156. */
  46157. /**
  46158. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46159. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46160. * 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;
  46161. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46162. */
  46163. cameraColorCurves: Nullable<ColorCurves>;
  46164. /**
  46165. * Instantiates a new PBRMaterial instance.
  46166. *
  46167. * @param name The material name
  46168. * @param scene The scene the material will be use in.
  46169. */
  46170. constructor(name: string, scene: Scene);
  46171. /**
  46172. * Returns the name of this material class.
  46173. */
  46174. getClassName(): string;
  46175. /**
  46176. * Returns an array of the actively used textures.
  46177. * @returns - Array of BaseTextures
  46178. */
  46179. getActiveTextures(): BaseTexture[];
  46180. /**
  46181. * Checks to see if a texture is used in the material.
  46182. * @param texture - Base texture to use.
  46183. * @returns - Boolean specifying if a texture is used in the material.
  46184. */
  46185. hasTexture(texture: BaseTexture): boolean;
  46186. /**
  46187. * Makes a duplicate of the current material.
  46188. * @param name - name to use for the new material.
  46189. */
  46190. clone(name: string): PBRMaterial;
  46191. /**
  46192. * Serializes this PBR Material.
  46193. * @returns - An object with the serialized material.
  46194. */
  46195. serialize(): any;
  46196. /**
  46197. * Parses a PBR Material from a serialized object.
  46198. * @param source - Serialized object.
  46199. * @param scene - BJS scene instance.
  46200. * @param rootUrl - url for the scene object
  46201. * @returns - PBRMaterial
  46202. */
  46203. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  46204. }
  46205. }
  46206. declare module BABYLON {
  46207. /**
  46208. * The PBR material of BJS following the metal roughness convention.
  46209. *
  46210. * This fits to the PBR convention in the GLTF definition:
  46211. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  46212. */
  46213. class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  46214. /**
  46215. * The base color has two different interpretations depending on the value of metalness.
  46216. * When the material is a metal, the base color is the specific measured reflectance value
  46217. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  46218. * of the material.
  46219. */
  46220. baseColor: Color3;
  46221. /**
  46222. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  46223. * well as opacity information in the alpha channel.
  46224. */
  46225. baseTexture: BaseTexture;
  46226. /**
  46227. * Specifies the metallic scalar value of the material.
  46228. * Can also be used to scale the metalness values of the metallic texture.
  46229. */
  46230. metallic: number;
  46231. /**
  46232. * Specifies the roughness scalar value of the material.
  46233. * Can also be used to scale the roughness values of the metallic texture.
  46234. */
  46235. roughness: number;
  46236. /**
  46237. * Texture containing both the metallic value in the B channel and the
  46238. * roughness value in the G channel to keep better precision.
  46239. */
  46240. metallicRoughnessTexture: BaseTexture;
  46241. /**
  46242. * Instantiates a new PBRMetalRoughnessMaterial instance.
  46243. *
  46244. * @param name The material name
  46245. * @param scene The scene the material will be use in.
  46246. */
  46247. constructor(name: string, scene: Scene);
  46248. /**
  46249. * Return the currrent class name of the material.
  46250. */
  46251. getClassName(): string;
  46252. /**
  46253. * Return the active textures of the material.
  46254. */
  46255. getActiveTextures(): BaseTexture[];
  46256. /**
  46257. * Checks to see if a texture is used in the material.
  46258. * @param texture - Base texture to use.
  46259. * @returns - Boolean specifying if a texture is used in the material.
  46260. */
  46261. hasTexture(texture: BaseTexture): boolean;
  46262. /**
  46263. * Makes a duplicate of the current material.
  46264. * @param name - name to use for the new material.
  46265. */
  46266. clone(name: string): PBRMetallicRoughnessMaterial;
  46267. /**
  46268. * Serialize the material to a parsable JSON object.
  46269. */
  46270. serialize(): any;
  46271. /**
  46272. * Parses a JSON object correponding to the serialize function.
  46273. */
  46274. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  46275. }
  46276. }
  46277. declare module BABYLON {
  46278. /**
  46279. * The PBR material of BJS following the specular glossiness convention.
  46280. *
  46281. * This fits to the PBR convention in the GLTF definition:
  46282. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  46283. */
  46284. class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  46285. /**
  46286. * Specifies the diffuse color of the material.
  46287. */
  46288. diffuseColor: Color3;
  46289. /**
  46290. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  46291. * channel.
  46292. */
  46293. diffuseTexture: BaseTexture;
  46294. /**
  46295. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  46296. */
  46297. specularColor: Color3;
  46298. /**
  46299. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  46300. */
  46301. glossiness: number;
  46302. /**
  46303. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  46304. */
  46305. specularGlossinessTexture: BaseTexture;
  46306. /**
  46307. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  46308. *
  46309. * @param name The material name
  46310. * @param scene The scene the material will be use in.
  46311. */
  46312. constructor(name: string, scene: Scene);
  46313. /**
  46314. * Return the currrent class name of the material.
  46315. */
  46316. getClassName(): string;
  46317. /**
  46318. * Return the active textures of the material.
  46319. */
  46320. getActiveTextures(): BaseTexture[];
  46321. /**
  46322. * Checks to see if a texture is used in the material.
  46323. * @param texture - Base texture to use.
  46324. * @returns - Boolean specifying if a texture is used in the material.
  46325. */
  46326. hasTexture(texture: BaseTexture): boolean;
  46327. /**
  46328. * Makes a duplicate of the current material.
  46329. * @param name - name to use for the new material.
  46330. */
  46331. clone(name: string): PBRSpecularGlossinessMaterial;
  46332. /**
  46333. * Serialize the material to a parsable JSON object.
  46334. */
  46335. serialize(): any;
  46336. /**
  46337. * Parses a JSON object correponding to the serialize function.
  46338. */
  46339. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  46340. }
  46341. }
  46342. declare module BABYLON {
  46343. /**
  46344. * Base class of all the textures in babylon.
  46345. * It groups all the common properties the materials, post process, lights... might need
  46346. * in order to make a correct use of the texture.
  46347. */
  46348. class BaseTexture {
  46349. /**
  46350. * Default anisotropic filtering level for the application.
  46351. * It is set to 4 as a good tradeoff between perf and quality.
  46352. */
  46353. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  46354. /**
  46355. * Gets or sets the unique id of the texture
  46356. */
  46357. uniqueId: number;
  46358. /**
  46359. * Define the name of the texture.
  46360. */
  46361. name: string;
  46362. /**
  46363. * Gets or sets an object used to store user defined information.
  46364. */
  46365. metadata: any;
  46366. /**
  46367. * For internal use only. Please do not use.
  46368. */
  46369. reservedDataStore: any;
  46370. private _hasAlpha;
  46371. /**
  46372. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  46373. */
  46374. hasAlpha: boolean;
  46375. /**
  46376. * Defines if the alpha value should be determined via the rgb values.
  46377. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  46378. */
  46379. getAlphaFromRGB: boolean;
  46380. /**
  46381. * Intensity or strength of the texture.
  46382. * It is commonly used by materials to fine tune the intensity of the texture
  46383. */
  46384. level: number;
  46385. /**
  46386. * Define the UV chanel to use starting from 0 and defaulting to 0.
  46387. * This is part of the texture as textures usually maps to one uv set.
  46388. */
  46389. coordinatesIndex: number;
  46390. private _coordinatesMode;
  46391. /**
  46392. * How a texture is mapped.
  46393. *
  46394. * | Value | Type | Description |
  46395. * | ----- | ----------------------------------- | ----------- |
  46396. * | 0 | EXPLICIT_MODE | |
  46397. * | 1 | SPHERICAL_MODE | |
  46398. * | 2 | PLANAR_MODE | |
  46399. * | 3 | CUBIC_MODE | |
  46400. * | 4 | PROJECTION_MODE | |
  46401. * | 5 | SKYBOX_MODE | |
  46402. * | 6 | INVCUBIC_MODE | |
  46403. * | 7 | EQUIRECTANGULAR_MODE | |
  46404. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  46405. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  46406. */
  46407. coordinatesMode: number;
  46408. /**
  46409. * | Value | Type | Description |
  46410. * | ----- | ------------------ | ----------- |
  46411. * | 0 | CLAMP_ADDRESSMODE | |
  46412. * | 1 | WRAP_ADDRESSMODE | |
  46413. * | 2 | MIRROR_ADDRESSMODE | |
  46414. */
  46415. wrapU: number;
  46416. /**
  46417. * | Value | Type | Description |
  46418. * | ----- | ------------------ | ----------- |
  46419. * | 0 | CLAMP_ADDRESSMODE | |
  46420. * | 1 | WRAP_ADDRESSMODE | |
  46421. * | 2 | MIRROR_ADDRESSMODE | |
  46422. */
  46423. wrapV: number;
  46424. /**
  46425. * | Value | Type | Description |
  46426. * | ----- | ------------------ | ----------- |
  46427. * | 0 | CLAMP_ADDRESSMODE | |
  46428. * | 1 | WRAP_ADDRESSMODE | |
  46429. * | 2 | MIRROR_ADDRESSMODE | |
  46430. */
  46431. wrapR: number;
  46432. /**
  46433. * With compliant hardware and browser (supporting anisotropic filtering)
  46434. * this defines the level of anisotropic filtering in the texture.
  46435. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  46436. */
  46437. anisotropicFilteringLevel: number;
  46438. /**
  46439. * Define if the texture is a cube texture or if false a 2d texture.
  46440. */
  46441. isCube: boolean;
  46442. /**
  46443. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  46444. */
  46445. is3D: boolean;
  46446. /**
  46447. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  46448. * HDR texture are usually stored in linear space.
  46449. * This only impacts the PBR and Background materials
  46450. */
  46451. gammaSpace: boolean;
  46452. /**
  46453. * Gets whether or not the texture contains RGBD data.
  46454. */
  46455. readonly isRGBD: boolean;
  46456. /**
  46457. * Is Z inverted in the texture (useful in a cube texture).
  46458. */
  46459. invertZ: boolean;
  46460. /**
  46461. * Are mip maps generated for this texture or not.
  46462. */
  46463. readonly noMipmap: boolean;
  46464. /**
  46465. * @hidden
  46466. */
  46467. lodLevelInAlpha: boolean;
  46468. /**
  46469. * With prefiltered texture, defined the offset used during the prefiltering steps.
  46470. */
  46471. lodGenerationOffset: number;
  46472. /**
  46473. * With prefiltered texture, defined the scale used during the prefiltering steps.
  46474. */
  46475. lodGenerationScale: number;
  46476. /**
  46477. * Define if the texture is a render target.
  46478. */
  46479. isRenderTarget: boolean;
  46480. /**
  46481. * Define the unique id of the texture in the scene.
  46482. */
  46483. readonly uid: string;
  46484. /**
  46485. * Return a string representation of the texture.
  46486. * @returns the texture as a string
  46487. */
  46488. toString(): string;
  46489. /**
  46490. * Get the class name of the texture.
  46491. * @returns "BaseTexture"
  46492. */
  46493. getClassName(): string;
  46494. /**
  46495. * Define the list of animation attached to the texture.
  46496. */
  46497. animations: Animation[];
  46498. /**
  46499. * An event triggered when the texture is disposed.
  46500. */
  46501. onDisposeObservable: Observable<BaseTexture>;
  46502. private _onDisposeObserver;
  46503. /**
  46504. * Callback triggered when the texture has been disposed.
  46505. * Kept for back compatibility, you can use the onDisposeObservable instead.
  46506. */
  46507. onDispose: () => void;
  46508. /**
  46509. * Define the current state of the loading sequence when in delayed load mode.
  46510. */
  46511. delayLoadState: number;
  46512. private _scene;
  46513. /** @hidden */
  46514. _samplingMode: number;
  46515. /** @hidden */
  46516. _texture: Nullable<InternalTexture>;
  46517. private _uid;
  46518. /**
  46519. * Define if the texture is preventinga material to render or not.
  46520. * If not and the texture is not ready, the engine will use a default black texture instead.
  46521. */
  46522. readonly isBlocking: boolean;
  46523. /**
  46524. * Instantiates a new BaseTexture.
  46525. * Base class of all the textures in babylon.
  46526. * It groups all the common properties the materials, post process, lights... might need
  46527. * in order to make a correct use of the texture.
  46528. * @param scene Define the scene the texture blongs to
  46529. */
  46530. constructor(scene: Nullable<Scene>);
  46531. /**
  46532. * Get the scene the texture belongs to.
  46533. * @returns the scene or null if undefined
  46534. */
  46535. getScene(): Nullable<Scene>;
  46536. /**
  46537. * Get the texture transform matrix used to offset tile the texture for istance.
  46538. * @returns the transformation matrix
  46539. */
  46540. getTextureMatrix(): Matrix;
  46541. /**
  46542. * Get the texture reflection matrix used to rotate/transform the reflection.
  46543. * @returns the reflection matrix
  46544. */
  46545. getReflectionTextureMatrix(): Matrix;
  46546. /**
  46547. * Get the underlying lower level texture from Babylon.
  46548. * @returns the insternal texture
  46549. */
  46550. getInternalTexture(): Nullable<InternalTexture>;
  46551. /**
  46552. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  46553. * @returns true if ready or not blocking
  46554. */
  46555. isReadyOrNotBlocking(): boolean;
  46556. /**
  46557. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  46558. * @returns true if fully ready
  46559. */
  46560. isReady(): boolean;
  46561. private _cachedSize;
  46562. /**
  46563. * Get the size of the texture.
  46564. * @returns the texture size.
  46565. */
  46566. getSize(): ISize;
  46567. /**
  46568. * Get the base size of the texture.
  46569. * It can be different from the size if the texture has been resized for POT for instance
  46570. * @returns the base size
  46571. */
  46572. getBaseSize(): ISize;
  46573. /**
  46574. * Update the sampling mode of the texture.
  46575. * Default is Trilinear mode.
  46576. *
  46577. * | Value | Type | Description |
  46578. * | ----- | ------------------ | ----------- |
  46579. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  46580. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  46581. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  46582. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  46583. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  46584. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  46585. * | 7 | NEAREST_LINEAR | |
  46586. * | 8 | NEAREST_NEAREST | |
  46587. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  46588. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  46589. * | 11 | LINEAR_LINEAR | |
  46590. * | 12 | LINEAR_NEAREST | |
  46591. *
  46592. * > _mag_: magnification filter (close to the viewer)
  46593. * > _min_: minification filter (far from the viewer)
  46594. * > _mip_: filter used between mip map levels
  46595. *@param samplingMode Define the new sampling mode of the texture
  46596. */
  46597. updateSamplingMode(samplingMode: number): void;
  46598. /**
  46599. * Scales the texture if is `canRescale()`
  46600. * @param ratio the resize factor we want to use to rescale
  46601. */
  46602. scale(ratio: number): void;
  46603. /**
  46604. * Get if the texture can rescale.
  46605. */
  46606. readonly canRescale: boolean;
  46607. /** @hidden */
  46608. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  46609. /** @hidden */
  46610. _rebuild(): void;
  46611. /**
  46612. * Triggers the load sequence in delayed load mode.
  46613. */
  46614. delayLoad(): void;
  46615. /**
  46616. * Clones the texture.
  46617. * @returns the cloned texture
  46618. */
  46619. clone(): Nullable<BaseTexture>;
  46620. /**
  46621. * Get the texture underlying type (INT, FLOAT...)
  46622. */
  46623. readonly textureType: number;
  46624. /**
  46625. * Get the texture underlying format (RGB, RGBA...)
  46626. */
  46627. readonly textureFormat: number;
  46628. /**
  46629. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  46630. * This will returns an RGBA array buffer containing either in values (0-255) or
  46631. * float values (0-1) depending of the underlying buffer type.
  46632. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  46633. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  46634. * @param buffer defines a user defined buffer to fill with data (can be null)
  46635. * @returns The Array buffer containing the pixels data.
  46636. */
  46637. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  46638. /**
  46639. * Release and destroy the underlying lower level texture aka internalTexture.
  46640. */
  46641. releaseInternalTexture(): void;
  46642. /**
  46643. * Get the polynomial representation of the texture data.
  46644. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  46645. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  46646. */
  46647. sphericalPolynomial: Nullable<SphericalPolynomial>;
  46648. /** @hidden */
  46649. readonly _lodTextureHigh: Nullable<BaseTexture>;
  46650. /** @hidden */
  46651. readonly _lodTextureMid: Nullable<BaseTexture>;
  46652. /** @hidden */
  46653. readonly _lodTextureLow: Nullable<BaseTexture>;
  46654. /**
  46655. * Dispose the texture and release its associated resources.
  46656. */
  46657. dispose(): void;
  46658. /**
  46659. * Serialize the texture into a JSON representation that can be parsed later on.
  46660. * @returns the JSON representation of the texture
  46661. */
  46662. serialize(): any;
  46663. /**
  46664. * Helper function to be called back once a list of texture contains only ready textures.
  46665. * @param textures Define the list of textures to wait for
  46666. * @param callback Define the callback triggered once the entire list will be ready
  46667. */
  46668. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  46669. }
  46670. }
  46671. declare module BABYLON {
  46672. /**
  46673. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  46674. * It can help converting any input color in a desired output one. This can then be used to create effects
  46675. * from sepia, black and white to sixties or futuristic rendering...
  46676. *
  46677. * The only supported format is currently 3dl.
  46678. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  46679. */
  46680. class ColorGradingTexture extends BaseTexture {
  46681. /**
  46682. * The current texture matrix. (will always be identity in color grading texture)
  46683. */
  46684. private _textureMatrix;
  46685. /**
  46686. * The texture URL.
  46687. */
  46688. url: string;
  46689. /**
  46690. * Empty line regex stored for GC.
  46691. */
  46692. private static _noneEmptyLineRegex;
  46693. private _engine;
  46694. /**
  46695. * Instantiates a ColorGradingTexture from the following parameters.
  46696. *
  46697. * @param url The location of the color gradind data (currently only supporting 3dl)
  46698. * @param scene The scene the texture will be used in
  46699. */
  46700. constructor(url: string, scene: Scene);
  46701. /**
  46702. * Returns the texture matrix used in most of the material.
  46703. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  46704. */
  46705. getTextureMatrix(): Matrix;
  46706. /**
  46707. * Occurs when the file being loaded is a .3dl LUT file.
  46708. */
  46709. private load3dlTexture;
  46710. /**
  46711. * Starts the loading process of the texture.
  46712. */
  46713. private loadTexture;
  46714. /**
  46715. * Clones the color gradind texture.
  46716. */
  46717. clone(): ColorGradingTexture;
  46718. /**
  46719. * Called during delayed load for textures.
  46720. */
  46721. delayLoad(): void;
  46722. /**
  46723. * Parses a color grading texture serialized by Babylon.
  46724. * @param parsedTexture The texture information being parsedTexture
  46725. * @param scene The scene to load the texture in
  46726. * @param rootUrl The root url of the data assets to load
  46727. * @return A color gradind texture
  46728. */
  46729. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<ColorGradingTexture>;
  46730. /**
  46731. * Serializes the LUT texture to json format.
  46732. */
  46733. serialize(): any;
  46734. }
  46735. }
  46736. declare module BABYLON {
  46737. /**
  46738. * Class for creating a cube texture
  46739. */
  46740. class CubeTexture extends BaseTexture {
  46741. private _delayedOnLoad;
  46742. /**
  46743. * The url of the texture
  46744. */
  46745. url: string;
  46746. /**
  46747. * Gets or sets the center of the bounding box associated with the cube texture.
  46748. * It must define where the camera used to render the texture was set
  46749. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  46750. */
  46751. boundingBoxPosition: Vector3;
  46752. private _boundingBoxSize;
  46753. /**
  46754. * Gets or sets the size of the bounding box associated with the cube texture
  46755. * When defined, the cubemap will switch to local mode
  46756. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  46757. * @example https://www.babylonjs-playground.com/#RNASML
  46758. */
  46759. /**
  46760. * Returns the bounding box size
  46761. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  46762. */
  46763. boundingBoxSize: Vector3;
  46764. protected _rotationY: number;
  46765. /**
  46766. * Sets texture matrix rotation angle around Y axis in radians.
  46767. */
  46768. /**
  46769. * Gets texture matrix rotation angle around Y axis radians.
  46770. */
  46771. rotationY: number;
  46772. /**
  46773. * Are mip maps generated for this texture or not.
  46774. */
  46775. readonly noMipmap: boolean;
  46776. private _noMipmap;
  46777. private _files;
  46778. private _extensions;
  46779. private _textureMatrix;
  46780. private _format;
  46781. private _createPolynomials;
  46782. /** @hidden */
  46783. _prefiltered: boolean;
  46784. /**
  46785. * Creates a cube texture from an array of image urls
  46786. * @param files defines an array of image urls
  46787. * @param scene defines the hosting scene
  46788. * @param noMipmap specifies if mip maps are not used
  46789. * @returns a cube texture
  46790. */
  46791. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  46792. /**
  46793. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  46794. * @param url defines the url of the prefiltered texture
  46795. * @param scene defines the scene the texture is attached to
  46796. * @param forcedExtension defines the extension of the file if different from the url
  46797. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  46798. * @return the prefiltered texture
  46799. */
  46800. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  46801. /**
  46802. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  46803. * as prefiltered data.
  46804. * @param rootUrl defines the url of the texture or the root name of the six images
  46805. * @param scene defines the scene the texture is attached to
  46806. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  46807. * @param noMipmap defines if mipmaps should be created or not
  46808. * @param files defines the six files to load for the different faces
  46809. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  46810. * @param onError defines a callback triggered in case of error during load
  46811. * @param format defines the internal format to use for the texture once loaded
  46812. * @param prefiltered defines whether or not the texture is created from prefiltered data
  46813. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  46814. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  46815. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  46816. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  46817. * @return the cube texture
  46818. */
  46819. 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);
  46820. /**
  46821. * Get the current class name of the texture useful for serialization or dynamic coding.
  46822. * @returns "CubeTexture"
  46823. */
  46824. getClassName(): string;
  46825. /**
  46826. * Update the url (and optional buffer) of this texture if url was null during construction.
  46827. * @param url the url of the texture
  46828. * @param forcedExtension defines the extension to use
  46829. * @param onLoad callback called when the texture is loaded (defaults to null)
  46830. */
  46831. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  46832. /**
  46833. * Delays loading of the cube texture
  46834. * @param forcedExtension defines the extension to use
  46835. */
  46836. delayLoad(forcedExtension?: string): void;
  46837. /**
  46838. * Returns the reflection texture matrix
  46839. * @returns the reflection texture matrix
  46840. */
  46841. getReflectionTextureMatrix(): Matrix;
  46842. /**
  46843. * Sets the reflection texture matrix
  46844. * @param value Reflection texture matrix
  46845. */
  46846. setReflectionTextureMatrix(value: Matrix): void;
  46847. /**
  46848. * Parses text to create a cube texture
  46849. * @param parsedTexture define the serialized text to read from
  46850. * @param scene defines the hosting scene
  46851. * @param rootUrl defines the root url of the cube texture
  46852. * @returns a cube texture
  46853. */
  46854. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  46855. /**
  46856. * Makes a clone, or deep copy, of the cube texture
  46857. * @returns a new cube texture
  46858. */
  46859. clone(): CubeTexture;
  46860. }
  46861. }
  46862. declare module BABYLON {
  46863. /**
  46864. * A class extending Texture allowing drawing on a texture
  46865. * @see http://doc.babylonjs.com/how_to/dynamictexture
  46866. */
  46867. class DynamicTexture extends Texture {
  46868. private _generateMipMaps;
  46869. private _canvas;
  46870. private _context;
  46871. private _engine;
  46872. /**
  46873. * Creates a DynamicTexture
  46874. * @param name defines the name of the texture
  46875. * @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
  46876. * @param scene defines the scene where you want the texture
  46877. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  46878. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  46879. * @param format defines the texture format to use (default is BABYLON.Engine.TEXTUREFORMAT_RGBA)
  46880. */
  46881. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  46882. /**
  46883. * Get the current class name of the texture useful for serialization or dynamic coding.
  46884. * @returns "DynamicTexture"
  46885. */
  46886. getClassName(): string;
  46887. /**
  46888. * Gets the current state of canRescale
  46889. */
  46890. readonly canRescale: boolean;
  46891. private _recreate;
  46892. /**
  46893. * Scales the texture
  46894. * @param ratio the scale factor to apply to both width and height
  46895. */
  46896. scale(ratio: number): void;
  46897. /**
  46898. * Resizes the texture
  46899. * @param width the new width
  46900. * @param height the new height
  46901. */
  46902. scaleTo(width: number, height: number): void;
  46903. /**
  46904. * Gets the context of the canvas used by the texture
  46905. * @returns the canvas context of the dynamic texture
  46906. */
  46907. getContext(): CanvasRenderingContext2D;
  46908. /**
  46909. * Clears the texture
  46910. */
  46911. clear(): void;
  46912. /**
  46913. * Updates the texture
  46914. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  46915. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  46916. */
  46917. update(invertY?: boolean, premulAlpha?: boolean): void;
  46918. /**
  46919. * Draws text onto the texture
  46920. * @param text defines the text to be drawn
  46921. * @param x defines the placement of the text from the left
  46922. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  46923. * @param font defines the font to be used with font-style, font-size, font-name
  46924. * @param color defines the color used for the text
  46925. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  46926. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  46927. * @param update defines whether texture is immediately update (default is true)
  46928. */
  46929. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  46930. /**
  46931. * Clones the texture
  46932. * @returns the clone of the texture.
  46933. */
  46934. clone(): DynamicTexture;
  46935. /**
  46936. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  46937. * @returns a serialized dynamic texture object
  46938. */
  46939. serialize(): any;
  46940. /** @hidden */
  46941. _rebuild(): void;
  46942. }
  46943. }
  46944. declare module BABYLON {
  46945. /**
  46946. * This represents a texture coming from an HDR input.
  46947. *
  46948. * The only supported format is currently panorama picture stored in RGBE format.
  46949. * Example of such files can be found on HDRLib: http://hdrlib.com/
  46950. */
  46951. class HDRCubeTexture extends BaseTexture {
  46952. private static _facesMapping;
  46953. private _generateHarmonics;
  46954. private _noMipmap;
  46955. private _textureMatrix;
  46956. private _size;
  46957. private _onLoad;
  46958. private _onError;
  46959. /**
  46960. * The texture URL.
  46961. */
  46962. url: string;
  46963. /**
  46964. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  46965. */
  46966. coordinatesMode: number;
  46967. protected _isBlocking: boolean;
  46968. /**
  46969. * Sets wether or not the texture is blocking during loading.
  46970. */
  46971. /**
  46972. * Gets wether or not the texture is blocking during loading.
  46973. */
  46974. isBlocking: boolean;
  46975. protected _rotationY: number;
  46976. /**
  46977. * Sets texture matrix rotation angle around Y axis in radians.
  46978. */
  46979. /**
  46980. * Gets texture matrix rotation angle around Y axis radians.
  46981. */
  46982. rotationY: number;
  46983. /**
  46984. * Gets or sets the center of the bounding box associated with the cube texture
  46985. * It must define where the camera used to render the texture was set
  46986. */
  46987. boundingBoxPosition: Vector3;
  46988. private _boundingBoxSize;
  46989. /**
  46990. * Gets or sets the size of the bounding box associated with the cube texture
  46991. * When defined, the cubemap will switch to local mode
  46992. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  46993. * @example https://www.babylonjs-playground.com/#RNASML
  46994. */
  46995. boundingBoxSize: Vector3;
  46996. /**
  46997. * Instantiates an HDRTexture from the following parameters.
  46998. *
  46999. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  47000. * @param scene The scene the texture will be used in
  47001. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  47002. * @param noMipmap Forces to not generate the mipmap if true
  47003. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  47004. * @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)
  47005. * @param reserved Reserved flag for internal use.
  47006. */
  47007. 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>);
  47008. /**
  47009. * Get the current class name of the texture useful for serialization or dynamic coding.
  47010. * @returns "HDRCubeTexture"
  47011. */
  47012. getClassName(): string;
  47013. /**
  47014. * Occurs when the file is raw .hdr file.
  47015. */
  47016. private loadTexture;
  47017. clone(): HDRCubeTexture;
  47018. delayLoad(): void;
  47019. /**
  47020. * Get the texture reflection matrix used to rotate/transform the reflection.
  47021. * @returns the reflection matrix
  47022. */
  47023. getReflectionTextureMatrix(): Matrix;
  47024. /**
  47025. * Set the texture reflection matrix used to rotate/transform the reflection.
  47026. * @param value Define the reflection matrix to set
  47027. */
  47028. setReflectionTextureMatrix(value: Matrix): void;
  47029. /**
  47030. * Parses a JSON representation of an HDR Texture in order to create the texture
  47031. * @param parsedTexture Define the JSON representation
  47032. * @param scene Define the scene the texture should be created in
  47033. * @param rootUrl Define the root url in case we need to load relative dependencies
  47034. * @returns the newly created texture after parsing
  47035. */
  47036. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  47037. serialize(): any;
  47038. }
  47039. }
  47040. declare module BABYLON {
  47041. /**
  47042. * Class used to store data associated with WebGL texture data for the engine
  47043. * This class should not be used directly
  47044. */
  47045. class InternalTexture implements IInternalTextureTracker {
  47046. /**
  47047. * The source of the texture data is unknown
  47048. */
  47049. static DATASOURCE_UNKNOWN: number;
  47050. /**
  47051. * Texture data comes from an URL
  47052. */
  47053. static DATASOURCE_URL: number;
  47054. /**
  47055. * Texture data is only used for temporary storage
  47056. */
  47057. static DATASOURCE_TEMP: number;
  47058. /**
  47059. * Texture data comes from raw data (ArrayBuffer)
  47060. */
  47061. static DATASOURCE_RAW: number;
  47062. /**
  47063. * Texture content is dynamic (video or dynamic texture)
  47064. */
  47065. static DATASOURCE_DYNAMIC: number;
  47066. /**
  47067. * Texture content is generated by rendering to it
  47068. */
  47069. static DATASOURCE_RENDERTARGET: number;
  47070. /**
  47071. * Texture content is part of a multi render target process
  47072. */
  47073. static DATASOURCE_MULTIRENDERTARGET: number;
  47074. /**
  47075. * Texture data comes from a cube data file
  47076. */
  47077. static DATASOURCE_CUBE: number;
  47078. /**
  47079. * Texture data comes from a raw cube data
  47080. */
  47081. static DATASOURCE_CUBERAW: number;
  47082. /**
  47083. * Texture data come from a prefiltered cube data file
  47084. */
  47085. static DATASOURCE_CUBEPREFILTERED: number;
  47086. /**
  47087. * Texture content is raw 3D data
  47088. */
  47089. static DATASOURCE_RAW3D: number;
  47090. /**
  47091. * Texture content is a depth texture
  47092. */
  47093. static DATASOURCE_DEPTHTEXTURE: number;
  47094. /**
  47095. * Texture data comes from a raw cube data encoded with RGBD
  47096. */
  47097. static DATASOURCE_CUBERAW_RGBD: number;
  47098. /**
  47099. * Defines if the texture is ready
  47100. */
  47101. isReady: boolean;
  47102. /**
  47103. * Defines if the texture is a cube texture
  47104. */
  47105. isCube: boolean;
  47106. /**
  47107. * Defines if the texture contains 3D data
  47108. */
  47109. is3D: boolean;
  47110. /**
  47111. * Gets the URL used to load this texture
  47112. */
  47113. url: string;
  47114. /**
  47115. * Gets the sampling mode of the texture
  47116. */
  47117. samplingMode: number;
  47118. /**
  47119. * Gets a boolean indicating if the texture needs mipmaps generation
  47120. */
  47121. generateMipMaps: boolean;
  47122. /**
  47123. * Gets the number of samples used by the texture (WebGL2+ only)
  47124. */
  47125. samples: number;
  47126. /**
  47127. * Gets the type of the texture (int, float...)
  47128. */
  47129. type: number;
  47130. /**
  47131. * Gets the format of the texture (RGB, RGBA...)
  47132. */
  47133. format: number;
  47134. /**
  47135. * Observable called when the texture is loaded
  47136. */
  47137. onLoadedObservable: Observable<InternalTexture>;
  47138. /**
  47139. * Gets the width of the texture
  47140. */
  47141. width: number;
  47142. /**
  47143. * Gets the height of the texture
  47144. */
  47145. height: number;
  47146. /**
  47147. * Gets the depth of the texture
  47148. */
  47149. depth: number;
  47150. /**
  47151. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  47152. */
  47153. baseWidth: number;
  47154. /**
  47155. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  47156. */
  47157. baseHeight: number;
  47158. /**
  47159. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  47160. */
  47161. baseDepth: number;
  47162. /**
  47163. * Gets a boolean indicating if the texture is inverted on Y axis
  47164. */
  47165. invertY: boolean;
  47166. /**
  47167. * Gets or set the previous tracker in the list
  47168. */
  47169. previous: Nullable<IInternalTextureTracker>;
  47170. /**
  47171. * Gets or set the next tracker in the list
  47172. */
  47173. next: Nullable<IInternalTextureTracker>;
  47174. /** @hidden */
  47175. _invertVScale: boolean;
  47176. /** @hidden */
  47177. _initialSlot: number;
  47178. /** @hidden */
  47179. _designatedSlot: number;
  47180. /** @hidden */
  47181. _dataSource: number;
  47182. /** @hidden */
  47183. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  47184. /** @hidden */
  47185. _bufferView: Nullable<ArrayBufferView>;
  47186. /** @hidden */
  47187. _bufferViewArray: Nullable<ArrayBufferView[]>;
  47188. /** @hidden */
  47189. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  47190. /** @hidden */
  47191. _size: number;
  47192. /** @hidden */
  47193. _extension: string;
  47194. /** @hidden */
  47195. _files: Nullable<string[]>;
  47196. /** @hidden */
  47197. _workingCanvas: HTMLCanvasElement;
  47198. /** @hidden */
  47199. _workingContext: CanvasRenderingContext2D;
  47200. /** @hidden */
  47201. _framebuffer: Nullable<WebGLFramebuffer>;
  47202. /** @hidden */
  47203. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  47204. /** @hidden */
  47205. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  47206. /** @hidden */
  47207. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  47208. /** @hidden */
  47209. _attachments: Nullable<number[]>;
  47210. /** @hidden */
  47211. _cachedCoordinatesMode: Nullable<number>;
  47212. /** @hidden */
  47213. _cachedWrapU: Nullable<number>;
  47214. /** @hidden */
  47215. _cachedWrapV: Nullable<number>;
  47216. /** @hidden */
  47217. _cachedWrapR: Nullable<number>;
  47218. /** @hidden */
  47219. _cachedAnisotropicFilteringLevel: Nullable<number>;
  47220. /** @hidden */
  47221. _isDisabled: boolean;
  47222. /** @hidden */
  47223. _compression: Nullable<string>;
  47224. /** @hidden */
  47225. _generateStencilBuffer: boolean;
  47226. /** @hidden */
  47227. _generateDepthBuffer: boolean;
  47228. /** @hidden */
  47229. _comparisonFunction: number;
  47230. /** @hidden */
  47231. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  47232. /** @hidden */
  47233. _lodGenerationScale: number;
  47234. /** @hidden */
  47235. _lodGenerationOffset: number;
  47236. /** @hidden */
  47237. _lodTextureHigh: BaseTexture;
  47238. /** @hidden */
  47239. _lodTextureMid: BaseTexture;
  47240. /** @hidden */
  47241. _lodTextureLow: BaseTexture;
  47242. /** @hidden */
  47243. _isRGBD: boolean;
  47244. /** @hidden */
  47245. _webGLTexture: Nullable<WebGLTexture>;
  47246. /** @hidden */
  47247. _references: number;
  47248. private _engine;
  47249. /**
  47250. * Gets the Engine the texture belongs to.
  47251. * @returns The babylon engine
  47252. */
  47253. getEngine(): Engine;
  47254. /**
  47255. * Gets the data source type of the texture (can be one of the BABYLON.InternalTexture.DATASOURCE_XXXX)
  47256. */
  47257. readonly dataSource: number;
  47258. /**
  47259. * Creates a new InternalTexture
  47260. * @param engine defines the engine to use
  47261. * @param dataSource defines the type of data that will be used
  47262. * @param delayAllocation if the texture allocation should be delayed (default: false)
  47263. */
  47264. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  47265. /**
  47266. * Increments the number of references (ie. the number of Texture that point to it)
  47267. */
  47268. incrementReferences(): void;
  47269. /**
  47270. * Change the size of the texture (not the size of the content)
  47271. * @param width defines the new width
  47272. * @param height defines the new height
  47273. * @param depth defines the new depth (1 by default)
  47274. */
  47275. updateSize(width: int, height: int, depth?: int): void;
  47276. /** @hidden */
  47277. _rebuild(): void;
  47278. /** @hidden */
  47279. _swapAndDie(target: InternalTexture): void;
  47280. /**
  47281. * Dispose the current allocated resources
  47282. */
  47283. dispose(): void;
  47284. }
  47285. }
  47286. declare module BABYLON {
  47287. /**
  47288. * This represents the required contract to create a new type of texture loader.
  47289. */
  47290. interface IInternalTextureLoader {
  47291. /**
  47292. * Defines wether the loader supports cascade loading the different faces.
  47293. */
  47294. supportCascades: boolean;
  47295. /**
  47296. * This returns if the loader support the current file information.
  47297. * @param extension defines the file extension of the file being loaded
  47298. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47299. * @param fallback defines the fallback internal texture if any
  47300. * @param isBase64 defines whether the texture is encoded as a base64
  47301. * @param isBuffer defines whether the texture data are stored as a buffer
  47302. * @returns true if the loader can load the specified file
  47303. */
  47304. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47305. /**
  47306. * Transform the url before loading if required.
  47307. * @param rootUrl the url of the texture
  47308. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47309. * @returns the transformed texture
  47310. */
  47311. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47312. /**
  47313. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47314. * @param rootUrl the url of the texture
  47315. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47316. * @returns the fallback texture
  47317. */
  47318. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47319. /**
  47320. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47321. * @param data contains the texture data
  47322. * @param texture defines the BabylonJS internal texture
  47323. * @param createPolynomials will be true if polynomials have been requested
  47324. * @param onLoad defines the callback to trigger once the texture is ready
  47325. * @param onError defines the callback to trigger in case of error
  47326. */
  47327. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47328. /**
  47329. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47330. * @param data contains the texture data
  47331. * @param texture defines the BabylonJS internal texture
  47332. * @param callback defines the method to call once ready to upload
  47333. */
  47334. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  47335. }
  47336. }
  47337. declare module BABYLON {
  47338. /**
  47339. * Internal interface used to track InternalTexture already bound to the GL context
  47340. */
  47341. interface IInternalTextureTracker {
  47342. /**
  47343. * Gets or set the previous tracker in the list
  47344. */
  47345. previous: Nullable<IInternalTextureTracker>;
  47346. /**
  47347. * Gets or set the next tracker in the list
  47348. */
  47349. next: Nullable<IInternalTextureTracker>;
  47350. }
  47351. /**
  47352. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  47353. */
  47354. class DummyInternalTextureTracker {
  47355. /**
  47356. * Gets or set the previous tracker in the list
  47357. */
  47358. previous: Nullable<IInternalTextureTracker>;
  47359. /**
  47360. * Gets or set the next tracker in the list
  47361. */
  47362. next: Nullable<IInternalTextureTracker>;
  47363. }
  47364. }
  47365. declare module BABYLON {
  47366. /**
  47367. * Mirror texture can be used to simulate the view from a mirror in a scene.
  47368. * It will dynamically be rendered every frame to adapt to the camera point of view.
  47369. * You can then easily use it as a reflectionTexture on a flat surface.
  47370. * In case the surface is not a plane, please consider relying on reflection probes.
  47371. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  47372. */
  47373. class MirrorTexture extends RenderTargetTexture {
  47374. private scene;
  47375. /**
  47376. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  47377. * 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.
  47378. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  47379. */
  47380. mirrorPlane: Plane;
  47381. /**
  47382. * Define the blur ratio used to blur the reflection if needed.
  47383. */
  47384. blurRatio: number;
  47385. /**
  47386. * Define the adaptive blur kernel used to blur the reflection if needed.
  47387. * This will autocompute the closest best match for the `blurKernel`
  47388. */
  47389. adaptiveBlurKernel: number;
  47390. /**
  47391. * Define the blur kernel used to blur the reflection if needed.
  47392. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  47393. */
  47394. blurKernel: number;
  47395. /**
  47396. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  47397. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  47398. */
  47399. blurKernelX: number;
  47400. /**
  47401. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  47402. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  47403. */
  47404. blurKernelY: number;
  47405. private _autoComputeBlurKernel;
  47406. protected _onRatioRescale(): void;
  47407. private _updateGammaSpace;
  47408. private _imageProcessingConfigChangeObserver;
  47409. private _transformMatrix;
  47410. private _mirrorMatrix;
  47411. private _savedViewMatrix;
  47412. private _blurX;
  47413. private _blurY;
  47414. private _adaptiveBlurKernel;
  47415. private _blurKernelX;
  47416. private _blurKernelY;
  47417. private _blurRatio;
  47418. /**
  47419. * Instantiates a Mirror Texture.
  47420. * Mirror texture can be used to simulate the view from a mirror in a scene.
  47421. * It will dynamically be rendered every frame to adapt to the camera point of view.
  47422. * You can then easily use it as a reflectionTexture on a flat surface.
  47423. * In case the surface is not a plane, please consider relying on reflection probes.
  47424. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  47425. * @param name
  47426. * @param size
  47427. * @param scene
  47428. * @param generateMipMaps
  47429. * @param type
  47430. * @param samplingMode
  47431. * @param generateDepthBuffer
  47432. */
  47433. constructor(name: string, size: number | {
  47434. width: number;
  47435. height: number;
  47436. } | {
  47437. ratio: number;
  47438. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  47439. private _preparePostProcesses;
  47440. /**
  47441. * Clone the mirror texture.
  47442. * @returns the cloned texture
  47443. */
  47444. clone(): MirrorTexture;
  47445. /**
  47446. * Serialize the texture to a JSON representation you could use in Parse later on
  47447. * @returns the serialized JSON representation
  47448. */
  47449. serialize(): any;
  47450. /**
  47451. * Dispose the texture and release its associated resources.
  47452. */
  47453. dispose(): void;
  47454. }
  47455. }
  47456. declare module BABYLON {
  47457. /**
  47458. * Creation options of the multi render target texture.
  47459. */
  47460. interface IMultiRenderTargetOptions {
  47461. /**
  47462. * Define if the texture needs to create mip maps after render.
  47463. */
  47464. generateMipMaps?: boolean;
  47465. /**
  47466. * Define the types of all the draw buffers we want to create
  47467. */
  47468. types?: number[];
  47469. /**
  47470. * Define the sampling modes of all the draw buffers we want to create
  47471. */
  47472. samplingModes?: number[];
  47473. /**
  47474. * Define if a depth buffer is required
  47475. */
  47476. generateDepthBuffer?: boolean;
  47477. /**
  47478. * Define if a stencil buffer is required
  47479. */
  47480. generateStencilBuffer?: boolean;
  47481. /**
  47482. * Define if a depth texture is required instead of a depth buffer
  47483. */
  47484. generateDepthTexture?: boolean;
  47485. /**
  47486. * Define the number of desired draw buffers
  47487. */
  47488. textureCount?: number;
  47489. /**
  47490. * Define if aspect ratio should be adapted to the texture or stay the scene one
  47491. */
  47492. doNotChangeAspectRatio?: boolean;
  47493. /**
  47494. * Define the default type of the buffers we are creating
  47495. */
  47496. defaultType?: number;
  47497. }
  47498. /**
  47499. * A multi render target, like a render target provides the ability to render to a texture.
  47500. * Unlike the render target, it can render to several draw buffers in one draw.
  47501. * This is specially interesting in deferred rendering or for any effects requiring more than
  47502. * just one color from a single pass.
  47503. */
  47504. class MultiRenderTarget extends RenderTargetTexture {
  47505. private _internalTextures;
  47506. private _textures;
  47507. private _multiRenderTargetOptions;
  47508. /**
  47509. * Get if draw buffers are currently supported by the used hardware and browser.
  47510. */
  47511. readonly isSupported: boolean;
  47512. /**
  47513. * Get the list of textures generated by the multi render target.
  47514. */
  47515. readonly textures: Texture[];
  47516. /**
  47517. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  47518. */
  47519. readonly depthTexture: Texture;
  47520. /**
  47521. * Set the wrapping mode on U of all the textures we are rendering to.
  47522. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47523. */
  47524. wrapU: number;
  47525. /**
  47526. * Set the wrapping mode on V of all the textures we are rendering to.
  47527. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47528. */
  47529. wrapV: number;
  47530. /**
  47531. * Instantiate a new multi render target texture.
  47532. * A multi render target, like a render target provides the ability to render to a texture.
  47533. * Unlike the render target, it can render to several draw buffers in one draw.
  47534. * This is specially interesting in deferred rendering or for any effects requiring more than
  47535. * just one color from a single pass.
  47536. * @param name Define the name of the texture
  47537. * @param size Define the size of the buffers to render to
  47538. * @param count Define the number of target we are rendering into
  47539. * @param scene Define the scene the texture belongs to
  47540. * @param options Define the options used to create the multi render target
  47541. */
  47542. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  47543. /** @hidden */
  47544. _rebuild(): void;
  47545. private _createInternalTextures;
  47546. private _createTextures;
  47547. /**
  47548. * Define the number of samples used if MSAA is enabled.
  47549. */
  47550. samples: number;
  47551. /**
  47552. * Resize all the textures in the multi render target.
  47553. * Be carrefull as it will recreate all the data in the new texture.
  47554. * @param size Define the new size
  47555. */
  47556. resize(size: any): void;
  47557. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  47558. /**
  47559. * Dispose the render targets and their associated resources
  47560. */
  47561. dispose(): void;
  47562. /**
  47563. * Release all the underlying texture used as draw buffers.
  47564. */
  47565. releaseInternalTextures(): void;
  47566. }
  47567. }
  47568. declare module BABYLON {
  47569. /**
  47570. * Raw cube texture where the raw buffers are passed in
  47571. */
  47572. class RawCubeTexture extends CubeTexture {
  47573. /**
  47574. * Creates a cube texture where the raw buffers are passed in.
  47575. * @param scene defines the scene the texture is attached to
  47576. * @param data defines the array of data to use to create each face
  47577. * @param size defines the size of the textures
  47578. * @param format defines the format of the data
  47579. * @param type defines the type of the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  47580. * @param generateMipMaps defines if the engine should generate the mip levels
  47581. * @param invertY defines if data must be stored with Y axis inverted
  47582. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  47583. * @param compression defines the compression used (null by default)
  47584. */
  47585. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  47586. /**
  47587. * Updates the raw cube texture.
  47588. * @param data defines the data to store
  47589. * @param format defines the data format
  47590. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  47591. * @param invertY defines if data must be stored with Y axis inverted
  47592. * @param compression defines the compression used (null by default)
  47593. * @param level defines which level of the texture to update
  47594. */
  47595. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  47596. /**
  47597. * Updates a raw cube texture with RGBD encoded data.
  47598. * @param data defines the array of data [mipmap][face] to use to create each face
  47599. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  47600. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  47601. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  47602. * @returns a promsie that resolves when the operation is complete
  47603. */
  47604. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  47605. /**
  47606. * Clones the raw cube texture.
  47607. * @return a new cube texture
  47608. */
  47609. clone(): CubeTexture;
  47610. /** @hidden */
  47611. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  47612. }
  47613. }
  47614. declare module BABYLON {
  47615. /**
  47616. * Raw texture can help creating a texture directly from an array of data.
  47617. * This can be super useful if you either get the data from an uncompressed source or
  47618. * if you wish to create your texture pixel by pixel.
  47619. */
  47620. class RawTexture extends Texture {
  47621. /**
  47622. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  47623. */
  47624. format: number;
  47625. private _engine;
  47626. /**
  47627. * Instantiates a new RawTexture.
  47628. * Raw texture can help creating a texture directly from an array of data.
  47629. * This can be super useful if you either get the data from an uncompressed source or
  47630. * if you wish to create your texture pixel by pixel.
  47631. * @param data define the array of data to use to create the texture
  47632. * @param width define the width of the texture
  47633. * @param height define the height of the texture
  47634. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  47635. * @param scene define the scene the texture belongs to
  47636. * @param generateMipMaps define whether mip maps should be generated or not
  47637. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47638. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47639. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  47640. */
  47641. constructor(data: ArrayBufferView, width: number, height: number,
  47642. /**
  47643. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  47644. */
  47645. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  47646. /**
  47647. * Updates the texture underlying data.
  47648. * @param data Define the new data of the texture
  47649. */
  47650. update(data: ArrayBufferView): void;
  47651. /**
  47652. * Creates a luminance texture from some data.
  47653. * @param data Define the texture data
  47654. * @param width Define the width of the texture
  47655. * @param height Define the height of the texture
  47656. * @param scene Define the scene the texture belongs to
  47657. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47658. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47659. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47660. * @returns the luminance texture
  47661. */
  47662. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  47663. /**
  47664. * Creates a luminance alpha texture from some data.
  47665. * @param data Define the texture data
  47666. * @param width Define the width of the texture
  47667. * @param height Define the height of the texture
  47668. * @param scene Define the scene the texture belongs to
  47669. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47670. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47671. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47672. * @returns the luminance alpha texture
  47673. */
  47674. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  47675. /**
  47676. * Creates an alpha texture from some data.
  47677. * @param data Define the texture data
  47678. * @param width Define the width of the texture
  47679. * @param height Define the height of the texture
  47680. * @param scene Define the scene the texture belongs to
  47681. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47682. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47683. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47684. * @returns the alpha texture
  47685. */
  47686. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  47687. /**
  47688. * Creates a RGB texture from some data.
  47689. * @param data Define the texture data
  47690. * @param width Define the width of the texture
  47691. * @param height Define the height of the texture
  47692. * @param scene Define the scene the texture belongs to
  47693. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47694. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47695. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47696. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  47697. * @returns the RGB alpha texture
  47698. */
  47699. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  47700. /**
  47701. * Creates a RGBA texture from some data.
  47702. * @param data Define the texture data
  47703. * @param width Define the width of the texture
  47704. * @param height Define the height of the texture
  47705. * @param scene Define the scene the texture belongs to
  47706. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47707. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47708. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47709. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  47710. * @returns the RGBA texture
  47711. */
  47712. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  47713. /**
  47714. * Creates a R texture from some data.
  47715. * @param data Define the texture data
  47716. * @param width Define the width of the texture
  47717. * @param height Define the height of the texture
  47718. * @param scene Define the scene the texture belongs to
  47719. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47720. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47721. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47722. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  47723. * @returns the R texture
  47724. */
  47725. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  47726. }
  47727. }
  47728. declare module BABYLON {
  47729. /**
  47730. * Class used to store 3D textures containing user data
  47731. */
  47732. class RawTexture3D extends Texture {
  47733. /** Gets or sets the texture format to use */
  47734. format: number;
  47735. private _engine;
  47736. /**
  47737. * Create a new RawTexture3D
  47738. * @param data defines the data of the texture
  47739. * @param width defines the width of the texture
  47740. * @param height defines the height of the texture
  47741. * @param depth defines the depth of the texture
  47742. * @param format defines the texture format to use
  47743. * @param scene defines the hosting scene
  47744. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  47745. * @param invertY defines if texture must be stored with Y axis inverted
  47746. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  47747. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  47748. */
  47749. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  47750. /** Gets or sets the texture format to use */
  47751. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  47752. /**
  47753. * Update the texture with new data
  47754. * @param data defines the data to store in the texture
  47755. */
  47756. update(data: ArrayBufferView): void;
  47757. }
  47758. }
  47759. declare module BABYLON {
  47760. /**
  47761. * Creates a refraction texture used by refraction channel of the standard material.
  47762. * It is like a mirror but to see through a material.
  47763. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  47764. */
  47765. class RefractionTexture extends RenderTargetTexture {
  47766. /**
  47767. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  47768. * 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.
  47769. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  47770. */
  47771. refractionPlane: Plane;
  47772. /**
  47773. * Define how deep under the surface we should see.
  47774. */
  47775. depth: number;
  47776. /**
  47777. * Creates a refraction texture used by refraction channel of the standard material.
  47778. * It is like a mirror but to see through a material.
  47779. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  47780. * @param name Define the texture name
  47781. * @param size Define the size of the underlying texture
  47782. * @param scene Define the scene the refraction belongs to
  47783. * @param generateMipMaps Define if we need to generate mips level for the refraction
  47784. */
  47785. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  47786. /**
  47787. * Clone the refraction texture.
  47788. * @returns the cloned texture
  47789. */
  47790. clone(): RefractionTexture;
  47791. /**
  47792. * Serialize the texture to a JSON representation you could use in Parse later on
  47793. * @returns the serialized JSON representation
  47794. */
  47795. serialize(): any;
  47796. }
  47797. }
  47798. declare module BABYLON {
  47799. /**
  47800. * This Helps creating a texture that will be created from a camera in your scene.
  47801. * It is basically a dynamic texture that could be used to create special effects for instance.
  47802. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  47803. */
  47804. class RenderTargetTexture extends Texture {
  47805. isCube: boolean;
  47806. /**
  47807. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  47808. */
  47809. static readonly REFRESHRATE_RENDER_ONCE: number;
  47810. /**
  47811. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  47812. */
  47813. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  47814. /**
  47815. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  47816. * the central point of your effect and can save a lot of performances.
  47817. */
  47818. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  47819. /**
  47820. * Use this predicate to dynamically define the list of mesh you want to render.
  47821. * If set, the renderList property will be overwritten.
  47822. */
  47823. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  47824. private _renderList;
  47825. /**
  47826. * Use this list to define the list of mesh you want to render.
  47827. */
  47828. renderList: Nullable<Array<AbstractMesh>>;
  47829. private _hookArray;
  47830. /**
  47831. * Define if particles should be rendered in your texture.
  47832. */
  47833. renderParticles: boolean;
  47834. /**
  47835. * Define if sprites should be rendered in your texture.
  47836. */
  47837. renderSprites: boolean;
  47838. /**
  47839. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  47840. */
  47841. coordinatesMode: number;
  47842. /**
  47843. * Define the camera used to render the texture.
  47844. */
  47845. activeCamera: Nullable<Camera>;
  47846. /**
  47847. * Override the render function of the texture with your own one.
  47848. */
  47849. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  47850. /**
  47851. * Define if camera post processes should be use while rendering the texture.
  47852. */
  47853. useCameraPostProcesses: boolean;
  47854. /**
  47855. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  47856. */
  47857. ignoreCameraViewport: boolean;
  47858. private _postProcessManager;
  47859. private _postProcesses;
  47860. private _resizeObserver;
  47861. /**
  47862. * An event triggered when the texture is unbind.
  47863. */
  47864. onBeforeBindObservable: Observable<RenderTargetTexture>;
  47865. /**
  47866. * An event triggered when the texture is unbind.
  47867. */
  47868. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  47869. private _onAfterUnbindObserver;
  47870. /**
  47871. * Set a after unbind callback in the texture.
  47872. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  47873. */
  47874. onAfterUnbind: () => void;
  47875. /**
  47876. * An event triggered before rendering the texture
  47877. */
  47878. onBeforeRenderObservable: Observable<number>;
  47879. private _onBeforeRenderObserver;
  47880. /**
  47881. * Set a before render callback in the texture.
  47882. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  47883. */
  47884. onBeforeRender: (faceIndex: number) => void;
  47885. /**
  47886. * An event triggered after rendering the texture
  47887. */
  47888. onAfterRenderObservable: Observable<number>;
  47889. private _onAfterRenderObserver;
  47890. /**
  47891. * Set a after render callback in the texture.
  47892. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  47893. */
  47894. onAfterRender: (faceIndex: number) => void;
  47895. /**
  47896. * An event triggered after the texture clear
  47897. */
  47898. onClearObservable: Observable<Engine>;
  47899. private _onClearObserver;
  47900. /**
  47901. * Set a clear callback in the texture.
  47902. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  47903. */
  47904. onClear: (Engine: Engine) => void;
  47905. /**
  47906. * Define the clear color of the Render Target if it should be different from the scene.
  47907. */
  47908. clearColor: Color4;
  47909. protected _size: number | {
  47910. width: number;
  47911. height: number;
  47912. };
  47913. protected _initialSizeParameter: number | {
  47914. width: number;
  47915. height: number;
  47916. } | {
  47917. ratio: number;
  47918. };
  47919. protected _sizeRatio: Nullable<number>;
  47920. /** @hidden */
  47921. _generateMipMaps: boolean;
  47922. protected _renderingManager: RenderingManager;
  47923. /** @hidden */
  47924. _waitingRenderList: string[];
  47925. protected _doNotChangeAspectRatio: boolean;
  47926. protected _currentRefreshId: number;
  47927. protected _refreshRate: number;
  47928. protected _textureMatrix: Matrix;
  47929. protected _samples: number;
  47930. protected _renderTargetOptions: RenderTargetCreationOptions;
  47931. /**
  47932. * Gets render target creation options that were used.
  47933. */
  47934. readonly renderTargetOptions: RenderTargetCreationOptions;
  47935. protected _engine: Engine;
  47936. protected _onRatioRescale(): void;
  47937. /**
  47938. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  47939. * It must define where the camera used to render the texture is set
  47940. */
  47941. boundingBoxPosition: Vector3;
  47942. private _boundingBoxSize;
  47943. /**
  47944. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  47945. * When defined, the cubemap will switch to local mode
  47946. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  47947. * @example https://www.babylonjs-playground.com/#RNASML
  47948. */
  47949. boundingBoxSize: Vector3;
  47950. /**
  47951. * In case the RTT has been created with a depth texture, get the associated
  47952. * depth texture.
  47953. * Otherwise, return null.
  47954. */
  47955. depthStencilTexture: Nullable<InternalTexture>;
  47956. /**
  47957. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  47958. * or used a shadow, depth texture...
  47959. * @param name The friendly name of the texture
  47960. * @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)
  47961. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  47962. * @param generateMipMaps True if mip maps need to be generated after render.
  47963. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  47964. * @param type The type of the buffer in the RTT (int, half float, float...)
  47965. * @param isCube True if a cube texture needs to be created
  47966. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  47967. * @param generateDepthBuffer True to generate a depth buffer
  47968. * @param generateStencilBuffer True to generate a stencil buffer
  47969. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  47970. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  47971. * @param delayAllocation if the texture allocation should be delayed (default: false)
  47972. */
  47973. constructor(name: string, size: number | {
  47974. width: number;
  47975. height: number;
  47976. } | {
  47977. ratio: number;
  47978. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  47979. /**
  47980. * Creates a depth stencil texture.
  47981. * This is only available in WebGL 2 or with the depth texture extension available.
  47982. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  47983. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  47984. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  47985. */
  47986. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  47987. private _processSizeParameter;
  47988. /**
  47989. * Define the number of samples to use in case of MSAA.
  47990. * It defaults to one meaning no MSAA has been enabled.
  47991. */
  47992. samples: number;
  47993. /**
  47994. * Resets the refresh counter of the texture and start bak from scratch.
  47995. * Could be useful to regenerate the texture if it is setup to render only once.
  47996. */
  47997. resetRefreshCounter(): void;
  47998. /**
  47999. * Define the refresh rate of the texture or the rendering frequency.
  48000. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  48001. */
  48002. refreshRate: number;
  48003. /**
  48004. * Adds a post process to the render target rendering passes.
  48005. * @param postProcess define the post process to add
  48006. */
  48007. addPostProcess(postProcess: PostProcess): void;
  48008. /**
  48009. * Clear all the post processes attached to the render target
  48010. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  48011. */
  48012. clearPostProcesses(dispose?: boolean): void;
  48013. /**
  48014. * Remove one of the post process from the list of attached post processes to the texture
  48015. * @param postProcess define the post process to remove from the list
  48016. */
  48017. removePostProcess(postProcess: PostProcess): void;
  48018. /** @hidden */
  48019. _shouldRender(): boolean;
  48020. /**
  48021. * Gets the actual render size of the texture.
  48022. * @returns the width of the render size
  48023. */
  48024. getRenderSize(): number;
  48025. /**
  48026. * Gets the actual render width of the texture.
  48027. * @returns the width of the render size
  48028. */
  48029. getRenderWidth(): number;
  48030. /**
  48031. * Gets the actual render height of the texture.
  48032. * @returns the height of the render size
  48033. */
  48034. getRenderHeight(): number;
  48035. /**
  48036. * Get if the texture can be rescaled or not.
  48037. */
  48038. readonly canRescale: boolean;
  48039. /**
  48040. * Resize the texture using a ratio.
  48041. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  48042. */
  48043. scale(ratio: number): void;
  48044. /**
  48045. * Get the texture reflection matrix used to rotate/transform the reflection.
  48046. * @returns the reflection matrix
  48047. */
  48048. getReflectionTextureMatrix(): Matrix;
  48049. /**
  48050. * Resize the texture to a new desired size.
  48051. * Be carrefull as it will recreate all the data in the new texture.
  48052. * @param size Define the new size. It can be:
  48053. * - a number for squared texture,
  48054. * - an object containing { width: number, height: number }
  48055. * - or an object containing a ratio { ratio: number }
  48056. */
  48057. resize(size: number | {
  48058. width: number;
  48059. height: number;
  48060. } | {
  48061. ratio: number;
  48062. }): void;
  48063. /**
  48064. * Renders all the objects from the render list into the texture.
  48065. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  48066. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  48067. */
  48068. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  48069. private _bestReflectionRenderTargetDimension;
  48070. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  48071. private renderToTarget;
  48072. /**
  48073. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  48074. * This allowed control for front to back rendering or reversly depending of the special needs.
  48075. *
  48076. * @param renderingGroupId The rendering group id corresponding to its index
  48077. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  48078. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  48079. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  48080. */
  48081. 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;
  48082. /**
  48083. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  48084. *
  48085. * @param renderingGroupId The rendering group id corresponding to its index
  48086. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  48087. */
  48088. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  48089. /**
  48090. * Clones the texture.
  48091. * @returns the cloned texture
  48092. */
  48093. clone(): RenderTargetTexture;
  48094. /**
  48095. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  48096. * @returns The JSON representation of the texture
  48097. */
  48098. serialize(): any;
  48099. /**
  48100. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  48101. */
  48102. disposeFramebufferObjects(): void;
  48103. /**
  48104. * Dispose the texture and release its associated resources.
  48105. */
  48106. dispose(): void;
  48107. /** @hidden */
  48108. _rebuild(): void;
  48109. /**
  48110. * Clear the info related to rendering groups preventing retention point in material dispose.
  48111. */
  48112. freeRenderingGroups(): void;
  48113. }
  48114. }
  48115. declare module BABYLON {
  48116. /**
  48117. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  48118. * @see http://doc.babylonjs.com/babylon101/materials#texture
  48119. */
  48120. class Texture extends BaseTexture {
  48121. /** nearest is mag = nearest and min = nearest and mip = linear */
  48122. static readonly NEAREST_SAMPLINGMODE: number;
  48123. /** nearest is mag = nearest and min = nearest and mip = linear */
  48124. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  48125. /** Bilinear is mag = linear and min = linear and mip = nearest */
  48126. static readonly BILINEAR_SAMPLINGMODE: number;
  48127. /** Bilinear is mag = linear and min = linear and mip = nearest */
  48128. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  48129. /** Trilinear is mag = linear and min = linear and mip = linear */
  48130. static readonly TRILINEAR_SAMPLINGMODE: number;
  48131. /** Trilinear is mag = linear and min = linear and mip = linear */
  48132. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  48133. /** mag = nearest and min = nearest and mip = nearest */
  48134. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  48135. /** mag = nearest and min = linear and mip = nearest */
  48136. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  48137. /** mag = nearest and min = linear and mip = linear */
  48138. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  48139. /** mag = nearest and min = linear and mip = none */
  48140. static readonly NEAREST_LINEAR: number;
  48141. /** mag = nearest and min = nearest and mip = none */
  48142. static readonly NEAREST_NEAREST: number;
  48143. /** mag = linear and min = nearest and mip = nearest */
  48144. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  48145. /** mag = linear and min = nearest and mip = linear */
  48146. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  48147. /** mag = linear and min = linear and mip = none */
  48148. static readonly LINEAR_LINEAR: number;
  48149. /** mag = linear and min = nearest and mip = none */
  48150. static readonly LINEAR_NEAREST: number;
  48151. /** Explicit coordinates mode */
  48152. static readonly EXPLICIT_MODE: number;
  48153. /** Spherical coordinates mode */
  48154. static readonly SPHERICAL_MODE: number;
  48155. /** Planar coordinates mode */
  48156. static readonly PLANAR_MODE: number;
  48157. /** Cubic coordinates mode */
  48158. static readonly CUBIC_MODE: number;
  48159. /** Projection coordinates mode */
  48160. static readonly PROJECTION_MODE: number;
  48161. /** Inverse Cubic coordinates mode */
  48162. static readonly SKYBOX_MODE: number;
  48163. /** Inverse Cubic coordinates mode */
  48164. static readonly INVCUBIC_MODE: number;
  48165. /** Equirectangular coordinates mode */
  48166. static readonly EQUIRECTANGULAR_MODE: number;
  48167. /** Equirectangular Fixed coordinates mode */
  48168. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  48169. /** Equirectangular Fixed Mirrored coordinates mode */
  48170. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  48171. /** Texture is not repeating outside of 0..1 UVs */
  48172. static readonly CLAMP_ADDRESSMODE: number;
  48173. /** Texture is repeating outside of 0..1 UVs */
  48174. static readonly WRAP_ADDRESSMODE: number;
  48175. /** Texture is repeating and mirrored */
  48176. static readonly MIRROR_ADDRESSMODE: number;
  48177. /**
  48178. * 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
  48179. */
  48180. static UseSerializedUrlIfAny: boolean;
  48181. /**
  48182. * Define the url of the texture.
  48183. */
  48184. url: Nullable<string>;
  48185. /**
  48186. * Define an offset on the texture to offset the u coordinates of the UVs
  48187. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  48188. */
  48189. uOffset: number;
  48190. /**
  48191. * Define an offset on the texture to offset the v coordinates of the UVs
  48192. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  48193. */
  48194. vOffset: number;
  48195. /**
  48196. * Define an offset on the texture to scale the u coordinates of the UVs
  48197. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  48198. */
  48199. uScale: number;
  48200. /**
  48201. * Define an offset on the texture to scale the v coordinates of the UVs
  48202. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  48203. */
  48204. vScale: number;
  48205. /**
  48206. * Define an offset on the texture to rotate around the u coordinates of the UVs
  48207. * @see http://doc.babylonjs.com/how_to/more_materials
  48208. */
  48209. uAng: number;
  48210. /**
  48211. * Define an offset on the texture to rotate around the v coordinates of the UVs
  48212. * @see http://doc.babylonjs.com/how_to/more_materials
  48213. */
  48214. vAng: number;
  48215. /**
  48216. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  48217. * @see http://doc.babylonjs.com/how_to/more_materials
  48218. */
  48219. wAng: number;
  48220. /**
  48221. * Defines the center of rotation (U)
  48222. */
  48223. uRotationCenter: number;
  48224. /**
  48225. * Defines the center of rotation (V)
  48226. */
  48227. vRotationCenter: number;
  48228. /**
  48229. * Defines the center of rotation (W)
  48230. */
  48231. wRotationCenter: number;
  48232. /**
  48233. * Are mip maps generated for this texture or not.
  48234. */
  48235. readonly noMipmap: boolean;
  48236. private _noMipmap;
  48237. /** @hidden */
  48238. _invertY: boolean;
  48239. private _rowGenerationMatrix;
  48240. private _cachedTextureMatrix;
  48241. private _projectionModeMatrix;
  48242. private _t0;
  48243. private _t1;
  48244. private _t2;
  48245. private _cachedUOffset;
  48246. private _cachedVOffset;
  48247. private _cachedUScale;
  48248. private _cachedVScale;
  48249. private _cachedUAng;
  48250. private _cachedVAng;
  48251. private _cachedWAng;
  48252. private _cachedProjectionMatrixId;
  48253. private _cachedCoordinatesMode;
  48254. /** @hidden */
  48255. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  48256. private _deleteBuffer;
  48257. protected _format: Nullable<number>;
  48258. private _delayedOnLoad;
  48259. private _delayedOnError;
  48260. /**
  48261. * Observable triggered once the texture has been loaded.
  48262. */
  48263. onLoadObservable: Observable<Texture>;
  48264. protected _isBlocking: boolean;
  48265. /**
  48266. * Is the texture preventing material to render while loading.
  48267. * If false, a default texture will be used instead of the loading one during the preparation step.
  48268. */
  48269. isBlocking: boolean;
  48270. /**
  48271. * Get the current sampling mode associated with the texture.
  48272. */
  48273. readonly samplingMode: number;
  48274. /**
  48275. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  48276. */
  48277. readonly invertY: boolean;
  48278. /**
  48279. * Instantiates a new texture.
  48280. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  48281. * @see http://doc.babylonjs.com/babylon101/materials#texture
  48282. * @param url define the url of the picture to load as a texture
  48283. * @param scene define the scene the texture will belong to
  48284. * @param noMipmap define if the texture will require mip maps or not
  48285. * @param invertY define if the texture needs to be inverted on the y axis during loading
  48286. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  48287. * @param onLoad define a callback triggered when the texture has been loaded
  48288. * @param onError define a callback triggered when an error occurred during the loading session
  48289. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  48290. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  48291. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  48292. */
  48293. 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);
  48294. /**
  48295. * Update the url (and optional buffer) of this texture if url was null during construction.
  48296. * @param url the url of the texture
  48297. * @param buffer the buffer of the texture (defaults to null)
  48298. * @param onLoad callback called when the texture is loaded (defaults to null)
  48299. */
  48300. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  48301. /**
  48302. * Finish the loading sequence of a texture flagged as delayed load.
  48303. * @hidden
  48304. */
  48305. delayLoad(): void;
  48306. private _prepareRowForTextureGeneration;
  48307. /**
  48308. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  48309. * @returns the transform matrix of the texture.
  48310. */
  48311. getTextureMatrix(): Matrix;
  48312. /**
  48313. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  48314. * @returns The reflection texture transform
  48315. */
  48316. getReflectionTextureMatrix(): Matrix;
  48317. /**
  48318. * Clones the texture.
  48319. * @returns the cloned texture
  48320. */
  48321. clone(): Texture;
  48322. /**
  48323. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  48324. * @returns The JSON representation of the texture
  48325. */
  48326. serialize(): any;
  48327. /**
  48328. * Get the current class name of the texture useful for serialization or dynamic coding.
  48329. * @returns "Texture"
  48330. */
  48331. getClassName(): string;
  48332. /**
  48333. * Dispose the texture and release its associated resources.
  48334. */
  48335. dispose(): void;
  48336. /**
  48337. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  48338. * @param parsedTexture Define the JSON representation of the texture
  48339. * @param scene Define the scene the parsed texture should be instantiated in
  48340. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  48341. * @returns The parsed texture if successful
  48342. */
  48343. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  48344. /**
  48345. * Creates a texture from its base 64 representation.
  48346. * @param data Define the base64 payload without the data: prefix
  48347. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  48348. * @param scene Define the scene the texture should belong to
  48349. * @param noMipmap Forces the texture to not create mip map information if true
  48350. * @param invertY define if the texture needs to be inverted on the y axis during loading
  48351. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  48352. * @param onLoad define a callback triggered when the texture has been loaded
  48353. * @param onError define a callback triggered when an error occurred during the loading session
  48354. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  48355. * @returns the created texture
  48356. */
  48357. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  48358. /**
  48359. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  48360. * @param data Define the base64 payload without the data: prefix
  48361. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  48362. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  48363. * @param scene Define the scene the texture should belong to
  48364. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  48365. * @param noMipmap Forces the texture to not create mip map information if true
  48366. * @param invertY define if the texture needs to be inverted on the y axis during loading
  48367. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  48368. * @param onLoad define a callback triggered when the texture has been loaded
  48369. * @param onError define a callback triggered when an error occurred during the loading session
  48370. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  48371. * @returns the created texture
  48372. */
  48373. 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;
  48374. }
  48375. }
  48376. declare module BABYLON {
  48377. /**
  48378. * Settings for finer control over video usage
  48379. */
  48380. interface VideoTextureSettings {
  48381. /**
  48382. * Applies `autoplay` to video, if specified
  48383. */
  48384. autoPlay?: boolean;
  48385. /**
  48386. * Applies `loop` to video, if specified
  48387. */
  48388. loop?: boolean;
  48389. /**
  48390. * Automatically updates internal texture from video at every frame in the render loop
  48391. */
  48392. autoUpdateTexture: boolean;
  48393. /**
  48394. * Image src displayed during the video loading or until the user interacts with the video.
  48395. */
  48396. poster?: string;
  48397. }
  48398. /**
  48399. * If you want to display a video in your scene, this is the special texture for that.
  48400. * This special texture works similar to other textures, with the exception of a few parameters.
  48401. * @see https://doc.babylonjs.com/how_to/video_texture
  48402. */
  48403. class VideoTexture extends Texture {
  48404. /**
  48405. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  48406. */
  48407. readonly autoUpdateTexture: boolean;
  48408. /**
  48409. * The video instance used by the texture internally
  48410. */
  48411. readonly video: HTMLVideoElement;
  48412. private _onUserActionRequestedObservable;
  48413. /**
  48414. * Event triggerd when a dom action is required by the user to play the video.
  48415. * This happens due to recent changes in browser policies preventing video to auto start.
  48416. */
  48417. readonly onUserActionRequestedObservable: Observable<Texture>;
  48418. private _generateMipMaps;
  48419. private _engine;
  48420. private _stillImageCaptured;
  48421. private _displayingPosterTexture;
  48422. private _settings;
  48423. private _createInternalTextureOnEvent;
  48424. /**
  48425. * Creates a video texture.
  48426. * If you want to display a video in your scene, this is the special texture for that.
  48427. * This special texture works similar to other textures, with the exception of a few parameters.
  48428. * @see https://doc.babylonjs.com/how_to/video_texture
  48429. * @param name optional name, will detect from video source, if not defined
  48430. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  48431. * @param scene is obviously the current scene.
  48432. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  48433. * @param invertY is false by default but can be used to invert video on Y axis
  48434. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  48435. * @param settings allows finer control over video usage
  48436. */
  48437. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  48438. private _getName;
  48439. private _getVideo;
  48440. private _createInternalTexture;
  48441. private reset;
  48442. /**
  48443. * @hidden Internal method to initiate `update`.
  48444. */
  48445. _rebuild(): void;
  48446. /**
  48447. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  48448. */
  48449. update(): void;
  48450. /**
  48451. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  48452. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  48453. */
  48454. updateTexture(isVisible: boolean): void;
  48455. protected _updateInternalTexture: (e?: Event | undefined) => void;
  48456. /**
  48457. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  48458. * @param url New url.
  48459. */
  48460. updateURL(url: string): void;
  48461. /**
  48462. * Dispose the texture and release its associated resources.
  48463. */
  48464. dispose(): void;
  48465. /**
  48466. * Creates a video texture straight from your WebCam video feed.
  48467. * @param scene Define the scene the texture should be created in
  48468. * @param onReady Define a callback to triggered once the texture will be ready
  48469. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  48470. */
  48471. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  48472. minWidth: number;
  48473. maxWidth: number;
  48474. minHeight: number;
  48475. maxHeight: number;
  48476. deviceId: string;
  48477. }): void;
  48478. }
  48479. }
  48480. declare var DracoDecoderModule: any;
  48481. declare var WebAssembly: any;
  48482. declare module BABYLON {
  48483. /**
  48484. * Configuration for Draco compression
  48485. */
  48486. interface IDracoCompressionConfiguration {
  48487. /**
  48488. * Configuration for the decoder.
  48489. */
  48490. decoder?: {
  48491. /**
  48492. * The url to the WebAssembly module.
  48493. */
  48494. wasmUrl?: string;
  48495. /**
  48496. * The url to the WebAssembly binary.
  48497. */
  48498. wasmBinaryUrl?: string;
  48499. /**
  48500. * The url to the fallback JavaScript module.
  48501. */
  48502. fallbackUrl?: string;
  48503. };
  48504. }
  48505. /**
  48506. * Draco compression (https://google.github.io/draco/)
  48507. *
  48508. * This class wraps the Draco module.
  48509. *
  48510. * **Encoder**
  48511. *
  48512. * The encoder is not currently implemented.
  48513. *
  48514. * **Decoder**
  48515. *
  48516. * 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.
  48517. *
  48518. * To update the configuration, use the following code:
  48519. * ```javascript
  48520. * BABYLON.DracoCompression.Configuration = {
  48521. * decoder: {
  48522. * wasmUrl: "<url to the WebAssembly library>",
  48523. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  48524. * fallbackUrl: "<url to the fallback JavaScript library>",
  48525. * }
  48526. * };
  48527. * ```
  48528. *
  48529. * 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.
  48530. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  48531. * Use `BABYLON.DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  48532. *
  48533. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  48534. * ```javascript
  48535. * var dracoCompression = new BABYLON.DracoCompression();
  48536. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  48537. * [BABYLON.VertexBuffer.PositionKind]: 0
  48538. * });
  48539. * ```
  48540. *
  48541. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  48542. */
  48543. class DracoCompression implements IDisposable {
  48544. private static _DecoderModulePromise;
  48545. /**
  48546. * The configuration. Defaults to the following urls:
  48547. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  48548. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  48549. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  48550. */
  48551. static Configuration: IDracoCompressionConfiguration;
  48552. /**
  48553. * Returns true if the decoder is available.
  48554. */
  48555. static readonly DecoderAvailable: boolean;
  48556. /**
  48557. * Constructor
  48558. */
  48559. constructor();
  48560. /**
  48561. * Stop all async operations and release resources.
  48562. */
  48563. dispose(): void;
  48564. /**
  48565. * Decode Draco compressed mesh data to vertex data.
  48566. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  48567. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  48568. * @returns A promise that resolves with the decoded vertex data
  48569. */
  48570. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  48571. [kind: string]: number;
  48572. }): Promise<VertexData>;
  48573. private static _GetDecoderModule;
  48574. private static _LoadScriptAsync;
  48575. private static _LoadFileAsync;
  48576. }
  48577. }
  48578. declare module BABYLON {
  48579. /**
  48580. * AmmoJS Physics plugin
  48581. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48582. * @see https://github.com/kripken/ammo.js/
  48583. */
  48584. class AmmoJSPlugin implements IPhysicsEnginePlugin {
  48585. private _useDeltaForWorldStep;
  48586. /**
  48587. * Reference to the Ammo library
  48588. */
  48589. bjsAMMO: any;
  48590. /**
  48591. * Created ammoJS world which physics bodies are added to
  48592. */
  48593. world: any;
  48594. /**
  48595. * Name of the plugin
  48596. */
  48597. name: string;
  48598. private _timeStep;
  48599. private _fixedTimeStep;
  48600. private _maxSteps;
  48601. private _tmpQuaternion;
  48602. private _tmpAmmoTransform;
  48603. private _tmpAmmoQuaternion;
  48604. private _tmpAmmoConcreteContactResultCallback;
  48605. private _collisionConfiguration;
  48606. private _dispatcher;
  48607. private _overlappingPairCache;
  48608. private _solver;
  48609. private _tmpAmmoVectorA;
  48610. private _tmpAmmoVectorB;
  48611. private _tmpAmmoVectorC;
  48612. private _tmpContactCallbackResult;
  48613. private static readonly DISABLE_COLLISION_FLAG;
  48614. private static readonly KINEMATIC_FLAG;
  48615. private static readonly DISABLE_DEACTIVATION_FLAG;
  48616. /**
  48617. * Initializes the ammoJS plugin
  48618. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  48619. */
  48620. constructor(_useDeltaForWorldStep?: boolean);
  48621. /**
  48622. * Sets the gravity of the physics world (m/(s^2))
  48623. * @param gravity Gravity to set
  48624. */
  48625. setGravity(gravity: Vector3): void;
  48626. /**
  48627. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  48628. * @param timeStep timestep to use in seconds
  48629. */
  48630. setTimeStep(timeStep: number): void;
  48631. /**
  48632. * 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)
  48633. * @param fixedTimeStep fixedTimeStep to use in seconds
  48634. */
  48635. setFixedTimeStep(fixedTimeStep: number): void;
  48636. /**
  48637. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  48638. * @param maxSteps the maximum number of steps by the physics engine per frame
  48639. */
  48640. setMaxSteps(maxSteps: number): void;
  48641. /**
  48642. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  48643. * @returns the current timestep in seconds
  48644. */
  48645. getTimeStep(): number;
  48646. private _isImpostorInContact;
  48647. private _isImpostorPairInContact;
  48648. private _stepSimulation;
  48649. /**
  48650. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  48651. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  48652. * After the step the babylon meshes are set to the position of the physics imposters
  48653. * @param delta amount of time to step forward
  48654. * @param impostors array of imposters to update before/after the step
  48655. */
  48656. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  48657. /**
  48658. * Applies an implulse on the imposter
  48659. * @param impostor imposter to apply impulse
  48660. * @param force amount of force to be applied to the imposter
  48661. * @param contactPoint the location to apply the impulse on the imposter
  48662. */
  48663. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48664. /**
  48665. * Applies a force on the imposter
  48666. * @param impostor imposter to apply force
  48667. * @param force amount of force to be applied to the imposter
  48668. * @param contactPoint the location to apply the force on the imposter
  48669. */
  48670. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48671. /**
  48672. * Creates a physics body using the plugin
  48673. * @param impostor the imposter to create the physics body on
  48674. */
  48675. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48676. /**
  48677. * Removes the physics body from the imposter and disposes of the body's memory
  48678. * @param impostor imposter to remove the physics body from
  48679. */
  48680. removePhysicsBody(impostor: PhysicsImpostor): void;
  48681. /**
  48682. * Generates a joint
  48683. * @param impostorJoint the imposter joint to create the joint with
  48684. */
  48685. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48686. /**
  48687. * Removes a joint
  48688. * @param impostorJoint the imposter joint to remove the joint from
  48689. */
  48690. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48691. private _addMeshVerts;
  48692. private _createShape;
  48693. /**
  48694. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  48695. * @param impostor imposter containing the physics body and babylon object
  48696. */
  48697. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48698. /**
  48699. * Sets the babylon object's position/rotation from the physics body's position/rotation
  48700. * @param impostor imposter containing the physics body and babylon object
  48701. * @param newPosition new position
  48702. * @param newRotation new rotation
  48703. */
  48704. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48705. /**
  48706. * If this plugin is supported
  48707. * @returns true if its supported
  48708. */
  48709. isSupported(): boolean;
  48710. /**
  48711. * Sets the linear velocity of the physics body
  48712. * @param impostor imposter to set the velocity on
  48713. * @param velocity velocity to set
  48714. */
  48715. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48716. /**
  48717. * Sets the angular velocity of the physics body
  48718. * @param impostor imposter to set the velocity on
  48719. * @param velocity velocity to set
  48720. */
  48721. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48722. /**
  48723. * gets the linear velocity
  48724. * @param impostor imposter to get linear velocity from
  48725. * @returns linear velocity
  48726. */
  48727. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48728. /**
  48729. * gets the angular velocity
  48730. * @param impostor imposter to get angular velocity from
  48731. * @returns angular velocity
  48732. */
  48733. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48734. /**
  48735. * Sets the mass of physics body
  48736. * @param impostor imposter to set the mass on
  48737. * @param mass mass to set
  48738. */
  48739. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48740. /**
  48741. * Gets the mass of the physics body
  48742. * @param impostor imposter to get the mass from
  48743. * @returns mass
  48744. */
  48745. getBodyMass(impostor: PhysicsImpostor): number;
  48746. /**
  48747. * Gets friction of the impostor
  48748. * @param impostor impostor to get friction from
  48749. * @returns friction value
  48750. */
  48751. getBodyFriction(impostor: PhysicsImpostor): number;
  48752. /**
  48753. * Sets friction of the impostor
  48754. * @param impostor impostor to set friction on
  48755. * @param friction friction value
  48756. */
  48757. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48758. /**
  48759. * Gets restitution of the impostor
  48760. * @param impostor impostor to get restitution from
  48761. * @returns restitution value
  48762. */
  48763. getBodyRestitution(impostor: PhysicsImpostor): number;
  48764. /**
  48765. * Sets resitution of the impostor
  48766. * @param impostor impostor to set resitution on
  48767. * @param restitution resitution value
  48768. */
  48769. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48770. /**
  48771. * Sleeps the physics body and stops it from being active
  48772. * @param impostor impostor to sleep
  48773. */
  48774. sleepBody(impostor: PhysicsImpostor): void;
  48775. /**
  48776. * Activates the physics body
  48777. * @param impostor impostor to activate
  48778. */
  48779. wakeUpBody(impostor: PhysicsImpostor): void;
  48780. /**
  48781. * Updates the distance parameters of the joint
  48782. * @param joint joint to update
  48783. * @param maxDistance maximum distance of the joint
  48784. * @param minDistance minimum distance of the joint
  48785. */
  48786. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  48787. /**
  48788. * Sets a motor on the joint
  48789. * @param joint joint to set motor on
  48790. * @param speed speed of the motor
  48791. * @param maxForce maximum force of the motor
  48792. * @param motorIndex index of the motor
  48793. */
  48794. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  48795. /**
  48796. * Sets the motors limit
  48797. * @param joint joint to set limit on
  48798. * @param upperLimit upper limit
  48799. * @param lowerLimit lower limit
  48800. */
  48801. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  48802. /**
  48803. * Syncs the position and rotation of a mesh with the impostor
  48804. * @param mesh mesh to sync
  48805. * @param impostor impostor to update the mesh with
  48806. */
  48807. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48808. /**
  48809. * Gets the radius of the impostor
  48810. * @param impostor impostor to get radius from
  48811. * @returns the radius
  48812. */
  48813. getRadius(impostor: PhysicsImpostor): number;
  48814. /**
  48815. * Gets the box size of the impostor
  48816. * @param impostor impostor to get box size from
  48817. * @param result the resulting box size
  48818. */
  48819. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48820. /**
  48821. * Disposes of the impostor
  48822. */
  48823. dispose(): void;
  48824. }
  48825. }
  48826. declare module BABYLON {
  48827. /** @hidden */
  48828. class CannonJSPlugin implements IPhysicsEnginePlugin {
  48829. private _useDeltaForWorldStep;
  48830. world: any;
  48831. name: string;
  48832. private _physicsMaterials;
  48833. private _fixedTimeStep;
  48834. BJSCANNON: any;
  48835. constructor(_useDeltaForWorldStep?: boolean, iterations?: number);
  48836. setGravity(gravity: Vector3): void;
  48837. setTimeStep(timeStep: number): void;
  48838. getTimeStep(): number;
  48839. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  48840. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48841. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48842. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48843. private _processChildMeshes;
  48844. removePhysicsBody(impostor: PhysicsImpostor): void;
  48845. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48846. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48847. private _addMaterial;
  48848. private _checkWithEpsilon;
  48849. private _createShape;
  48850. private _createHeightmap;
  48851. private _minus90X;
  48852. private _plus90X;
  48853. private _tmpPosition;
  48854. private _tmpDeltaPosition;
  48855. private _tmpUnityRotation;
  48856. private _updatePhysicsBodyTransformation;
  48857. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48858. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48859. isSupported(): boolean;
  48860. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48861. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48862. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48863. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48864. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48865. getBodyMass(impostor: PhysicsImpostor): number;
  48866. getBodyFriction(impostor: PhysicsImpostor): number;
  48867. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48868. getBodyRestitution(impostor: PhysicsImpostor): number;
  48869. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48870. sleepBody(impostor: PhysicsImpostor): void;
  48871. wakeUpBody(impostor: PhysicsImpostor): void;
  48872. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  48873. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  48874. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  48875. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48876. getRadius(impostor: PhysicsImpostor): number;
  48877. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48878. dispose(): void;
  48879. private _extendNamespace;
  48880. }
  48881. }
  48882. declare module BABYLON {
  48883. /** @hidden */
  48884. class OimoJSPlugin implements IPhysicsEnginePlugin {
  48885. world: any;
  48886. name: string;
  48887. BJSOIMO: any;
  48888. constructor(iterations?: number);
  48889. setGravity(gravity: Vector3): void;
  48890. setTimeStep(timeStep: number): void;
  48891. getTimeStep(): number;
  48892. private _tmpImpostorsArray;
  48893. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  48894. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48895. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48896. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48897. private _tmpPositionVector;
  48898. removePhysicsBody(impostor: PhysicsImpostor): void;
  48899. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48900. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48901. isSupported(): boolean;
  48902. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48903. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48904. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48905. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48906. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48907. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48908. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48909. getBodyMass(impostor: PhysicsImpostor): number;
  48910. getBodyFriction(impostor: PhysicsImpostor): number;
  48911. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48912. getBodyRestitution(impostor: PhysicsImpostor): number;
  48913. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48914. sleepBody(impostor: PhysicsImpostor): void;
  48915. wakeUpBody(impostor: PhysicsImpostor): void;
  48916. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  48917. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  48918. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  48919. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48920. getRadius(impostor: PhysicsImpostor): number;
  48921. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48922. dispose(): void;
  48923. }
  48924. }
  48925. declare module BABYLON {
  48926. /**
  48927. * Particle emitter emitting particles from the inside of a box.
  48928. * It emits the particles randomly between 2 given directions.
  48929. */
  48930. class BoxParticleEmitter implements IParticleEmitterType {
  48931. /**
  48932. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  48933. */
  48934. direction1: Vector3;
  48935. /**
  48936. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  48937. */
  48938. direction2: Vector3;
  48939. /**
  48940. * 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.
  48941. */
  48942. minEmitBox: Vector3;
  48943. /**
  48944. * 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.
  48945. */
  48946. maxEmitBox: Vector3;
  48947. /**
  48948. * Creates a new instance BoxParticleEmitter
  48949. */
  48950. constructor();
  48951. /**
  48952. * Called by the particle System when the direction is computed for the created particle.
  48953. * @param worldMatrix is the world matrix of the particle system
  48954. * @param directionToUpdate is the direction vector to update with the result
  48955. * @param particle is the particle we are computed the direction for
  48956. */
  48957. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48958. /**
  48959. * Called by the particle System when the position is computed for the created particle.
  48960. * @param worldMatrix is the world matrix of the particle system
  48961. * @param positionToUpdate is the position vector to update with the result
  48962. * @param particle is the particle we are computed the position for
  48963. */
  48964. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48965. /**
  48966. * Clones the current emitter and returns a copy of it
  48967. * @returns the new emitter
  48968. */
  48969. clone(): BoxParticleEmitter;
  48970. /**
  48971. * Called by the GPUParticleSystem to setup the update shader
  48972. * @param effect defines the update shader
  48973. */
  48974. applyToShader(effect: Effect): void;
  48975. /**
  48976. * Returns a string to use to update the GPU particles update shader
  48977. * @returns a string containng the defines string
  48978. */
  48979. getEffectDefines(): string;
  48980. /**
  48981. * Returns the string "BoxParticleEmitter"
  48982. * @returns a string containing the class name
  48983. */
  48984. getClassName(): string;
  48985. /**
  48986. * Serializes the particle system to a JSON object.
  48987. * @returns the JSON object
  48988. */
  48989. serialize(): any;
  48990. /**
  48991. * Parse properties from a JSON object
  48992. * @param serializationObject defines the JSON object
  48993. */
  48994. parse(serializationObject: any): void;
  48995. }
  48996. }
  48997. declare module BABYLON {
  48998. /**
  48999. * Particle emitter emitting particles from the inside of a cone.
  49000. * It emits the particles alongside the cone volume from the base to the particle.
  49001. * The emission direction might be randomized.
  49002. */
  49003. class ConeParticleEmitter implements IParticleEmitterType {
  49004. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  49005. directionRandomizer: number;
  49006. private _radius;
  49007. private _angle;
  49008. private _height;
  49009. /**
  49010. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  49011. */
  49012. radiusRange: number;
  49013. /**
  49014. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  49015. */
  49016. heightRange: number;
  49017. /**
  49018. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  49019. */
  49020. emitFromSpawnPointOnly: boolean;
  49021. /**
  49022. * Gets or sets the radius of the emission cone
  49023. */
  49024. radius: number;
  49025. /**
  49026. * Gets or sets the angle of the emission cone
  49027. */
  49028. angle: number;
  49029. private _buildHeight;
  49030. /**
  49031. * Creates a new instance ConeParticleEmitter
  49032. * @param radius the radius of the emission cone (1 by default)
  49033. * @param angles the cone base angle (PI by default)
  49034. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  49035. */
  49036. constructor(radius?: number, angle?: number,
  49037. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  49038. directionRandomizer?: number);
  49039. /**
  49040. * Called by the particle System when the direction is computed for the created particle.
  49041. * @param worldMatrix is the world matrix of the particle system
  49042. * @param directionToUpdate is the direction vector to update with the result
  49043. * @param particle is the particle we are computed the direction for
  49044. */
  49045. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  49046. /**
  49047. * Called by the particle System when the position is computed for the created particle.
  49048. * @param worldMatrix is the world matrix of the particle system
  49049. * @param positionToUpdate is the position vector to update with the result
  49050. * @param particle is the particle we are computed the position for
  49051. */
  49052. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  49053. /**
  49054. * Clones the current emitter and returns a copy of it
  49055. * @returns the new emitter
  49056. */
  49057. clone(): ConeParticleEmitter;
  49058. /**
  49059. * Called by the GPUParticleSystem to setup the update shader
  49060. * @param effect defines the update shader
  49061. */
  49062. applyToShader(effect: Effect): void;
  49063. /**
  49064. * Returns a string to use to update the GPU particles update shader
  49065. * @returns a string containng the defines string
  49066. */
  49067. getEffectDefines(): string;
  49068. /**
  49069. * Returns the string "ConeParticleEmitter"
  49070. * @returns a string containing the class name
  49071. */
  49072. getClassName(): string;
  49073. /**
  49074. * Serializes the particle system to a JSON object.
  49075. * @returns the JSON object
  49076. */
  49077. serialize(): any;
  49078. /**
  49079. * Parse properties from a JSON object
  49080. * @param serializationObject defines the JSON object
  49081. */
  49082. parse(serializationObject: any): void;
  49083. }
  49084. }
  49085. declare module BABYLON {
  49086. /**
  49087. * Particle emitter emitting particles from the inside of a cylinder.
  49088. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  49089. */
  49090. class CylinderParticleEmitter implements IParticleEmitterType {
  49091. /**
  49092. * The radius of the emission cylinder.
  49093. */
  49094. radius: number;
  49095. /**
  49096. * The height of the emission cylinder.
  49097. */
  49098. height: number;
  49099. /**
  49100. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  49101. */
  49102. radiusRange: number;
  49103. /**
  49104. * How much to randomize the particle direction [0-1].
  49105. */
  49106. directionRandomizer: number;
  49107. /**
  49108. * Creates a new instance CylinderParticleEmitter
  49109. * @param radius the radius of the emission cylinder (1 by default)
  49110. * @param height the height of the emission cylinder (1 by default)
  49111. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  49112. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  49113. */
  49114. constructor(
  49115. /**
  49116. * The radius of the emission cylinder.
  49117. */
  49118. radius?: number,
  49119. /**
  49120. * The height of the emission cylinder.
  49121. */
  49122. height?: number,
  49123. /**
  49124. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  49125. */
  49126. radiusRange?: number,
  49127. /**
  49128. * How much to randomize the particle direction [0-1].
  49129. */
  49130. directionRandomizer?: number);
  49131. /**
  49132. * Called by the particle System when the direction is computed for the created particle.
  49133. * @param worldMatrix is the world matrix of the particle system
  49134. * @param directionToUpdate is the direction vector to update with the result
  49135. * @param particle is the particle we are computed the direction for
  49136. */
  49137. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  49138. /**
  49139. * Called by the particle System when the position is computed for the created particle.
  49140. * @param worldMatrix is the world matrix of the particle system
  49141. * @param positionToUpdate is the position vector to update with the result
  49142. * @param particle is the particle we are computed the position for
  49143. */
  49144. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  49145. /**
  49146. * Clones the current emitter and returns a copy of it
  49147. * @returns the new emitter
  49148. */
  49149. clone(): CylinderParticleEmitter;
  49150. /**
  49151. * Called by the GPUParticleSystem to setup the update shader
  49152. * @param effect defines the update shader
  49153. */
  49154. applyToShader(effect: Effect): void;
  49155. /**
  49156. * Returns a string to use to update the GPU particles update shader
  49157. * @returns a string containng the defines string
  49158. */
  49159. getEffectDefines(): string;
  49160. /**
  49161. * Returns the string "CylinderParticleEmitter"
  49162. * @returns a string containing the class name
  49163. */
  49164. getClassName(): string;
  49165. /**
  49166. * Serializes the particle system to a JSON object.
  49167. * @returns the JSON object
  49168. */
  49169. serialize(): any;
  49170. /**
  49171. * Parse properties from a JSON object
  49172. * @param serializationObject defines the JSON object
  49173. */
  49174. parse(serializationObject: any): void;
  49175. }
  49176. /**
  49177. * Particle emitter emitting particles from the inside of a cylinder.
  49178. * It emits the particles randomly between two vectors.
  49179. */
  49180. class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  49181. /**
  49182. * The min limit of the emission direction.
  49183. */
  49184. direction1: Vector3;
  49185. /**
  49186. * The max limit of the emission direction.
  49187. */
  49188. direction2: Vector3;
  49189. /**
  49190. * Creates a new instance CylinderDirectedParticleEmitter
  49191. * @param radius the radius of the emission cylinder (1 by default)
  49192. * @param height the height of the emission cylinder (1 by default)
  49193. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  49194. * @param direction1 the min limit of the emission direction (up vector by default)
  49195. * @param direction2 the max limit of the emission direction (up vector by default)
  49196. */
  49197. constructor(radius?: number, height?: number, radiusRange?: number,
  49198. /**
  49199. * The min limit of the emission direction.
  49200. */
  49201. direction1?: Vector3,
  49202. /**
  49203. * The max limit of the emission direction.
  49204. */
  49205. direction2?: Vector3);
  49206. /**
  49207. * Called by the particle System when the direction is computed for the created particle.
  49208. * @param worldMatrix is the world matrix of the particle system
  49209. * @param directionToUpdate is the direction vector to update with the result
  49210. * @param particle is the particle we are computed the direction for
  49211. */
  49212. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  49213. /**
  49214. * Clones the current emitter and returns a copy of it
  49215. * @returns the new emitter
  49216. */
  49217. clone(): CylinderDirectedParticleEmitter;
  49218. /**
  49219. * Called by the GPUParticleSystem to setup the update shader
  49220. * @param effect defines the update shader
  49221. */
  49222. applyToShader(effect: Effect): void;
  49223. /**
  49224. * Returns a string to use to update the GPU particles update shader
  49225. * @returns a string containng the defines string
  49226. */
  49227. getEffectDefines(): string;
  49228. /**
  49229. * Returns the string "CylinderDirectedParticleEmitter"
  49230. * @returns a string containing the class name
  49231. */
  49232. getClassName(): string;
  49233. /**
  49234. * Serializes the particle system to a JSON object.
  49235. * @returns the JSON object
  49236. */
  49237. serialize(): any;
  49238. /**
  49239. * Parse properties from a JSON object
  49240. * @param serializationObject defines the JSON object
  49241. */
  49242. parse(serializationObject: any): void;
  49243. }
  49244. }
  49245. declare module BABYLON {
  49246. /**
  49247. * Particle emitter emitting particles from the inside of a hemisphere.
  49248. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  49249. */
  49250. class HemisphericParticleEmitter implements IParticleEmitterType {
  49251. /**
  49252. * The radius of the emission hemisphere.
  49253. */
  49254. radius: number;
  49255. /**
  49256. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  49257. */
  49258. radiusRange: number;
  49259. /**
  49260. * How much to randomize the particle direction [0-1].
  49261. */
  49262. directionRandomizer: number;
  49263. /**
  49264. * Creates a new instance HemisphericParticleEmitter
  49265. * @param radius the radius of the emission hemisphere (1 by default)
  49266. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  49267. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  49268. */
  49269. constructor(
  49270. /**
  49271. * The radius of the emission hemisphere.
  49272. */
  49273. radius?: number,
  49274. /**
  49275. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  49276. */
  49277. radiusRange?: number,
  49278. /**
  49279. * How much to randomize the particle direction [0-1].
  49280. */
  49281. directionRandomizer?: number);
  49282. /**
  49283. * Called by the particle System when the direction is computed for the created particle.
  49284. * @param worldMatrix is the world matrix of the particle system
  49285. * @param directionToUpdate is the direction vector to update with the result
  49286. * @param particle is the particle we are computed the direction for
  49287. */
  49288. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  49289. /**
  49290. * Called by the particle System when the position is computed for the created particle.
  49291. * @param worldMatrix is the world matrix of the particle system
  49292. * @param positionToUpdate is the position vector to update with the result
  49293. * @param particle is the particle we are computed the position for
  49294. */
  49295. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  49296. /**
  49297. * Clones the current emitter and returns a copy of it
  49298. * @returns the new emitter
  49299. */
  49300. clone(): HemisphericParticleEmitter;
  49301. /**
  49302. * Called by the GPUParticleSystem to setup the update shader
  49303. * @param effect defines the update shader
  49304. */
  49305. applyToShader(effect: Effect): void;
  49306. /**
  49307. * Returns a string to use to update the GPU particles update shader
  49308. * @returns a string containng the defines string
  49309. */
  49310. getEffectDefines(): string;
  49311. /**
  49312. * Returns the string "HemisphericParticleEmitter"
  49313. * @returns a string containing the class name
  49314. */
  49315. getClassName(): string;
  49316. /**
  49317. * Serializes the particle system to a JSON object.
  49318. * @returns the JSON object
  49319. */
  49320. serialize(): any;
  49321. /**
  49322. * Parse properties from a JSON object
  49323. * @param serializationObject defines the JSON object
  49324. */
  49325. parse(serializationObject: any): void;
  49326. }
  49327. }
  49328. declare module BABYLON {
  49329. /**
  49330. * Particle emitter represents a volume emitting particles.
  49331. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  49332. */
  49333. interface IParticleEmitterType {
  49334. /**
  49335. * Called by the particle System when the direction is computed for the created particle.
  49336. * @param worldMatrix is the world matrix of the particle system
  49337. * @param directionToUpdate is the direction vector to update with the result
  49338. * @param particle is the particle we are computed the direction for
  49339. */
  49340. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  49341. /**
  49342. * Called by the particle System when the position is computed for the created particle.
  49343. * @param worldMatrix is the world matrix of the particle system
  49344. * @param positionToUpdate is the position vector to update with the result
  49345. * @param particle is the particle we are computed the position for
  49346. */
  49347. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  49348. /**
  49349. * Clones the current emitter and returns a copy of it
  49350. * @returns the new emitter
  49351. */
  49352. clone(): IParticleEmitterType;
  49353. /**
  49354. * Called by the GPUParticleSystem to setup the update shader
  49355. * @param effect defines the update shader
  49356. */
  49357. applyToShader(effect: Effect): void;
  49358. /**
  49359. * Returns a string to use to update the GPU particles update shader
  49360. * @returns the effect defines string
  49361. */
  49362. getEffectDefines(): string;
  49363. /**
  49364. * Returns a string representing the class name
  49365. * @returns a string containing the class name
  49366. */
  49367. getClassName(): string;
  49368. /**
  49369. * Serializes the particle system to a JSON object.
  49370. * @returns the JSON object
  49371. */
  49372. serialize(): any;
  49373. /**
  49374. * Parse properties from a JSON object
  49375. * @param serializationObject defines the JSON object
  49376. */
  49377. parse(serializationObject: any): void;
  49378. }
  49379. }
  49380. declare module BABYLON {
  49381. /**
  49382. * Particle emitter emitting particles from a point.
  49383. * It emits the particles randomly between 2 given directions.
  49384. */
  49385. class PointParticleEmitter implements IParticleEmitterType {
  49386. /**
  49387. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  49388. */
  49389. direction1: Vector3;
  49390. /**
  49391. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  49392. */
  49393. direction2: Vector3;
  49394. /**
  49395. * Creates a new instance PointParticleEmitter
  49396. */
  49397. constructor();
  49398. /**
  49399. * Called by the particle System when the direction is computed for the created particle.
  49400. * @param worldMatrix is the world matrix of the particle system
  49401. * @param directionToUpdate is the direction vector to update with the result
  49402. * @param particle is the particle we are computed the direction for
  49403. */
  49404. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  49405. /**
  49406. * Called by the particle System when the position is computed for the created particle.
  49407. * @param worldMatrix is the world matrix of the particle system
  49408. * @param positionToUpdate is the position vector to update with the result
  49409. * @param particle is the particle we are computed the position for
  49410. */
  49411. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  49412. /**
  49413. * Clones the current emitter and returns a copy of it
  49414. * @returns the new emitter
  49415. */
  49416. clone(): PointParticleEmitter;
  49417. /**
  49418. * Called by the GPUParticleSystem to setup the update shader
  49419. * @param effect defines the update shader
  49420. */
  49421. applyToShader(effect: Effect): void;
  49422. /**
  49423. * Returns a string to use to update the GPU particles update shader
  49424. * @returns a string containng the defines string
  49425. */
  49426. getEffectDefines(): string;
  49427. /**
  49428. * Returns the string "PointParticleEmitter"
  49429. * @returns a string containing the class name
  49430. */
  49431. getClassName(): string;
  49432. /**
  49433. * Serializes the particle system to a JSON object.
  49434. * @returns the JSON object
  49435. */
  49436. serialize(): any;
  49437. /**
  49438. * Parse properties from a JSON object
  49439. * @param serializationObject defines the JSON object
  49440. */
  49441. parse(serializationObject: any): void;
  49442. }
  49443. }
  49444. declare module BABYLON {
  49445. /**
  49446. * Particle emitter emitting particles from the inside of a sphere.
  49447. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  49448. */
  49449. class SphereParticleEmitter implements IParticleEmitterType {
  49450. /**
  49451. * The radius of the emission sphere.
  49452. */
  49453. radius: number;
  49454. /**
  49455. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  49456. */
  49457. radiusRange: number;
  49458. /**
  49459. * How much to randomize the particle direction [0-1].
  49460. */
  49461. directionRandomizer: number;
  49462. /**
  49463. * Creates a new instance SphereParticleEmitter
  49464. * @param radius the radius of the emission sphere (1 by default)
  49465. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  49466. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  49467. */
  49468. constructor(
  49469. /**
  49470. * The radius of the emission sphere.
  49471. */
  49472. radius?: number,
  49473. /**
  49474. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  49475. */
  49476. radiusRange?: number,
  49477. /**
  49478. * How much to randomize the particle direction [0-1].
  49479. */
  49480. directionRandomizer?: number);
  49481. /**
  49482. * Called by the particle System when the direction is computed for the created particle.
  49483. * @param worldMatrix is the world matrix of the particle system
  49484. * @param directionToUpdate is the direction vector to update with the result
  49485. * @param particle is the particle we are computed the direction for
  49486. */
  49487. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  49488. /**
  49489. * Called by the particle System when the position is computed for the created particle.
  49490. * @param worldMatrix is the world matrix of the particle system
  49491. * @param positionToUpdate is the position vector to update with the result
  49492. * @param particle is the particle we are computed the position for
  49493. */
  49494. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  49495. /**
  49496. * Clones the current emitter and returns a copy of it
  49497. * @returns the new emitter
  49498. */
  49499. clone(): SphereParticleEmitter;
  49500. /**
  49501. * Called by the GPUParticleSystem to setup the update shader
  49502. * @param effect defines the update shader
  49503. */
  49504. applyToShader(effect: Effect): void;
  49505. /**
  49506. * Returns a string to use to update the GPU particles update shader
  49507. * @returns a string containng the defines string
  49508. */
  49509. getEffectDefines(): string;
  49510. /**
  49511. * Returns the string "SphereParticleEmitter"
  49512. * @returns a string containing the class name
  49513. */
  49514. getClassName(): string;
  49515. /**
  49516. * Serializes the particle system to a JSON object.
  49517. * @returns the JSON object
  49518. */
  49519. serialize(): any;
  49520. /**
  49521. * Parse properties from a JSON object
  49522. * @param serializationObject defines the JSON object
  49523. */
  49524. parse(serializationObject: any): void;
  49525. }
  49526. /**
  49527. * Particle emitter emitting particles from the inside of a sphere.
  49528. * It emits the particles randomly between two vectors.
  49529. */
  49530. class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  49531. /**
  49532. * The min limit of the emission direction.
  49533. */
  49534. direction1: Vector3;
  49535. /**
  49536. * The max limit of the emission direction.
  49537. */
  49538. direction2: Vector3;
  49539. /**
  49540. * Creates a new instance SphereDirectedParticleEmitter
  49541. * @param radius the radius of the emission sphere (1 by default)
  49542. * @param direction1 the min limit of the emission direction (up vector by default)
  49543. * @param direction2 the max limit of the emission direction (up vector by default)
  49544. */
  49545. constructor(radius?: number,
  49546. /**
  49547. * The min limit of the emission direction.
  49548. */
  49549. direction1?: Vector3,
  49550. /**
  49551. * The max limit of the emission direction.
  49552. */
  49553. direction2?: Vector3);
  49554. /**
  49555. * Called by the particle System when the direction is computed for the created particle.
  49556. * @param worldMatrix is the world matrix of the particle system
  49557. * @param directionToUpdate is the direction vector to update with the result
  49558. * @param particle is the particle we are computed the direction for
  49559. */
  49560. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  49561. /**
  49562. * Clones the current emitter and returns a copy of it
  49563. * @returns the new emitter
  49564. */
  49565. clone(): SphereDirectedParticleEmitter;
  49566. /**
  49567. * Called by the GPUParticleSystem to setup the update shader
  49568. * @param effect defines the update shader
  49569. */
  49570. applyToShader(effect: Effect): void;
  49571. /**
  49572. * Returns a string to use to update the GPU particles update shader
  49573. * @returns a string containng the defines string
  49574. */
  49575. getEffectDefines(): string;
  49576. /**
  49577. * Returns the string "SphereDirectedParticleEmitter"
  49578. * @returns a string containing the class name
  49579. */
  49580. getClassName(): string;
  49581. /**
  49582. * Serializes the particle system to a JSON object.
  49583. * @returns the JSON object
  49584. */
  49585. serialize(): any;
  49586. /**
  49587. * Parse properties from a JSON object
  49588. * @param serializationObject defines the JSON object
  49589. */
  49590. parse(serializationObject: any): void;
  49591. }
  49592. }
  49593. declare module BABYLON {
  49594. /**
  49595. * This represents a set of one or more post processes in Babylon.
  49596. * A post process can be used to apply a shader to a texture after it is rendered.
  49597. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  49598. */
  49599. class PostProcessRenderEffect {
  49600. private _postProcesses;
  49601. private _getPostProcesses;
  49602. private _singleInstance;
  49603. private _cameras;
  49604. private _indicesForCamera;
  49605. /**
  49606. * Name of the effect
  49607. * @hidden
  49608. */
  49609. _name: string;
  49610. /**
  49611. * Instantiates a post process render effect.
  49612. * A post process can be used to apply a shader to a texture after it is rendered.
  49613. * @param engine The engine the effect is tied to
  49614. * @param name The name of the effect
  49615. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  49616. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  49617. */
  49618. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  49619. /**
  49620. * Checks if all the post processes in the effect are supported.
  49621. */
  49622. readonly isSupported: boolean;
  49623. /**
  49624. * Updates the current state of the effect
  49625. * @hidden
  49626. */
  49627. _update(): void;
  49628. /**
  49629. * Attaches the effect on cameras
  49630. * @param cameras The camera to attach to.
  49631. * @hidden
  49632. */
  49633. _attachCameras(cameras: Camera): void;
  49634. /**
  49635. * Attaches the effect on cameras
  49636. * @param cameras The camera to attach to.
  49637. * @hidden
  49638. */
  49639. _attachCameras(cameras: Camera[]): void;
  49640. /**
  49641. * Detatches the effect on cameras
  49642. * @param cameras The camera to detatch from.
  49643. * @hidden
  49644. */
  49645. _detachCameras(cameras: Camera): void;
  49646. /**
  49647. * Detatches the effect on cameras
  49648. * @param cameras The camera to detatch from.
  49649. * @hidden
  49650. */
  49651. _detachCameras(cameras: Camera[]): void;
  49652. /**
  49653. * Enables the effect on given cameras
  49654. * @param cameras The camera to enable.
  49655. * @hidden
  49656. */
  49657. _enable(cameras: Camera): void;
  49658. /**
  49659. * Enables the effect on given cameras
  49660. * @param cameras The camera to enable.
  49661. * @hidden
  49662. */
  49663. _enable(cameras: Nullable<Camera[]>): void;
  49664. /**
  49665. * Disables the effect on the given cameras
  49666. * @param cameras The camera to disable.
  49667. * @hidden
  49668. */
  49669. _disable(cameras: Camera): void;
  49670. /**
  49671. * Disables the effect on the given cameras
  49672. * @param cameras The camera to disable.
  49673. * @hidden
  49674. */
  49675. _disable(cameras: Nullable<Camera[]>): void;
  49676. /**
  49677. * Gets a list of the post processes contained in the effect.
  49678. * @param camera The camera to get the post processes on.
  49679. * @returns The list of the post processes in the effect.
  49680. */
  49681. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  49682. }
  49683. }
  49684. declare module BABYLON {
  49685. /**
  49686. * PostProcessRenderPipeline
  49687. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  49688. */
  49689. class PostProcessRenderPipeline {
  49690. private engine;
  49691. private _renderEffects;
  49692. private _renderEffectsForIsolatedPass;
  49693. /**
  49694. * @hidden
  49695. */
  49696. protected _cameras: Camera[];
  49697. /** @hidden */
  49698. _name: string;
  49699. /**
  49700. * Initializes a PostProcessRenderPipeline
  49701. * @param engine engine to add the pipeline to
  49702. * @param name name of the pipeline
  49703. */
  49704. constructor(engine: Engine, name: string);
  49705. /**
  49706. * "PostProcessRenderPipeline"
  49707. * @returns "PostProcessRenderPipeline"
  49708. */
  49709. getClassName(): string;
  49710. /**
  49711. * If all the render effects in the pipeline are support
  49712. */
  49713. readonly isSupported: boolean;
  49714. /**
  49715. * Adds an effect to the pipeline
  49716. * @param renderEffect the effect to add
  49717. */
  49718. addEffect(renderEffect: PostProcessRenderEffect): void;
  49719. /** @hidden */
  49720. _rebuild(): void;
  49721. /** @hidden */
  49722. _enableEffect(renderEffectName: string, cameras: Camera): void;
  49723. /** @hidden */
  49724. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  49725. /** @hidden */
  49726. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  49727. /** @hidden */
  49728. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  49729. /** @hidden */
  49730. _attachCameras(cameras: Camera, unique: boolean): void;
  49731. /** @hidden */
  49732. _attachCameras(cameras: Camera[], unique: boolean): void;
  49733. /** @hidden */
  49734. _detachCameras(cameras: Camera): void;
  49735. /** @hidden */
  49736. _detachCameras(cameras: Nullable<Camera[]>): void;
  49737. /** @hidden */
  49738. _update(): void;
  49739. /** @hidden */
  49740. _reset(): void;
  49741. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  49742. /**
  49743. * Disposes of the pipeline
  49744. */
  49745. dispose(): void;
  49746. }
  49747. }
  49748. declare module BABYLON {
  49749. /**
  49750. * PostProcessRenderPipelineManager class
  49751. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  49752. */
  49753. class PostProcessRenderPipelineManager {
  49754. private _renderPipelines;
  49755. /**
  49756. * Initializes a PostProcessRenderPipelineManager
  49757. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  49758. */
  49759. constructor();
  49760. /**
  49761. * Adds a pipeline to the manager
  49762. * @param renderPipeline The pipeline to add
  49763. */
  49764. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  49765. /**
  49766. * Attaches a camera to the pipeline
  49767. * @param renderPipelineName The name of the pipeline to attach to
  49768. * @param cameras the camera to attach
  49769. * @param unique if the camera can be attached multiple times to the pipeline
  49770. */
  49771. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  49772. /**
  49773. * Detaches a camera from the pipeline
  49774. * @param renderPipelineName The name of the pipeline to detach from
  49775. * @param cameras the camera to detach
  49776. */
  49777. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  49778. /**
  49779. * Enables an effect by name on a pipeline
  49780. * @param renderPipelineName the name of the pipeline to enable the effect in
  49781. * @param renderEffectName the name of the effect to enable
  49782. * @param cameras the cameras that the effect should be enabled on
  49783. */
  49784. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  49785. /**
  49786. * Disables an effect by name on a pipeline
  49787. * @param renderPipelineName the name of the pipeline to disable the effect in
  49788. * @param renderEffectName the name of the effect to disable
  49789. * @param cameras the cameras that the effect should be disabled on
  49790. */
  49791. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  49792. /**
  49793. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  49794. */
  49795. update(): void;
  49796. /** @hidden */
  49797. _rebuild(): void;
  49798. /**
  49799. * Disposes of the manager and pipelines
  49800. */
  49801. dispose(): void;
  49802. }
  49803. }
  49804. declare module BABYLON {
  49805. interface Scene {
  49806. /** @hidden (Backing field) */
  49807. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  49808. /**
  49809. * Gets the postprocess render pipeline manager
  49810. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  49811. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  49812. */
  49813. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  49814. }
  49815. /**
  49816. * Defines the Render Pipeline scene component responsible to rendering pipelines
  49817. */
  49818. class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  49819. /**
  49820. * The component name helpfull to identify the component in the list of scene components.
  49821. */
  49822. readonly name: string;
  49823. /**
  49824. * The scene the component belongs to.
  49825. */
  49826. scene: Scene;
  49827. /**
  49828. * Creates a new instance of the component for the given scene
  49829. * @param scene Defines the scene to register the component in
  49830. */
  49831. constructor(scene: Scene);
  49832. /**
  49833. * Registers the component in a given scene
  49834. */
  49835. register(): void;
  49836. /**
  49837. * Rebuilds the elements related to this component in case of
  49838. * context lost for instance.
  49839. */
  49840. rebuild(): void;
  49841. /**
  49842. * Disposes the component and the associated ressources
  49843. */
  49844. dispose(): void;
  49845. private _gatherRenderTargets;
  49846. }
  49847. }
  49848. declare module BABYLON {
  49849. /**
  49850. * Helper class dealing with the extraction of spherical polynomial dataArray
  49851. * from a cube map.
  49852. */
  49853. class CubeMapToSphericalPolynomialTools {
  49854. private static FileFaces;
  49855. /**
  49856. * Converts a texture to the according Spherical Polynomial data.
  49857. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49858. *
  49859. * @param texture The texture to extract the information from.
  49860. * @return The Spherical Polynomial data.
  49861. */
  49862. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  49863. /**
  49864. * Converts a cubemap to the according Spherical Polynomial data.
  49865. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49866. *
  49867. * @param cubeInfo The Cube map to extract the information from.
  49868. * @return The Spherical Polynomial data.
  49869. */
  49870. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  49871. }
  49872. }
  49873. declare module BABYLON {
  49874. /**
  49875. * Header information of HDR texture files.
  49876. */
  49877. interface HDRInfo {
  49878. /**
  49879. * The height of the texture in pixels.
  49880. */
  49881. height: number;
  49882. /**
  49883. * The width of the texture in pixels.
  49884. */
  49885. width: number;
  49886. /**
  49887. * The index of the beginning of the data in the binary file.
  49888. */
  49889. dataPosition: number;
  49890. }
  49891. /**
  49892. * This groups tools to convert HDR texture to native colors array.
  49893. */
  49894. class HDRTools {
  49895. private static Ldexp;
  49896. private static Rgbe2float;
  49897. private static readStringLine;
  49898. /**
  49899. * Reads header information from an RGBE texture stored in a native array.
  49900. * More information on this format are available here:
  49901. * https://en.wikipedia.org/wiki/RGBE_image_format
  49902. *
  49903. * @param uint8array The binary file stored in native array.
  49904. * @return The header information.
  49905. */
  49906. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  49907. /**
  49908. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  49909. * This RGBE texture needs to store the information as a panorama.
  49910. *
  49911. * More information on this format are available here:
  49912. * https://en.wikipedia.org/wiki/RGBE_image_format
  49913. *
  49914. * @param buffer The binary file stored in an array buffer.
  49915. * @param size The expected size of the extracted cubemap.
  49916. * @return The Cube Map information.
  49917. */
  49918. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  49919. /**
  49920. * Returns the pixels data extracted from an RGBE texture.
  49921. * This pixels will be stored left to right up to down in the R G B order in one array.
  49922. *
  49923. * More information on this format are available here:
  49924. * https://en.wikipedia.org/wiki/RGBE_image_format
  49925. *
  49926. * @param uint8array The binary file stored in an array buffer.
  49927. * @param hdrInfo The header information of the file.
  49928. * @return The pixels data in RGB right to left up to down order.
  49929. */
  49930. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  49931. private static RGBE_ReadPixels_RLE;
  49932. }
  49933. }
  49934. declare module BABYLON {
  49935. /**
  49936. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  49937. */
  49938. interface CubeMapInfo {
  49939. /**
  49940. * The pixel array for the front face.
  49941. * This is stored in format, left to right, up to down format.
  49942. */
  49943. front: Nullable<ArrayBufferView>;
  49944. /**
  49945. * The pixel array for the back face.
  49946. * This is stored in format, left to right, up to down format.
  49947. */
  49948. back: Nullable<ArrayBufferView>;
  49949. /**
  49950. * The pixel array for the left face.
  49951. * This is stored in format, left to right, up to down format.
  49952. */
  49953. left: Nullable<ArrayBufferView>;
  49954. /**
  49955. * The pixel array for the right face.
  49956. * This is stored in format, left to right, up to down format.
  49957. */
  49958. right: Nullable<ArrayBufferView>;
  49959. /**
  49960. * The pixel array for the up face.
  49961. * This is stored in format, left to right, up to down format.
  49962. */
  49963. up: Nullable<ArrayBufferView>;
  49964. /**
  49965. * The pixel array for the down face.
  49966. * This is stored in format, left to right, up to down format.
  49967. */
  49968. down: Nullable<ArrayBufferView>;
  49969. /**
  49970. * The size of the cubemap stored.
  49971. *
  49972. * Each faces will be size * size pixels.
  49973. */
  49974. size: number;
  49975. /**
  49976. * The format of the texture.
  49977. *
  49978. * RGBA, RGB.
  49979. */
  49980. format: number;
  49981. /**
  49982. * The type of the texture data.
  49983. *
  49984. * UNSIGNED_INT, FLOAT.
  49985. */
  49986. type: number;
  49987. /**
  49988. * Specifies whether the texture is in gamma space.
  49989. */
  49990. gammaSpace: boolean;
  49991. }
  49992. /**
  49993. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  49994. */
  49995. class PanoramaToCubeMapTools {
  49996. private static FACE_FRONT;
  49997. private static FACE_BACK;
  49998. private static FACE_RIGHT;
  49999. private static FACE_LEFT;
  50000. private static FACE_DOWN;
  50001. private static FACE_UP;
  50002. /**
  50003. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  50004. *
  50005. * @param float32Array The source data.
  50006. * @param inputWidth The width of the input panorama.
  50007. * @param inputHeight The height of the input panorama.
  50008. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  50009. * @return The cubemap data
  50010. */
  50011. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  50012. private static CreateCubemapTexture;
  50013. private static CalcProjectionSpherical;
  50014. }
  50015. }
  50016. declare module BABYLON {
  50017. }
  50018. declare module BABYLON {
  50019. }
  50020. declare module BABYLON {
  50021. }
  50022. declare module BABYLON {
  50023. }
  50024. declare module BABYLON {
  50025. /**
  50026. * 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.
  50027. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  50028. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  50029. */
  50030. class CustomProceduralTexture extends ProceduralTexture {
  50031. private _animate;
  50032. private _time;
  50033. private _config;
  50034. private _texturePath;
  50035. /**
  50036. * Instantiates a new Custom Procedural Texture.
  50037. * 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.
  50038. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  50039. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  50040. * @param name Define the name of the texture
  50041. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  50042. * @param size Define the size of the texture to create
  50043. * @param scene Define the scene the texture belongs to
  50044. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  50045. * @param generateMipMaps Define if the texture should creates mip maps or not
  50046. */
  50047. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  50048. private _loadJson;
  50049. /**
  50050. * Is the texture ready to be used ? (rendered at least once)
  50051. * @returns true if ready, otherwise, false.
  50052. */
  50053. isReady(): boolean;
  50054. /**
  50055. * Render the texture to its associated render target.
  50056. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  50057. */
  50058. render(useCameraPostProcess?: boolean): void;
  50059. /**
  50060. * Update the list of dependant textures samplers in the shader.
  50061. */
  50062. updateTextures(): void;
  50063. /**
  50064. * Update the uniform values of the procedural texture in the shader.
  50065. */
  50066. updateShaderUniforms(): void;
  50067. /**
  50068. * Define if the texture animates or not.
  50069. */
  50070. animate: boolean;
  50071. }
  50072. }
  50073. declare module BABYLON {
  50074. /**
  50075. * Class used to generate noise procedural textures
  50076. */
  50077. class NoiseProceduralTexture extends ProceduralTexture {
  50078. private _time;
  50079. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  50080. brightness: number;
  50081. /** Defines the number of octaves to process */
  50082. octaves: number;
  50083. /** Defines the level of persistence (0.8 by default) */
  50084. persistence: number;
  50085. /** Gets or sets animation speed factor (default is 1) */
  50086. animationSpeedFactor: number;
  50087. /**
  50088. * Creates a new NoiseProceduralTexture
  50089. * @param name defines the name fo the texture
  50090. * @param size defines the size of the texture (default is 256)
  50091. * @param scene defines the hosting scene
  50092. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  50093. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  50094. */
  50095. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  50096. private _updateShaderUniforms;
  50097. protected _getDefines(): string;
  50098. /** Generate the current state of the procedural texture */
  50099. render(useCameraPostProcess?: boolean): void;
  50100. /**
  50101. * Serializes this noise procedural texture
  50102. * @returns a serialized noise procedural texture object
  50103. */
  50104. serialize(): any;
  50105. /**
  50106. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  50107. * @param parsedTexture defines parsed texture data
  50108. * @param scene defines the current scene
  50109. * @param rootUrl defines the root URL containing noise procedural texture information
  50110. * @returns a parsed NoiseProceduralTexture
  50111. */
  50112. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): NoiseProceduralTexture;
  50113. }
  50114. }
  50115. declare module BABYLON {
  50116. /**
  50117. * 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.
  50118. * This is the base class of any Procedural texture and contains most of the shareable code.
  50119. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  50120. */
  50121. class ProceduralTexture extends Texture {
  50122. isCube: boolean;
  50123. /**
  50124. * Define if the texture is enabled or not (disabled texture will not render)
  50125. */
  50126. isEnabled: boolean;
  50127. /**
  50128. * Define if the texture must be cleared before rendering (default is true)
  50129. */
  50130. autoClear: boolean;
  50131. /**
  50132. * Callback called when the texture is generated
  50133. */
  50134. onGenerated: () => void;
  50135. /**
  50136. * Event raised when the texture is generated
  50137. */
  50138. onGeneratedObservable: Observable<ProceduralTexture>;
  50139. /** @hidden */
  50140. _generateMipMaps: boolean;
  50141. /** @hidden **/
  50142. _effect: Effect;
  50143. /** @hidden */
  50144. _textures: {
  50145. [key: string]: Texture;
  50146. };
  50147. private _size;
  50148. private _currentRefreshId;
  50149. private _refreshRate;
  50150. private _vertexBuffers;
  50151. private _indexBuffer;
  50152. private _uniforms;
  50153. private _samplers;
  50154. private _fragment;
  50155. private _floats;
  50156. private _ints;
  50157. private _floatsArrays;
  50158. private _colors3;
  50159. private _colors4;
  50160. private _vectors2;
  50161. private _vectors3;
  50162. private _matrices;
  50163. private _fallbackTexture;
  50164. private _fallbackTextureUsed;
  50165. private _engine;
  50166. private _cachedDefines;
  50167. private _contentUpdateId;
  50168. private _contentData;
  50169. /**
  50170. * Instantiates a new procedural texture.
  50171. * 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.
  50172. * This is the base class of any Procedural texture and contains most of the shareable code.
  50173. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  50174. * @param name Define the name of the texture
  50175. * @param size Define the size of the texture to create
  50176. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  50177. * @param scene Define the scene the texture belongs to
  50178. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  50179. * @param generateMipMaps Define if the texture should creates mip maps or not
  50180. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  50181. */
  50182. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  50183. /**
  50184. * The effect that is created when initializing the post process.
  50185. * @returns The created effect corrisponding the the postprocess.
  50186. */
  50187. getEffect(): Effect;
  50188. /**
  50189. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  50190. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  50191. */
  50192. getContent(): Nullable<ArrayBufferView>;
  50193. private _createIndexBuffer;
  50194. /** @hidden */
  50195. _rebuild(): void;
  50196. /**
  50197. * Resets the texture in order to recreate its associated resources.
  50198. * This can be called in case of context loss
  50199. */
  50200. reset(): void;
  50201. protected _getDefines(): string;
  50202. /**
  50203. * Is the texture ready to be used ? (rendered at least once)
  50204. * @returns true if ready, otherwise, false.
  50205. */
  50206. isReady(): boolean;
  50207. /**
  50208. * Resets the refresh counter of the texture and start bak from scratch.
  50209. * Could be useful to regenerate the texture if it is setup to render only once.
  50210. */
  50211. resetRefreshCounter(): void;
  50212. /**
  50213. * Set the fragment shader to use in order to render the texture.
  50214. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  50215. */
  50216. setFragment(fragment: any): void;
  50217. /**
  50218. * Define the refresh rate of the texture or the rendering frequency.
  50219. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  50220. */
  50221. refreshRate: number;
  50222. /** @hidden */
  50223. _shouldRender(): boolean;
  50224. /**
  50225. * Get the size the texture is rendering at.
  50226. * @returns the size (texture is always squared)
  50227. */
  50228. getRenderSize(): number;
  50229. /**
  50230. * Resize the texture to new value.
  50231. * @param size Define the new size the texture should have
  50232. * @param generateMipMaps Define whether the new texture should create mip maps
  50233. */
  50234. resize(size: number, generateMipMaps: boolean): void;
  50235. private _checkUniform;
  50236. /**
  50237. * Set a texture in the shader program used to render.
  50238. * @param name Define the name of the uniform samplers as defined in the shader
  50239. * @param texture Define the texture to bind to this sampler
  50240. * @return the texture itself allowing "fluent" like uniform updates
  50241. */
  50242. setTexture(name: string, texture: Texture): ProceduralTexture;
  50243. /**
  50244. * Set a float in the shader.
  50245. * @param name Define the name of the uniform as defined in the shader
  50246. * @param value Define the value to give to the uniform
  50247. * @return the texture itself allowing "fluent" like uniform updates
  50248. */
  50249. setFloat(name: string, value: number): ProceduralTexture;
  50250. /**
  50251. * Set a int in the shader.
  50252. * @param name Define the name of the uniform as defined in the shader
  50253. * @param value Define the value to give to the uniform
  50254. * @return the texture itself allowing "fluent" like uniform updates
  50255. */
  50256. setInt(name: string, value: number): ProceduralTexture;
  50257. /**
  50258. * Set an array of floats in the shader.
  50259. * @param name Define the name of the uniform as defined in the shader
  50260. * @param value Define the value to give to the uniform
  50261. * @return the texture itself allowing "fluent" like uniform updates
  50262. */
  50263. setFloats(name: string, value: number[]): ProceduralTexture;
  50264. /**
  50265. * Set a vec3 in the shader from a Color3.
  50266. * @param name Define the name of the uniform as defined in the shader
  50267. * @param value Define the value to give to the uniform
  50268. * @return the texture itself allowing "fluent" like uniform updates
  50269. */
  50270. setColor3(name: string, value: Color3): ProceduralTexture;
  50271. /**
  50272. * Set a vec4 in the shader from a Color4.
  50273. * @param name Define the name of the uniform as defined in the shader
  50274. * @param value Define the value to give to the uniform
  50275. * @return the texture itself allowing "fluent" like uniform updates
  50276. */
  50277. setColor4(name: string, value: Color4): ProceduralTexture;
  50278. /**
  50279. * Set a vec2 in the shader from a Vector2.
  50280. * @param name Define the name of the uniform as defined in the shader
  50281. * @param value Define the value to give to the uniform
  50282. * @return the texture itself allowing "fluent" like uniform updates
  50283. */
  50284. setVector2(name: string, value: Vector2): ProceduralTexture;
  50285. /**
  50286. * Set a vec3 in the shader from a Vector3.
  50287. * @param name Define the name of the uniform as defined in the shader
  50288. * @param value Define the value to give to the uniform
  50289. * @return the texture itself allowing "fluent" like uniform updates
  50290. */
  50291. setVector3(name: string, value: Vector3): ProceduralTexture;
  50292. /**
  50293. * Set a mat4 in the shader from a MAtrix.
  50294. * @param name Define the name of the uniform as defined in the shader
  50295. * @param value Define the value to give to the uniform
  50296. * @return the texture itself allowing "fluent" like uniform updates
  50297. */
  50298. setMatrix(name: string, value: Matrix): ProceduralTexture;
  50299. /**
  50300. * Render the texture to its associated render target.
  50301. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  50302. */
  50303. render(useCameraPostProcess?: boolean): void;
  50304. /**
  50305. * Clone the texture.
  50306. * @returns the cloned texture
  50307. */
  50308. clone(): ProceduralTexture;
  50309. /**
  50310. * Dispose the texture and release its asoociated resources.
  50311. */
  50312. dispose(): void;
  50313. }
  50314. }
  50315. declare module BABYLON {
  50316. interface AbstractScene {
  50317. /**
  50318. * The list of procedural textures added to the scene
  50319. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  50320. */
  50321. proceduralTextures: Array<ProceduralTexture>;
  50322. }
  50323. /**
  50324. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  50325. * in a given scene.
  50326. */
  50327. class ProceduralTextureSceneComponent implements ISceneComponent {
  50328. /**
  50329. * The component name helpfull to identify the component in the list of scene components.
  50330. */
  50331. readonly name: string;
  50332. /**
  50333. * The scene the component belongs to.
  50334. */
  50335. scene: Scene;
  50336. /**
  50337. * Creates a new instance of the component for the given scene
  50338. * @param scene Defines the scene to register the component in
  50339. */
  50340. constructor(scene: Scene);
  50341. /**
  50342. * Registers the component in a given scene
  50343. */
  50344. register(): void;
  50345. /**
  50346. * Rebuilds the elements related to this component in case of
  50347. * context lost for instance.
  50348. */
  50349. rebuild(): void;
  50350. /**
  50351. * Disposes the component and the associated ressources.
  50352. */
  50353. dispose(): void;
  50354. private _beforeClear;
  50355. }
  50356. }
  50357. declare module BABYLON {
  50358. /**
  50359. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  50360. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  50361. */
  50362. class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  50363. private _scene;
  50364. private _camerasToBeAttached;
  50365. /**
  50366. * ID of the sharpen post process,
  50367. */
  50368. private readonly SharpenPostProcessId;
  50369. /**
  50370. * @ignore
  50371. * ID of the image processing post process;
  50372. */
  50373. readonly ImageProcessingPostProcessId: string;
  50374. /**
  50375. * @ignore
  50376. * ID of the Fast Approximate Anti-Aliasing post process;
  50377. */
  50378. readonly FxaaPostProcessId: string;
  50379. /**
  50380. * ID of the chromatic aberration post process,
  50381. */
  50382. private readonly ChromaticAberrationPostProcessId;
  50383. /**
  50384. * ID of the grain post process
  50385. */
  50386. private readonly GrainPostProcessId;
  50387. /**
  50388. * Sharpen post process which will apply a sharpen convolution to enhance edges
  50389. */
  50390. sharpen: SharpenPostProcess;
  50391. private _sharpenEffect;
  50392. private bloom;
  50393. /**
  50394. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  50395. */
  50396. depthOfField: DepthOfFieldEffect;
  50397. /**
  50398. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  50399. */
  50400. fxaa: FxaaPostProcess;
  50401. /**
  50402. * Image post processing pass used to perform operations such as tone mapping or color grading.
  50403. */
  50404. imageProcessing: ImageProcessingPostProcess;
  50405. /**
  50406. * Chromatic aberration post process which will shift rgb colors in the image
  50407. */
  50408. chromaticAberration: ChromaticAberrationPostProcess;
  50409. private _chromaticAberrationEffect;
  50410. /**
  50411. * Grain post process which add noise to the image
  50412. */
  50413. grain: GrainPostProcess;
  50414. private _grainEffect;
  50415. /**
  50416. * Glow post process which adds a glow to emmisive areas of the image
  50417. */
  50418. private _glowLayer;
  50419. /**
  50420. * Animations which can be used to tweak settings over a period of time
  50421. */
  50422. animations: Animation[];
  50423. private _imageProcessingConfigurationObserver;
  50424. private _sharpenEnabled;
  50425. private _bloomEnabled;
  50426. private _depthOfFieldEnabled;
  50427. private _depthOfFieldBlurLevel;
  50428. private _fxaaEnabled;
  50429. private _imageProcessingEnabled;
  50430. private _defaultPipelineTextureType;
  50431. private _bloomScale;
  50432. private _chromaticAberrationEnabled;
  50433. private _grainEnabled;
  50434. private _buildAllowed;
  50435. /**
  50436. * Enable or disable the sharpen process from the pipeline
  50437. */
  50438. sharpenEnabled: boolean;
  50439. private _resizeObserver;
  50440. private _hardwareScaleLevel;
  50441. private _bloomKernel;
  50442. /**
  50443. * Specifies the size of the bloom blur kernel, relative to the final output size
  50444. */
  50445. bloomKernel: number;
  50446. /**
  50447. * Specifies the weight of the bloom in the final rendering
  50448. */
  50449. private _bloomWeight;
  50450. /**
  50451. * Specifies the luma threshold for the area that will be blurred by the bloom
  50452. */
  50453. private _bloomThreshold;
  50454. private _hdr;
  50455. /**
  50456. * The strength of the bloom.
  50457. */
  50458. bloomWeight: number;
  50459. /**
  50460. * The strength of the bloom.
  50461. */
  50462. bloomThreshold: number;
  50463. /**
  50464. * The scale of the bloom, lower value will provide better performance.
  50465. */
  50466. bloomScale: number;
  50467. /**
  50468. * Enable or disable the bloom from the pipeline
  50469. */
  50470. bloomEnabled: boolean;
  50471. private _rebuildBloom;
  50472. /**
  50473. * If the depth of field is enabled.
  50474. */
  50475. depthOfFieldEnabled: boolean;
  50476. /**
  50477. * Blur level of the depth of field effect. (Higher blur will effect performance)
  50478. */
  50479. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  50480. /**
  50481. * If the anti aliasing is enabled.
  50482. */
  50483. fxaaEnabled: boolean;
  50484. private _samples;
  50485. /**
  50486. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  50487. */
  50488. samples: number;
  50489. /**
  50490. * If image processing is enabled.
  50491. */
  50492. imageProcessingEnabled: boolean;
  50493. /**
  50494. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  50495. */
  50496. glowLayerEnabled: boolean;
  50497. /**
  50498. * Enable or disable the chromaticAberration process from the pipeline
  50499. */
  50500. chromaticAberrationEnabled: boolean;
  50501. /**
  50502. * Enable or disable the grain process from the pipeline
  50503. */
  50504. grainEnabled: boolean;
  50505. /**
  50506. * @constructor
  50507. * @param name - The rendering pipeline name (default: "")
  50508. * @param hdr - If high dynamic range textures should be used (default: true)
  50509. * @param scene - The scene linked to this pipeline (default: the last created scene)
  50510. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  50511. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  50512. */
  50513. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  50514. /**
  50515. * Force the compilation of the entire pipeline.
  50516. */
  50517. prepare(): void;
  50518. private _hasCleared;
  50519. private _prevPostProcess;
  50520. private _prevPrevPostProcess;
  50521. private _setAutoClearAndTextureSharing;
  50522. private _depthOfFieldSceneObserver;
  50523. private _buildPipeline;
  50524. private _disposePostProcesses;
  50525. /**
  50526. * Adds a camera to the pipeline
  50527. * @param camera the camera to be added
  50528. */
  50529. addCamera(camera: Camera): void;
  50530. /**
  50531. * Removes a camera from the pipeline
  50532. * @param camera the camera to remove
  50533. */
  50534. removeCamera(camera: Camera): void;
  50535. /**
  50536. * Dispose of the pipeline and stop all post processes
  50537. */
  50538. dispose(): void;
  50539. /**
  50540. * Serialize the rendering pipeline (Used when exporting)
  50541. * @returns the serialized object
  50542. */
  50543. serialize(): any;
  50544. /**
  50545. * Parse the serialized pipeline
  50546. * @param source Source pipeline.
  50547. * @param scene The scene to load the pipeline to.
  50548. * @param rootUrl The URL of the serialized pipeline.
  50549. * @returns An instantiated pipeline from the serialized object.
  50550. */
  50551. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  50552. }
  50553. }
  50554. declare module BABYLON {
  50555. /**
  50556. * BABYLON.JS Chromatic Aberration GLSL Shader
  50557. * Author: Olivier Guyot
  50558. * Separates very slightly R, G and B colors on the edges of the screen
  50559. * Inspired by Francois Tarlier & Martins Upitis
  50560. */
  50561. class LensRenderingPipeline extends PostProcessRenderPipeline {
  50562. /**
  50563. * @ignore
  50564. * The chromatic aberration PostProcess id in the pipeline
  50565. */
  50566. LensChromaticAberrationEffect: string;
  50567. /**
  50568. * @ignore
  50569. * The highlights enhancing PostProcess id in the pipeline
  50570. */
  50571. HighlightsEnhancingEffect: string;
  50572. /**
  50573. * @ignore
  50574. * The depth-of-field PostProcess id in the pipeline
  50575. */
  50576. LensDepthOfFieldEffect: string;
  50577. private _scene;
  50578. private _depthTexture;
  50579. private _grainTexture;
  50580. private _chromaticAberrationPostProcess;
  50581. private _highlightsPostProcess;
  50582. private _depthOfFieldPostProcess;
  50583. private _edgeBlur;
  50584. private _grainAmount;
  50585. private _chromaticAberration;
  50586. private _distortion;
  50587. private _highlightsGain;
  50588. private _highlightsThreshold;
  50589. private _dofDistance;
  50590. private _dofAperture;
  50591. private _dofDarken;
  50592. private _dofPentagon;
  50593. private _blurNoise;
  50594. /**
  50595. * @constructor
  50596. *
  50597. * Effect parameters are as follow:
  50598. * {
  50599. * chromatic_aberration: number; // from 0 to x (1 for realism)
  50600. * edge_blur: number; // from 0 to x (1 for realism)
  50601. * distortion: number; // from 0 to x (1 for realism)
  50602. * grain_amount: number; // from 0 to 1
  50603. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  50604. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  50605. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  50606. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  50607. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  50608. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  50609. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  50610. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  50611. * }
  50612. * Note: if an effect parameter is unset, effect is disabled
  50613. *
  50614. * @param name The rendering pipeline name
  50615. * @param parameters - An object containing all parameters (see above)
  50616. * @param scene The scene linked to this pipeline
  50617. * @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)
  50618. * @param cameras The array of cameras that the rendering pipeline will be attached to
  50619. */
  50620. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  50621. /**
  50622. * Sets the amount of blur at the edges
  50623. * @param amount blur amount
  50624. */
  50625. setEdgeBlur(amount: number): void;
  50626. /**
  50627. * Sets edge blur to 0
  50628. */
  50629. disableEdgeBlur(): void;
  50630. /**
  50631. * Sets the amout of grain
  50632. * @param amount Amount of grain
  50633. */
  50634. setGrainAmount(amount: number): void;
  50635. /**
  50636. * Set grain amount to 0
  50637. */
  50638. disableGrain(): void;
  50639. /**
  50640. * Sets the chromatic aberration amount
  50641. * @param amount amount of chromatic aberration
  50642. */
  50643. setChromaticAberration(amount: number): void;
  50644. /**
  50645. * Sets chromatic aberration amount to 0
  50646. */
  50647. disableChromaticAberration(): void;
  50648. /**
  50649. * Sets the EdgeDistortion amount
  50650. * @param amount amount of EdgeDistortion
  50651. */
  50652. setEdgeDistortion(amount: number): void;
  50653. /**
  50654. * Sets edge distortion to 0
  50655. */
  50656. disableEdgeDistortion(): void;
  50657. /**
  50658. * Sets the FocusDistance amount
  50659. * @param amount amount of FocusDistance
  50660. */
  50661. setFocusDistance(amount: number): void;
  50662. /**
  50663. * Disables depth of field
  50664. */
  50665. disableDepthOfField(): void;
  50666. /**
  50667. * Sets the Aperture amount
  50668. * @param amount amount of Aperture
  50669. */
  50670. setAperture(amount: number): void;
  50671. /**
  50672. * Sets the DarkenOutOfFocus amount
  50673. * @param amount amount of DarkenOutOfFocus
  50674. */
  50675. setDarkenOutOfFocus(amount: number): void;
  50676. /**
  50677. * Creates a pentagon bokeh effect
  50678. */
  50679. enablePentagonBokeh(): void;
  50680. /**
  50681. * Disables the pentagon bokeh effect
  50682. */
  50683. disablePentagonBokeh(): void;
  50684. /**
  50685. * Enables noise blur
  50686. */
  50687. enableNoiseBlur(): void;
  50688. /**
  50689. * Disables noise blur
  50690. */
  50691. disableNoiseBlur(): void;
  50692. /**
  50693. * Sets the HighlightsGain amount
  50694. * @param amount amount of HighlightsGain
  50695. */
  50696. setHighlightsGain(amount: number): void;
  50697. /**
  50698. * Sets the HighlightsThreshold amount
  50699. * @param amount amount of HighlightsThreshold
  50700. */
  50701. setHighlightsThreshold(amount: number): void;
  50702. /**
  50703. * Disables highlights
  50704. */
  50705. disableHighlights(): void;
  50706. /**
  50707. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  50708. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  50709. */
  50710. dispose(disableDepthRender?: boolean): void;
  50711. private _createChromaticAberrationPostProcess;
  50712. private _createHighlightsPostProcess;
  50713. private _createDepthOfFieldPostProcess;
  50714. private _createGrainTexture;
  50715. }
  50716. }
  50717. declare module BABYLON {
  50718. /**
  50719. * Render pipeline to produce ssao effect
  50720. */
  50721. class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  50722. /**
  50723. * @ignore
  50724. * The PassPostProcess id in the pipeline that contains the original scene color
  50725. */
  50726. SSAOOriginalSceneColorEffect: string;
  50727. /**
  50728. * @ignore
  50729. * The SSAO PostProcess id in the pipeline
  50730. */
  50731. SSAORenderEffect: string;
  50732. /**
  50733. * @ignore
  50734. * The horizontal blur PostProcess id in the pipeline
  50735. */
  50736. SSAOBlurHRenderEffect: string;
  50737. /**
  50738. * @ignore
  50739. * The vertical blur PostProcess id in the pipeline
  50740. */
  50741. SSAOBlurVRenderEffect: string;
  50742. /**
  50743. * @ignore
  50744. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  50745. */
  50746. SSAOCombineRenderEffect: string;
  50747. /**
  50748. * The output strength of the SSAO post-process. Default value is 1.0.
  50749. */
  50750. totalStrength: number;
  50751. /**
  50752. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  50753. */
  50754. maxZ: number;
  50755. /**
  50756. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  50757. */
  50758. minZAspect: number;
  50759. private _samples;
  50760. /**
  50761. * Number of samples used for the SSAO calculations. Default value is 8
  50762. */
  50763. samples: number;
  50764. private _textureSamples;
  50765. /**
  50766. * Number of samples to use for antialiasing
  50767. */
  50768. textureSamples: number;
  50769. /**
  50770. * Ratio object used for SSAO ratio and blur ratio
  50771. */
  50772. private _ratio;
  50773. /**
  50774. * Dynamically generated sphere sampler.
  50775. */
  50776. private _sampleSphere;
  50777. /**
  50778. * Blur filter offsets
  50779. */
  50780. private _samplerOffsets;
  50781. private _expensiveBlur;
  50782. /**
  50783. * If bilateral blur should be used
  50784. */
  50785. expensiveBlur: boolean;
  50786. /**
  50787. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  50788. */
  50789. radius: number;
  50790. /**
  50791. * The base color of the SSAO post-process
  50792. * The final result is "base + ssao" between [0, 1]
  50793. */
  50794. base: number;
  50795. /**
  50796. * Support test.
  50797. */
  50798. static readonly IsSupported: boolean;
  50799. private _scene;
  50800. private _depthTexture;
  50801. private _normalTexture;
  50802. private _randomTexture;
  50803. private _originalColorPostProcess;
  50804. private _ssaoPostProcess;
  50805. private _blurHPostProcess;
  50806. private _blurVPostProcess;
  50807. private _ssaoCombinePostProcess;
  50808. private _firstUpdate;
  50809. /**
  50810. * @constructor
  50811. * @param name The rendering pipeline name
  50812. * @param scene The scene linked to this pipeline
  50813. * @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 }
  50814. * @param cameras The array of cameras that the rendering pipeline will be attached to
  50815. */
  50816. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  50817. /**
  50818. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  50819. */
  50820. dispose(disableGeometryBufferRenderer?: boolean): void;
  50821. private _createBlurPostProcess;
  50822. /** @hidden */
  50823. _rebuild(): void;
  50824. private _bits;
  50825. private _radicalInverse_VdC;
  50826. private _hammersley;
  50827. private _hemisphereSample_uniform;
  50828. private _generateHemisphere;
  50829. private _createSSAOPostProcess;
  50830. private _createSSAOCombinePostProcess;
  50831. private _createRandomTexture;
  50832. /**
  50833. * Serialize the rendering pipeline (Used when exporting)
  50834. * @returns the serialized object
  50835. */
  50836. serialize(): any;
  50837. /**
  50838. * Parse the serialized pipeline
  50839. * @param source Source pipeline.
  50840. * @param scene The scene to load the pipeline to.
  50841. * @param rootUrl The URL of the serialized pipeline.
  50842. * @returns An instantiated pipeline from the serialized object.
  50843. */
  50844. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  50845. }
  50846. }
  50847. declare module BABYLON {
  50848. /**
  50849. * Render pipeline to produce ssao effect
  50850. */
  50851. class SSAORenderingPipeline extends PostProcessRenderPipeline {
  50852. /**
  50853. * @ignore
  50854. * The PassPostProcess id in the pipeline that contains the original scene color
  50855. */
  50856. SSAOOriginalSceneColorEffect: string;
  50857. /**
  50858. * @ignore
  50859. * The SSAO PostProcess id in the pipeline
  50860. */
  50861. SSAORenderEffect: string;
  50862. /**
  50863. * @ignore
  50864. * The horizontal blur PostProcess id in the pipeline
  50865. */
  50866. SSAOBlurHRenderEffect: string;
  50867. /**
  50868. * @ignore
  50869. * The vertical blur PostProcess id in the pipeline
  50870. */
  50871. SSAOBlurVRenderEffect: string;
  50872. /**
  50873. * @ignore
  50874. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  50875. */
  50876. SSAOCombineRenderEffect: string;
  50877. /**
  50878. * The output strength of the SSAO post-process. Default value is 1.0.
  50879. */
  50880. totalStrength: number;
  50881. /**
  50882. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  50883. */
  50884. radius: number;
  50885. /**
  50886. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  50887. * Must not be equal to fallOff and superior to fallOff.
  50888. * Default value is 0.975
  50889. */
  50890. area: number;
  50891. /**
  50892. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  50893. * Must not be equal to area and inferior to area.
  50894. * Default value is 0.0
  50895. */
  50896. fallOff: number;
  50897. /**
  50898. * The base color of the SSAO post-process
  50899. * The final result is "base + ssao" between [0, 1]
  50900. */
  50901. base: number;
  50902. private _scene;
  50903. private _depthTexture;
  50904. private _randomTexture;
  50905. private _originalColorPostProcess;
  50906. private _ssaoPostProcess;
  50907. private _blurHPostProcess;
  50908. private _blurVPostProcess;
  50909. private _ssaoCombinePostProcess;
  50910. private _firstUpdate;
  50911. /**
  50912. * @constructor
  50913. * @param name - The rendering pipeline name
  50914. * @param scene - The scene linked to this pipeline
  50915. * @param ratio - The size of the postprocesses. Can be a number shared between passes or an object for more precision: { ssaoRatio: 0.5, combineRatio: 1.0 }
  50916. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  50917. */
  50918. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  50919. /**
  50920. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  50921. */
  50922. dispose(disableDepthRender?: boolean): void;
  50923. private _createBlurPostProcess;
  50924. /** @hidden */
  50925. _rebuild(): void;
  50926. private _createSSAOPostProcess;
  50927. private _createSSAOCombinePostProcess;
  50928. private _createRandomTexture;
  50929. }
  50930. }
  50931. declare module BABYLON {
  50932. /**
  50933. * Standard rendering pipeline
  50934. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  50935. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  50936. */
  50937. class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  50938. /**
  50939. * Public members
  50940. */
  50941. /**
  50942. * Post-process which contains the original scene color before the pipeline applies all the effects
  50943. */
  50944. originalPostProcess: Nullable<PostProcess>;
  50945. /**
  50946. * Post-process used to down scale an image x4
  50947. */
  50948. downSampleX4PostProcess: Nullable<PostProcess>;
  50949. /**
  50950. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  50951. */
  50952. brightPassPostProcess: Nullable<PostProcess>;
  50953. /**
  50954. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  50955. */
  50956. blurHPostProcesses: PostProcess[];
  50957. /**
  50958. * Post-process array storing all the vertical blur post-processes used by the pipeline
  50959. */
  50960. blurVPostProcesses: PostProcess[];
  50961. /**
  50962. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  50963. */
  50964. textureAdderPostProcess: Nullable<PostProcess>;
  50965. /**
  50966. * Post-process used to create volumetric lighting effect
  50967. */
  50968. volumetricLightPostProcess: Nullable<PostProcess>;
  50969. /**
  50970. * Post-process used to smooth the previous volumetric light post-process on the X axis
  50971. */
  50972. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  50973. /**
  50974. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  50975. */
  50976. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  50977. /**
  50978. * Post-process used to merge the volumetric light effect and the real scene color
  50979. */
  50980. volumetricLightMergePostProces: Nullable<PostProcess>;
  50981. /**
  50982. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  50983. */
  50984. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  50985. /**
  50986. * Base post-process used to calculate the average luminance of the final image for HDR
  50987. */
  50988. luminancePostProcess: Nullable<PostProcess>;
  50989. /**
  50990. * Post-processes used to create down sample post-processes in order to get
  50991. * the average luminance of the final image for HDR
  50992. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  50993. */
  50994. luminanceDownSamplePostProcesses: PostProcess[];
  50995. /**
  50996. * Post-process used to create a HDR effect (light adaptation)
  50997. */
  50998. hdrPostProcess: Nullable<PostProcess>;
  50999. /**
  51000. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  51001. */
  51002. textureAdderFinalPostProcess: Nullable<PostProcess>;
  51003. /**
  51004. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  51005. */
  51006. lensFlareFinalPostProcess: Nullable<PostProcess>;
  51007. /**
  51008. * Post-process used to merge the final HDR post-process and the real scene color
  51009. */
  51010. hdrFinalPostProcess: Nullable<PostProcess>;
  51011. /**
  51012. * Post-process used to create a lens flare effect
  51013. */
  51014. lensFlarePostProcess: Nullable<PostProcess>;
  51015. /**
  51016. * Post-process that merges the result of the lens flare post-process and the real scene color
  51017. */
  51018. lensFlareComposePostProcess: Nullable<PostProcess>;
  51019. /**
  51020. * Post-process used to create a motion blur effect
  51021. */
  51022. motionBlurPostProcess: Nullable<PostProcess>;
  51023. /**
  51024. * Post-process used to create a depth of field effect
  51025. */
  51026. depthOfFieldPostProcess: Nullable<PostProcess>;
  51027. /**
  51028. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  51029. */
  51030. fxaaPostProcess: Nullable<FxaaPostProcess>;
  51031. /**
  51032. * Represents the brightness threshold in order to configure the illuminated surfaces
  51033. */
  51034. brightThreshold: number;
  51035. /**
  51036. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  51037. */
  51038. blurWidth: number;
  51039. /**
  51040. * Sets if the blur for highlighted surfaces must be only horizontal
  51041. */
  51042. horizontalBlur: boolean;
  51043. /**
  51044. * Sets the overall exposure used by the pipeline
  51045. */
  51046. exposure: number;
  51047. /**
  51048. * Texture used typically to simulate "dirty" on camera lens
  51049. */
  51050. lensTexture: Nullable<Texture>;
  51051. /**
  51052. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  51053. */
  51054. volumetricLightCoefficient: number;
  51055. /**
  51056. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  51057. */
  51058. volumetricLightPower: number;
  51059. /**
  51060. * Used the set the blur intensity to smooth the volumetric lights
  51061. */
  51062. volumetricLightBlurScale: number;
  51063. /**
  51064. * Light (spot or directional) used to generate the volumetric lights rays
  51065. * The source light must have a shadow generate so the pipeline can get its
  51066. * depth map
  51067. */
  51068. sourceLight: Nullable<SpotLight | DirectionalLight>;
  51069. /**
  51070. * For eye adaptation, represents the minimum luminance the eye can see
  51071. */
  51072. hdrMinimumLuminance: number;
  51073. /**
  51074. * For eye adaptation, represents the decrease luminance speed
  51075. */
  51076. hdrDecreaseRate: number;
  51077. /**
  51078. * For eye adaptation, represents the increase luminance speed
  51079. */
  51080. hdrIncreaseRate: number;
  51081. /**
  51082. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  51083. */
  51084. lensColorTexture: Nullable<Texture>;
  51085. /**
  51086. * The overall strengh for the lens flare effect
  51087. */
  51088. lensFlareStrength: number;
  51089. /**
  51090. * Dispersion coefficient for lens flare ghosts
  51091. */
  51092. lensFlareGhostDispersal: number;
  51093. /**
  51094. * Main lens flare halo width
  51095. */
  51096. lensFlareHaloWidth: number;
  51097. /**
  51098. * Based on the lens distortion effect, defines how much the lens flare result
  51099. * is distorted
  51100. */
  51101. lensFlareDistortionStrength: number;
  51102. /**
  51103. * Lens star texture must be used to simulate rays on the flares and is available
  51104. * in the documentation
  51105. */
  51106. lensStarTexture: Nullable<Texture>;
  51107. /**
  51108. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  51109. * flare effect by taking account of the dirt texture
  51110. */
  51111. lensFlareDirtTexture: Nullable<Texture>;
  51112. /**
  51113. * Represents the focal length for the depth of field effect
  51114. */
  51115. depthOfFieldDistance: number;
  51116. /**
  51117. * Represents the blur intensity for the blurred part of the depth of field effect
  51118. */
  51119. depthOfFieldBlurWidth: number;
  51120. /**
  51121. * For motion blur, defines how much the image is blurred by the movement
  51122. */
  51123. motionStrength: number;
  51124. /**
  51125. * List of animations for the pipeline (IAnimatable implementation)
  51126. */
  51127. animations: Animation[];
  51128. /**
  51129. * Private members
  51130. */
  51131. private _scene;
  51132. private _currentDepthOfFieldSource;
  51133. private _basePostProcess;
  51134. private _hdrCurrentLuminance;
  51135. private _floatTextureType;
  51136. private _ratio;
  51137. private _bloomEnabled;
  51138. private _depthOfFieldEnabled;
  51139. private _vlsEnabled;
  51140. private _lensFlareEnabled;
  51141. private _hdrEnabled;
  51142. private _motionBlurEnabled;
  51143. private _fxaaEnabled;
  51144. private _motionBlurSamples;
  51145. private _volumetricLightStepsCount;
  51146. private _samples;
  51147. /**
  51148. * @ignore
  51149. * Specifies if the bloom pipeline is enabled
  51150. */
  51151. BloomEnabled: boolean;
  51152. /**
  51153. * @ignore
  51154. * Specifies if the depth of field pipeline is enabed
  51155. */
  51156. DepthOfFieldEnabled: boolean;
  51157. /**
  51158. * @ignore
  51159. * Specifies if the lens flare pipeline is enabed
  51160. */
  51161. LensFlareEnabled: boolean;
  51162. /**
  51163. * @ignore
  51164. * Specifies if the HDR pipeline is enabled
  51165. */
  51166. HDREnabled: boolean;
  51167. /**
  51168. * @ignore
  51169. * Specifies if the volumetric lights scattering effect is enabled
  51170. */
  51171. VLSEnabled: boolean;
  51172. /**
  51173. * @ignore
  51174. * Specifies if the motion blur effect is enabled
  51175. */
  51176. MotionBlurEnabled: boolean;
  51177. /**
  51178. * Specifies if anti-aliasing is enabled
  51179. */
  51180. fxaaEnabled: boolean;
  51181. /**
  51182. * Specifies the number of steps used to calculate the volumetric lights
  51183. * Typically in interval [50, 200]
  51184. */
  51185. volumetricLightStepsCount: number;
  51186. /**
  51187. * Specifies the number of samples used for the motion blur effect
  51188. * Typically in interval [16, 64]
  51189. */
  51190. motionBlurSamples: number;
  51191. /**
  51192. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  51193. */
  51194. samples: number;
  51195. /**
  51196. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  51197. * @constructor
  51198. * @param name The rendering pipeline name
  51199. * @param scene The scene linked to this pipeline
  51200. * @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)
  51201. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  51202. * @param cameras The array of cameras that the rendering pipeline will be attached to
  51203. */
  51204. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  51205. private _buildPipeline;
  51206. private _createDownSampleX4PostProcess;
  51207. private _createBrightPassPostProcess;
  51208. private _createBlurPostProcesses;
  51209. private _createTextureAdderPostProcess;
  51210. private _createVolumetricLightPostProcess;
  51211. private _createLuminancePostProcesses;
  51212. private _createHdrPostProcess;
  51213. private _createLensFlarePostProcess;
  51214. private _createDepthOfFieldPostProcess;
  51215. private _createMotionBlurPostProcess;
  51216. private _getDepthTexture;
  51217. private _disposePostProcesses;
  51218. /**
  51219. * Dispose of the pipeline and stop all post processes
  51220. */
  51221. dispose(): void;
  51222. /**
  51223. * Serialize the rendering pipeline (Used when exporting)
  51224. * @returns the serialized object
  51225. */
  51226. serialize(): any;
  51227. /**
  51228. * Parse the serialized pipeline
  51229. * @param source Source pipeline.
  51230. * @param scene The scene to load the pipeline to.
  51231. * @param rootUrl The URL of the serialized pipeline.
  51232. * @returns An instantiated pipeline from the serialized object.
  51233. */
  51234. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  51235. /**
  51236. * Luminance steps
  51237. */
  51238. static LuminanceSteps: number;
  51239. }
  51240. }