babylon.d.ts 2.1 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110
  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. * @see http://doc.babylonjs.com/babylon101/materials
  105. */
  106. materials: Material[];
  107. /**
  108. * The list of morph target managers added to the scene
  109. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  110. */
  111. morphTargetManagers: MorphTargetManager[];
  112. /**
  113. * The list of geometries used in the scene.
  114. */
  115. geometries: Geometry[];
  116. /**
  117. * All of the tranform nodes added to this scene
  118. * @see http://doc.babylonjs.com/how_to/transformnode
  119. */
  120. transformNodes: TransformNode[];
  121. /**
  122. * ActionManagers available on the scene.
  123. */
  124. actionManagers: ActionManager[];
  125. /**
  126. * Textures to keep.
  127. */
  128. textures: BaseTexture[];
  129. }
  130. }
  131. declare module BABYLON {
  132. /**
  133. * Set of assets to keep when moving a scene into an asset container.
  134. */
  135. class KeepAssets extends AbstractScene {
  136. }
  137. /**
  138. * Container with a set of assets that can be added or removed from a scene.
  139. */
  140. class AssetContainer extends AbstractScene {
  141. /**
  142. * The scene the AssetContainer belongs to.
  143. */
  144. scene: Scene;
  145. /**
  146. * Instantiates an AssetContainer.
  147. * @param scene The scene the AssetContainer belongs to.
  148. */
  149. constructor(scene: Scene);
  150. /**
  151. * Adds all the assets from the container to the scene.
  152. */
  153. addAllToScene(): void;
  154. /**
  155. * Removes all the assets in the container from the scene
  156. */
  157. removeAllFromScene(): void;
  158. private _moveAssets;
  159. /**
  160. * Removes all the assets contained in the scene and adds them to the container.
  161. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  162. */
  163. moveAllFromScene(keepAssets?: KeepAssets): void;
  164. /**
  165. * 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.
  166. * @returns the root mesh
  167. */
  168. createRootMesh(): Mesh;
  169. }
  170. }
  171. interface Window {
  172. mozIndexedDB: IDBFactory;
  173. webkitIndexedDB: IDBFactory;
  174. msIndexedDB: IDBFactory;
  175. webkitURL: typeof URL;
  176. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  177. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  178. WebGLRenderingContext: WebGLRenderingContext;
  179. MSGesture: MSGesture;
  180. CANNON: any;
  181. AudioContext: AudioContext;
  182. webkitAudioContext: AudioContext;
  183. PointerEvent: any;
  184. Math: Math;
  185. Uint8Array: Uint8ArrayConstructor;
  186. Float32Array: Float32ArrayConstructor;
  187. mozURL: typeof URL;
  188. msURL: typeof URL;
  189. VRFrameData: any;
  190. DracoDecoderModule: any;
  191. setImmediate(handler: (...args: any[]) => void): number;
  192. }
  193. interface WebGLProgram {
  194. context?: WebGLRenderingContext;
  195. vertexShader?: WebGLShader;
  196. fragmentShader?: WebGLShader;
  197. isParallelCompiled: boolean;
  198. onCompiled?: () => void;
  199. }
  200. interface WebGLRenderingContext {
  201. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  202. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  203. vertexAttribDivisor(index: number, divisor: number): void;
  204. createVertexArray(): any;
  205. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  206. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  207. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  208. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  209. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  210. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  211. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  212. createQuery(): WebGLQuery;
  213. deleteQuery(query: WebGLQuery): void;
  214. beginQuery(target: number, query: WebGLQuery): void;
  215. endQuery(target: number): void;
  216. getQueryParameter(query: WebGLQuery, pname: number): any;
  217. getQuery(target: number, pname: number): any;
  218. MAX_SAMPLES: number;
  219. RGBA8: number;
  220. READ_FRAMEBUFFER: number;
  221. DRAW_FRAMEBUFFER: number;
  222. UNIFORM_BUFFER: number;
  223. HALF_FLOAT_OES: number;
  224. RGBA16F: number;
  225. RGBA32F: number;
  226. R32F: number;
  227. RG32F: number;
  228. RGB32F: number;
  229. R16F: number;
  230. RG16F: number;
  231. RGB16F: number;
  232. RED: number;
  233. RG: number;
  234. R8: number;
  235. RG8: number;
  236. UNSIGNED_INT_24_8: number;
  237. DEPTH24_STENCIL8: number;
  238. drawBuffers(buffers: number[]): void;
  239. readBuffer(src: number): void;
  240. readonly COLOR_ATTACHMENT0: number;
  241. readonly COLOR_ATTACHMENT1: number;
  242. readonly COLOR_ATTACHMENT2: number;
  243. readonly COLOR_ATTACHMENT3: number;
  244. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  245. ANY_SAMPLES_PASSED: number;
  246. QUERY_RESULT_AVAILABLE: number;
  247. QUERY_RESULT: number;
  248. }
  249. interface Document {
  250. mozCancelFullScreen(): void;
  251. msCancelFullScreen(): void;
  252. webkitCancelFullScreen(): void;
  253. requestPointerLock(): void;
  254. exitPointerLock(): void;
  255. fullscreen: boolean;
  256. mozFullScreen: boolean;
  257. msIsFullScreen: boolean;
  258. readonly webkitIsFullScreen: boolean;
  259. readonly pointerLockElement: Element;
  260. mozPointerLockElement: HTMLElement;
  261. msPointerLockElement: HTMLElement;
  262. webkitPointerLockElement: HTMLElement;
  263. }
  264. interface HTMLCanvasElement {
  265. requestPointerLock(): void;
  266. msRequestPointerLock?(): void;
  267. mozRequestPointerLock?(): void;
  268. webkitRequestPointerLock?(): void;
  269. }
  270. interface CanvasRenderingContext2D {
  271. msImageSmoothingEnabled: boolean;
  272. }
  273. interface WebGLBuffer {
  274. references: number;
  275. capacity: number;
  276. is32Bits: boolean;
  277. }
  278. interface WebGLProgram {
  279. transformFeedback?: WebGLTransformFeedback | null;
  280. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  281. }
  282. interface MouseEvent {
  283. mozMovementX: number;
  284. mozMovementY: number;
  285. webkitMovementX: number;
  286. webkitMovementY: number;
  287. msMovementX: number;
  288. msMovementY: number;
  289. }
  290. interface Navigator {
  291. mozGetVRDevices: (any: any) => any;
  292. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  293. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  294. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  295. webkitGetGamepads(): Gamepad[];
  296. msGetGamepads(): Gamepad[];
  297. webkitGamepads(): Gamepad[];
  298. }
  299. interface HTMLVideoElement {
  300. mozSrcObject: any;
  301. }
  302. interface Element {
  303. webkitRequestFullScreen: () => void;
  304. }
  305. interface Screen {
  306. readonly orientation: string;
  307. readonly mozOrientation: string;
  308. }
  309. interface Math {
  310. fround(x: number): number;
  311. imul(a: number, b: number): number;
  312. }
  313. interface EXT_disjoint_timer_query {
  314. QUERY_COUNTER_BITS_EXT: number;
  315. TIME_ELAPSED_EXT: number;
  316. TIMESTAMP_EXT: number;
  317. GPU_DISJOINT_EXT: number;
  318. QUERY_RESULT_EXT: number;
  319. QUERY_RESULT_AVAILABLE_EXT: number;
  320. queryCounterEXT(query: WebGLQuery, target: number): void;
  321. createQueryEXT(): WebGLQuery;
  322. beginQueryEXT(target: number, query: WebGLQuery): void;
  323. endQueryEXT(target: number): void;
  324. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  325. deleteQueryEXT(query: WebGLQuery): void;
  326. }
  327. interface WebGLUniformLocation {
  328. _currentState: any;
  329. }
  330. declare module BABYLON {
  331. /**
  332. * Defines how a node can be built from a string name.
  333. */
  334. type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  335. /**
  336. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  337. */
  338. class Node implements IBehaviorAware<Node> {
  339. private static _NodeConstructors;
  340. /**
  341. * Add a new node constructor
  342. * @param type defines the type name of the node to construct
  343. * @param constructorFunc defines the constructor function
  344. */
  345. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  346. /**
  347. * Returns a node constructor based on type name
  348. * @param type defines the type name
  349. * @param name defines the new node name
  350. * @param scene defines the hosting scene
  351. * @param options defines optional options to transmit to constructors
  352. * @returns the new constructor or null
  353. */
  354. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  355. /**
  356. * Gets or sets the name of the node
  357. */
  358. name: string;
  359. /**
  360. * Gets or sets the id of the node
  361. */
  362. id: string;
  363. /**
  364. * Gets or sets the unique id of the node
  365. */
  366. uniqueId: number;
  367. /**
  368. * Gets or sets a string used to store user defined state for the node
  369. */
  370. state: string;
  371. /**
  372. * Gets or sets an object used to store user defined information for the node
  373. */
  374. metadata: any;
  375. /**
  376. * Gets or sets a boolean used to define if the node must be serialized
  377. */
  378. doNotSerialize: boolean;
  379. /** @hidden */
  380. _isDisposed: boolean;
  381. /**
  382. * Gets a list of Animations associated with the node
  383. */
  384. animations: Animation[];
  385. protected _ranges: {
  386. [name: string]: Nullable<AnimationRange>;
  387. };
  388. /**
  389. * Callback raised when the node is ready to be used
  390. */
  391. onReady: (node: Node) => void;
  392. private _isEnabled;
  393. private _isParentEnabled;
  394. private _isReady;
  395. /** @hidden */
  396. _currentRenderId: number;
  397. private _parentRenderId;
  398. protected _childRenderId: number;
  399. /** @hidden */
  400. _waitingParentId: Nullable<string>;
  401. /** @hidden */
  402. _scene: Scene;
  403. /** @hidden */
  404. _cache: any;
  405. private _parentNode;
  406. private _children;
  407. /** @hidden */
  408. _worldMatrix: Matrix;
  409. /** @hidden */
  410. _worldMatrixDeterminant: number;
  411. /** @hidden */
  412. private _sceneRootNodesIndex;
  413. /**
  414. * Gets a boolean indicating if the node has been disposed
  415. * @returns true if the node was disposed
  416. */
  417. isDisposed(): boolean;
  418. /**
  419. * Gets or sets the parent of the node
  420. */
  421. parent: Nullable<Node>;
  422. private addToSceneRootNodes;
  423. private removeFromSceneRootNodes;
  424. private _animationPropertiesOverride;
  425. /**
  426. * Gets or sets the animation properties override
  427. */
  428. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  429. /**
  430. * Gets a string idenfifying the name of the class
  431. * @returns "Node" string
  432. */
  433. getClassName(): string;
  434. /**
  435. * An event triggered when the mesh is disposed
  436. */
  437. onDisposeObservable: Observable<Node>;
  438. private _onDisposeObserver;
  439. /**
  440. * Sets a callback that will be raised when the node will be disposed
  441. */
  442. onDispose: () => void;
  443. /**
  444. * Creates a new Node
  445. * @param name the name and id to be given to this node
  446. * @param scene the scene this node will be added to
  447. */
  448. constructor(name: string, scene?: Nullable<Scene>);
  449. /**
  450. * Gets the scene of the node
  451. * @returns a scene
  452. */
  453. getScene(): Scene;
  454. /**
  455. * Gets the engine of the node
  456. * @returns a Engine
  457. */
  458. getEngine(): Engine;
  459. private _behaviors;
  460. /**
  461. * Attach a behavior to the node
  462. * @see http://doc.babylonjs.com/features/behaviour
  463. * @param behavior defines the behavior to attach
  464. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  465. * @returns the current Node
  466. */
  467. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  468. /**
  469. * Remove an attached behavior
  470. * @see http://doc.babylonjs.com/features/behaviour
  471. * @param behavior defines the behavior to attach
  472. * @returns the current Node
  473. */
  474. removeBehavior(behavior: Behavior<Node>): Node;
  475. /**
  476. * Gets the list of attached behaviors
  477. * @see http://doc.babylonjs.com/features/behaviour
  478. */
  479. readonly behaviors: Behavior<Node>[];
  480. /**
  481. * Gets an attached behavior by name
  482. * @param name defines the name of the behavior to look for
  483. * @see http://doc.babylonjs.com/features/behaviour
  484. * @returns null if behavior was not found else the requested behavior
  485. */
  486. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  487. /**
  488. * Returns the latest update of the World matrix
  489. * @returns a Matrix
  490. */
  491. getWorldMatrix(): Matrix;
  492. /** @hidden */
  493. _getWorldMatrixDeterminant(): number;
  494. /**
  495. * Returns directly the latest state of the mesh World matrix.
  496. * A Matrix is returned.
  497. */
  498. readonly worldMatrixFromCache: Matrix;
  499. /** @hidden */
  500. _initCache(): void;
  501. /** @hidden */
  502. updateCache(force?: boolean): void;
  503. /** @hidden */
  504. _updateCache(ignoreParentClass?: boolean): void;
  505. /** @hidden */
  506. _isSynchronized(): boolean;
  507. /** @hidden */
  508. _markSyncedWithParent(): void;
  509. /** @hidden */
  510. isSynchronizedWithParent(): boolean;
  511. /** @hidden */
  512. isSynchronized(): boolean;
  513. /**
  514. * Is this node ready to be used/rendered
  515. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  516. * @return true if the node is ready
  517. */
  518. isReady(completeCheck?: boolean): boolean;
  519. /**
  520. * Is this node enabled?
  521. * 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
  522. * @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
  523. * @return whether this node (and its parent) is enabled
  524. */
  525. isEnabled(checkAncestors?: boolean): boolean;
  526. /** @hidden */
  527. protected _syncParentEnabledState(): void;
  528. /**
  529. * Set the enabled state of this node
  530. * @param value defines the new enabled state
  531. */
  532. setEnabled(value: boolean): void;
  533. /**
  534. * Is this node a descendant of the given node?
  535. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  536. * @param ancestor defines the parent node to inspect
  537. * @returns a boolean indicating if this node is a descendant of the given node
  538. */
  539. isDescendantOf(ancestor: Node): boolean;
  540. /** @hidden */
  541. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  542. /**
  543. * Will return all nodes that have this node as ascendant
  544. * @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
  545. * @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
  546. * @return all children nodes of all types
  547. */
  548. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  549. /**
  550. * Get all child-meshes of this node
  551. * @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
  552. * @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
  553. * @returns an array of AbstractMesh
  554. */
  555. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  556. /**
  557. * Get all child-transformNodes of this node
  558. * @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
  559. * @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
  560. * @returns an array of TransformNode
  561. */
  562. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  563. /**
  564. * Get all direct children of this node
  565. * @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
  566. * @returns an array of Node
  567. */
  568. getChildren(predicate?: (node: Node) => boolean): Node[];
  569. /** @hidden */
  570. _setReady(state: boolean): void;
  571. /**
  572. * Get an animation by name
  573. * @param name defines the name of the animation to look for
  574. * @returns null if not found else the requested animation
  575. */
  576. getAnimationByName(name: string): Nullable<Animation>;
  577. /**
  578. * Creates an animation range for this node
  579. * @param name defines the name of the range
  580. * @param from defines the starting key
  581. * @param to defines the end key
  582. */
  583. createAnimationRange(name: string, from: number, to: number): void;
  584. /**
  585. * Delete a specific animation range
  586. * @param name defines the name of the range to delete
  587. * @param deleteFrames defines if animation frames from the range must be deleted as well
  588. */
  589. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  590. /**
  591. * Get an animation range by name
  592. * @param name defines the name of the animation range to look for
  593. * @returns null if not found else the requested animation range
  594. */
  595. getAnimationRange(name: string): Nullable<AnimationRange>;
  596. /**
  597. * Will start the animation sequence
  598. * @param name defines the range frames for animation sequence
  599. * @param loop defines if the animation should loop (false by default)
  600. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  601. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  602. * @returns the object created for this animation. If range does not exist, it will return null
  603. */
  604. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  605. /**
  606. * Serialize animation ranges into a JSON compatible object
  607. * @returns serialization object
  608. */
  609. serializeAnimationRanges(): any;
  610. /**
  611. * Computes the world matrix of the node
  612. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  613. * @returns the world matrix
  614. */
  615. computeWorldMatrix(force?: boolean): Matrix;
  616. /**
  617. * Releases resources associated with this node.
  618. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  619. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  620. */
  621. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  622. /**
  623. * Parse animation range data from a serialization object and store them into a given node
  624. * @param node defines where to store the animation ranges
  625. * @param parsedNode defines the serialization object to read data from
  626. * @param scene defines the hosting scene
  627. */
  628. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  629. }
  630. }
  631. declare module BABYLON {
  632. /**
  633. * Define an interface for all classes that will hold resources
  634. */
  635. interface IDisposable {
  636. /**
  637. * Releases all held resources
  638. */
  639. dispose(): void;
  640. }
  641. /**
  642. * This class is used by the onRenderingGroupObservable
  643. */
  644. class RenderingGroupInfo {
  645. /**
  646. * The Scene that being rendered
  647. */
  648. scene: Scene;
  649. /**
  650. * The camera currently used for the rendering pass
  651. */
  652. camera: Nullable<Camera>;
  653. /**
  654. * The ID of the renderingGroup being processed
  655. */
  656. renderingGroupId: number;
  657. }
  658. /** Interface defining initialization parameters for Scene class */
  659. interface SceneOptions {
  660. /**
  661. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by Id
  662. * It will improve performance when the number of geometries becomes important.
  663. */
  664. useGeometryIdsMap?: boolean;
  665. }
  666. /**
  667. * Represents a scene to be rendered by the engine.
  668. * @see http://doc.babylonjs.com/features/scene
  669. */
  670. class Scene extends AbstractScene implements IAnimatable {
  671. private static _uniqueIdCounter;
  672. /** The fog is deactivated */
  673. static readonly FOGMODE_NONE: number;
  674. /** The fog density is following an exponential function */
  675. static readonly FOGMODE_EXP: number;
  676. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  677. static readonly FOGMODE_EXP2: number;
  678. /** The fog density is following a linear function. */
  679. static readonly FOGMODE_LINEAR: number;
  680. /**
  681. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  682. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  683. */
  684. static MinDeltaTime: number;
  685. /**
  686. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  687. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  688. */
  689. static MaxDeltaTime: number;
  690. /**
  691. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  692. */
  693. autoClear: boolean;
  694. /**
  695. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  696. */
  697. autoClearDepthAndStencil: boolean;
  698. /**
  699. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  700. */
  701. clearColor: Color4;
  702. /**
  703. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  704. */
  705. ambientColor: Color3;
  706. /** @hidden */
  707. _environmentBRDFTexture: BaseTexture;
  708. /** @hidden */
  709. protected _environmentTexture: BaseTexture;
  710. /**
  711. * Texture used in all pbr material as the reflection texture.
  712. * As in the majority of the scene they are the same (exception for multi room and so on),
  713. * this is easier to reference from here than from all the materials.
  714. */
  715. /**
  716. * Texture used in all pbr material as the reflection texture.
  717. * As in the majority of the scene they are the same (exception for multi room and so on),
  718. * this is easier to set here than in all the materials.
  719. */
  720. environmentTexture: BaseTexture;
  721. /** @hidden */
  722. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  723. /**
  724. * Default image processing configuration used either in the rendering
  725. * Forward main pass or through the imageProcessingPostProcess if present.
  726. * As in the majority of the scene they are the same (exception for multi camera),
  727. * this is easier to reference from here than from all the materials and post process.
  728. *
  729. * No setter as we it is a shared configuration, you can set the values instead.
  730. */
  731. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  732. private _forceWireframe;
  733. /**
  734. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  735. */
  736. forceWireframe: boolean;
  737. private _forcePointsCloud;
  738. /**
  739. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  740. */
  741. forcePointsCloud: boolean;
  742. /**
  743. * Gets or sets the active clipplane 1
  744. */
  745. clipPlane: Nullable<Plane>;
  746. /**
  747. * Gets or sets the active clipplane 2
  748. */
  749. clipPlane2: Nullable<Plane>;
  750. /**
  751. * Gets or sets the active clipplane 3
  752. */
  753. clipPlane3: Nullable<Plane>;
  754. /**
  755. * Gets or sets the active clipplane 4
  756. */
  757. clipPlane4: Nullable<Plane>;
  758. /**
  759. * Gets or sets a boolean indicating if animations are enabled
  760. */
  761. animationsEnabled: boolean;
  762. private _animationPropertiesOverride;
  763. /**
  764. * Gets or sets the animation properties override
  765. */
  766. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  767. /**
  768. * Gets or sets a boolean indicating if a constant deltatime has to be used
  769. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  770. */
  771. useConstantAnimationDeltaTime: boolean;
  772. /**
  773. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  774. * Please note that it requires to run a ray cast through the scene on every frame
  775. */
  776. constantlyUpdateMeshUnderPointer: boolean;
  777. /**
  778. * Defines the HTML cursor to use when hovering over interactive elements
  779. */
  780. hoverCursor: string;
  781. /**
  782. * Defines the HTML default cursor to use (empty by default)
  783. */
  784. defaultCursor: string;
  785. /**
  786. * This is used to call preventDefault() on pointer down
  787. * in order to block unwanted artifacts like system double clicks
  788. */
  789. preventDefaultOnPointerDown: boolean;
  790. /**
  791. * Gets or sets user defined metadata
  792. */
  793. metadata: any;
  794. /**
  795. * Gets the name of the plugin used to load this scene (null by default)
  796. */
  797. loadingPluginName: string;
  798. /**
  799. * Use this array to add regular expressions used to disable offline support for specific urls
  800. */
  801. disableOfflineSupportExceptionRules: RegExp[];
  802. /**
  803. * An event triggered when the scene is disposed.
  804. */
  805. onDisposeObservable: Observable<Scene>;
  806. private _onDisposeObserver;
  807. /** Sets a function to be executed when this scene is disposed. */
  808. onDispose: () => void;
  809. /**
  810. * An event triggered before rendering the scene (right after animations and physics)
  811. */
  812. onBeforeRenderObservable: Observable<Scene>;
  813. private _onBeforeRenderObserver;
  814. /** Sets a function to be executed before rendering this scene */
  815. beforeRender: Nullable<() => void>;
  816. /**
  817. * An event triggered after rendering the scene
  818. */
  819. onAfterRenderObservable: Observable<Scene>;
  820. private _onAfterRenderObserver;
  821. /** Sets a function to be executed after rendering this scene */
  822. afterRender: Nullable<() => void>;
  823. /**
  824. * An event triggered before animating the scene
  825. */
  826. onBeforeAnimationsObservable: Observable<Scene>;
  827. /**
  828. * An event triggered after animations processing
  829. */
  830. onAfterAnimationsObservable: Observable<Scene>;
  831. /**
  832. * An event triggered before draw calls are ready to be sent
  833. */
  834. onBeforeDrawPhaseObservable: Observable<Scene>;
  835. /**
  836. * An event triggered after draw calls have been sent
  837. */
  838. onAfterDrawPhaseObservable: Observable<Scene>;
  839. /**
  840. * An event triggered when the scene is ready
  841. */
  842. onReadyObservable: Observable<Scene>;
  843. /**
  844. * An event triggered before rendering a camera
  845. */
  846. onBeforeCameraRenderObservable: Observable<Camera>;
  847. private _onBeforeCameraRenderObserver;
  848. /** Sets a function to be executed before rendering a camera*/
  849. beforeCameraRender: () => void;
  850. /**
  851. * An event triggered after rendering a camera
  852. */
  853. onAfterCameraRenderObservable: Observable<Camera>;
  854. private _onAfterCameraRenderObserver;
  855. /** Sets a function to be executed after rendering a camera*/
  856. afterCameraRender: () => void;
  857. /**
  858. * An event triggered when active meshes evaluation is about to start
  859. */
  860. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  861. /**
  862. * An event triggered when active meshes evaluation is done
  863. */
  864. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  865. /**
  866. * An event triggered when particles rendering is about to start
  867. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  868. */
  869. onBeforeParticlesRenderingObservable: Observable<Scene>;
  870. /**
  871. * An event triggered when particles rendering is done
  872. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  873. */
  874. onAfterParticlesRenderingObservable: Observable<Scene>;
  875. /**
  876. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  877. */
  878. onDataLoadedObservable: Observable<Scene>;
  879. /**
  880. * An event triggered when a camera is created
  881. */
  882. onNewCameraAddedObservable: Observable<Camera>;
  883. /**
  884. * An event triggered when a camera is removed
  885. */
  886. onCameraRemovedObservable: Observable<Camera>;
  887. /**
  888. * An event triggered when a light is created
  889. */
  890. onNewLightAddedObservable: Observable<Light>;
  891. /**
  892. * An event triggered when a light is removed
  893. */
  894. onLightRemovedObservable: Observable<Light>;
  895. /**
  896. * An event triggered when a geometry is created
  897. */
  898. onNewGeometryAddedObservable: Observable<Geometry>;
  899. /**
  900. * An event triggered when a geometry is removed
  901. */
  902. onGeometryRemovedObservable: Observable<Geometry>;
  903. /**
  904. * An event triggered when a transform node is created
  905. */
  906. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  907. /**
  908. * An event triggered when a transform node is removed
  909. */
  910. onTransformNodeRemovedObservable: Observable<TransformNode>;
  911. /**
  912. * An event triggered when a mesh is created
  913. */
  914. onNewMeshAddedObservable: Observable<AbstractMesh>;
  915. /**
  916. * An event triggered when a mesh is removed
  917. */
  918. onMeshRemovedObservable: Observable<AbstractMesh>;
  919. /**
  920. * An event triggered when a material is created
  921. */
  922. onNewMaterialAddedObservable: Observable<Material>;
  923. /**
  924. * An event triggered when a material is removed
  925. */
  926. onMaterialRemovedObservable: Observable<Material>;
  927. /**
  928. * An event triggered when a texture is created
  929. */
  930. onNewTextureAddedObservable: Observable<BaseTexture>;
  931. /**
  932. * An event triggered when a texture is removed
  933. */
  934. onTextureRemovedObservable: Observable<BaseTexture>;
  935. /**
  936. * An event triggered when render targets are about to be rendered
  937. * Can happen multiple times per frame.
  938. */
  939. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  940. /**
  941. * An event triggered when render targets were rendered.
  942. * Can happen multiple times per frame.
  943. */
  944. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  945. /**
  946. * An event triggered before calculating deterministic simulation step
  947. */
  948. onBeforeStepObservable: Observable<Scene>;
  949. /**
  950. * An event triggered after calculating deterministic simulation step
  951. */
  952. onAfterStepObservable: Observable<Scene>;
  953. /**
  954. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  955. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  956. * 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)
  957. */
  958. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  959. /**
  960. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  961. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  962. * 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)
  963. */
  964. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  965. /**
  966. * This Observable will when a mesh has been imported into the scene.
  967. */
  968. onMeshImportedObservable: Observable<AbstractMesh>;
  969. private _registeredForLateAnimationBindings;
  970. /**
  971. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  972. */
  973. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  974. /**
  975. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  976. */
  977. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  978. /**
  979. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  980. */
  981. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  982. private _onPointerMove;
  983. private _onPointerDown;
  984. private _onPointerUp;
  985. /** Deprecated. Use onPointerObservable instead */
  986. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  987. /** Deprecated. Use onPointerObservable instead */
  988. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  989. /** Deprecated. Use onPointerObservable instead */
  990. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  991. /** Deprecated. Use onPointerObservable instead */
  992. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  993. /**
  994. * 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).
  995. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  996. */
  997. onPrePointerObservable: Observable<PointerInfoPre>;
  998. /**
  999. * Observable event triggered each time an input event is received from the rendering canvas
  1000. */
  1001. onPointerObservable: Observable<PointerInfo>;
  1002. /**
  1003. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  1004. */
  1005. readonly unTranslatedPointer: Vector2;
  1006. /** The distance in pixel that you have to move to prevent some events */
  1007. static DragMovementThreshold: number;
  1008. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  1009. static LongPressDelay: number;
  1010. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  1011. static DoubleClickDelay: number;
  1012. /** If you need to check double click without raising a single click at first click, enable this flag */
  1013. static ExclusiveDoubleClickMode: boolean;
  1014. private _initClickEvent;
  1015. private _initActionManager;
  1016. private _delayedSimpleClick;
  1017. private _delayedSimpleClickTimeout;
  1018. private _previousDelayedSimpleClickTimeout;
  1019. private _meshPickProceed;
  1020. private _previousButtonPressed;
  1021. private _currentPickResult;
  1022. private _previousPickResult;
  1023. private _totalPointersPressed;
  1024. private _doubleClickOccured;
  1025. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  1026. cameraToUseForPointers: Nullable<Camera>;
  1027. private _pointerX;
  1028. private _pointerY;
  1029. private _unTranslatedPointerX;
  1030. private _unTranslatedPointerY;
  1031. private _startingPointerPosition;
  1032. private _previousStartingPointerPosition;
  1033. private _startingPointerTime;
  1034. private _previousStartingPointerTime;
  1035. private _pointerCaptures;
  1036. private _timeAccumulator;
  1037. private _currentStepId;
  1038. private _currentInternalStep;
  1039. /** @hidden */
  1040. _mirroredCameraPosition: Nullable<Vector3>;
  1041. /**
  1042. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  1043. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  1044. */
  1045. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  1046. /**
  1047. * Observable event triggered each time an keyboard event is received from the hosting window
  1048. */
  1049. onKeyboardObservable: Observable<KeyboardInfo>;
  1050. private _onKeyDown;
  1051. private _onKeyUp;
  1052. private _onCanvasFocusObserver;
  1053. private _onCanvasBlurObserver;
  1054. private _useRightHandedSystem;
  1055. /**
  1056. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  1057. */
  1058. useRightHandedSystem: boolean;
  1059. /**
  1060. * Sets the step Id used by deterministic lock step
  1061. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1062. * @param newStepId defines the step Id
  1063. */
  1064. setStepId(newStepId: number): void;
  1065. /**
  1066. * Gets the step Id used by deterministic lock step
  1067. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1068. * @returns the step Id
  1069. */
  1070. getStepId(): number;
  1071. /**
  1072. * Gets the internal step used by deterministic lock step
  1073. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1074. * @returns the internal step
  1075. */
  1076. getInternalStep(): number;
  1077. private _fogEnabled;
  1078. /**
  1079. * Gets or sets a boolean indicating if fog is enabled on this scene
  1080. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1081. * (Default is true)
  1082. */
  1083. fogEnabled: boolean;
  1084. private _fogMode;
  1085. /**
  1086. * Gets or sets the fog mode to use
  1087. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1088. * | mode | value |
  1089. * | --- | --- |
  1090. * | FOGMODE_NONE | 0 |
  1091. * | FOGMODE_EXP | 1 |
  1092. * | FOGMODE_EXP2 | 2 |
  1093. * | FOGMODE_LINEAR | 3 |
  1094. */
  1095. fogMode: number;
  1096. /**
  1097. * Gets or sets the fog color to use
  1098. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1099. * (Default is Color3(0.2, 0.2, 0.3))
  1100. */
  1101. fogColor: Color3;
  1102. /**
  1103. * Gets or sets the fog density to use
  1104. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1105. * (Default is 0.1)
  1106. */
  1107. fogDensity: number;
  1108. /**
  1109. * Gets or sets the fog start distance to use
  1110. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1111. * (Default is 0)
  1112. */
  1113. fogStart: number;
  1114. /**
  1115. * Gets or sets the fog end distance to use
  1116. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1117. * (Default is 1000)
  1118. */
  1119. fogEnd: number;
  1120. private _shadowsEnabled;
  1121. /**
  1122. * Gets or sets a boolean indicating if shadows are enabled on this scene
  1123. */
  1124. shadowsEnabled: boolean;
  1125. private _lightsEnabled;
  1126. /**
  1127. * Gets or sets a boolean indicating if lights are enabled on this scene
  1128. */
  1129. lightsEnabled: boolean;
  1130. /** All of the active cameras added to this scene. */
  1131. activeCameras: Camera[];
  1132. /** The current active camera */
  1133. activeCamera: Nullable<Camera>;
  1134. private _defaultMaterial;
  1135. /** The default material used on meshes when no material is affected */
  1136. /** The default material used on meshes when no material is affected */
  1137. defaultMaterial: Material;
  1138. private _texturesEnabled;
  1139. /**
  1140. * Gets or sets a boolean indicating if textures are enabled on this scene
  1141. */
  1142. texturesEnabled: boolean;
  1143. /**
  1144. * Gets or sets a boolean indicating if particles are enabled on this scene
  1145. */
  1146. particlesEnabled: boolean;
  1147. /**
  1148. * Gets or sets a boolean indicating if sprites are enabled on this scene
  1149. */
  1150. spritesEnabled: boolean;
  1151. private _skeletonsEnabled;
  1152. /**
  1153. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  1154. */
  1155. skeletonsEnabled: boolean;
  1156. /**
  1157. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  1158. */
  1159. lensFlaresEnabled: boolean;
  1160. /**
  1161. * Gets or sets a boolean indicating if collisions are enabled on this scene
  1162. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1163. */
  1164. collisionsEnabled: boolean;
  1165. private _workerCollisions;
  1166. /** @hidden */
  1167. collisionCoordinator: ICollisionCoordinator;
  1168. /**
  1169. * Defines the gravity applied to this scene (used only for collisions)
  1170. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1171. */
  1172. gravity: Vector3;
  1173. /**
  1174. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  1175. */
  1176. postProcessesEnabled: boolean;
  1177. /**
  1178. * The list of postprocesses added to the scene
  1179. */
  1180. postProcesses: PostProcess[];
  1181. /**
  1182. * Gets the current postprocess manager
  1183. */
  1184. postProcessManager: PostProcessManager;
  1185. /**
  1186. * Gets or sets a boolean indicating if render targets are enabled on this scene
  1187. */
  1188. renderTargetsEnabled: boolean;
  1189. /**
  1190. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  1191. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  1192. */
  1193. dumpNextRenderTargets: boolean;
  1194. /**
  1195. * The list of user defined render targets added to the scene
  1196. */
  1197. customRenderTargets: RenderTargetTexture[];
  1198. /**
  1199. * Defines if texture loading must be delayed
  1200. * If true, textures will only be loaded when they need to be rendered
  1201. */
  1202. useDelayedTextureLoading: boolean;
  1203. /**
  1204. * Gets the list of meshes imported to the scene through SceneLoader
  1205. */
  1206. importedMeshesFiles: String[];
  1207. /**
  1208. * Gets or sets a boolean indicating if probes are enabled on this scene
  1209. */
  1210. probesEnabled: boolean;
  1211. /**
  1212. * @hidden
  1213. */
  1214. database: Database;
  1215. /**
  1216. * Gets or sets the action manager associated with the scene
  1217. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1218. */
  1219. actionManager: ActionManager;
  1220. private _meshesForIntersections;
  1221. /**
  1222. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  1223. */
  1224. proceduralTexturesEnabled: boolean;
  1225. private _engine;
  1226. private _totalVertices;
  1227. /** @hidden */
  1228. _activeIndices: PerfCounter;
  1229. /** @hidden */
  1230. _activeParticles: PerfCounter;
  1231. /** @hidden */
  1232. _activeBones: PerfCounter;
  1233. private _animationRatio;
  1234. private _animationTimeLast;
  1235. private _animationTime;
  1236. /**
  1237. * Gets or sets a general scale for animation speed
  1238. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  1239. */
  1240. animationTimeScale: number;
  1241. /** @hidden */
  1242. _cachedMaterial: Nullable<Material>;
  1243. /** @hidden */
  1244. _cachedEffect: Nullable<Effect>;
  1245. /** @hidden */
  1246. _cachedVisibility: Nullable<number>;
  1247. private _renderId;
  1248. private _frameId;
  1249. private _executeWhenReadyTimeoutId;
  1250. private _intermediateRendering;
  1251. private _viewUpdateFlag;
  1252. private _projectionUpdateFlag;
  1253. private _alternateViewUpdateFlag;
  1254. private _alternateProjectionUpdateFlag;
  1255. /** @hidden */
  1256. _toBeDisposed: Nullable<IDisposable>[];
  1257. private _activeRequests;
  1258. private _pendingData;
  1259. private _isDisposed;
  1260. /**
  1261. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  1262. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  1263. */
  1264. dispatchAllSubMeshesOfActiveMeshes: boolean;
  1265. private _activeMeshes;
  1266. private _processedMaterials;
  1267. private _renderTargets;
  1268. /** @hidden */
  1269. _activeParticleSystems: SmartArray<IParticleSystem>;
  1270. private _activeSkeletons;
  1271. private _softwareSkinnedMeshes;
  1272. private _renderingManager;
  1273. /** @hidden */
  1274. _activeAnimatables: Animatable[];
  1275. private _transformMatrix;
  1276. private _sceneUbo;
  1277. private _alternateSceneUbo;
  1278. private _pickWithRayInverseMatrix;
  1279. private _viewMatrix;
  1280. private _projectionMatrix;
  1281. private _alternateViewMatrix;
  1282. private _alternateProjectionMatrix;
  1283. private _alternateTransformMatrix;
  1284. private _useAlternateCameraConfiguration;
  1285. private _alternateRendering;
  1286. /** @hidden */
  1287. _forcedViewPosition: Nullable<Vector3>;
  1288. /** @hidden */
  1289. readonly _isAlternateRenderingEnabled: boolean;
  1290. private _frustumPlanes;
  1291. /**
  1292. * Gets the list of frustum planes (built from the active camera)
  1293. */
  1294. readonly frustumPlanes: Plane[];
  1295. /**
  1296. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  1297. * This is useful if there are more lights that the maximum simulteanous authorized
  1298. */
  1299. requireLightSorting: boolean;
  1300. private _pointerOverMesh;
  1301. private _pickedDownMesh;
  1302. private _pickedUpMesh;
  1303. private _externalData;
  1304. private _uid;
  1305. /**
  1306. * @hidden
  1307. * Backing store of defined scene components.
  1308. */
  1309. _components: ISceneComponent[];
  1310. /**
  1311. * @hidden
  1312. * Backing store of defined scene components.
  1313. */
  1314. _serializableComponents: ISceneSerializableComponent[];
  1315. /**
  1316. * List of components to register on the next registration step.
  1317. */
  1318. private _transientComponents;
  1319. /**
  1320. * Registers the transient components if needed.
  1321. */
  1322. private _registerTransientComponents;
  1323. /**
  1324. * @hidden
  1325. * Add a component to the scene.
  1326. * Note that the ccomponent could be registered on th next frame if this is called after
  1327. * the register component stage.
  1328. * @param component Defines the component to add to the scene
  1329. */
  1330. _addComponent(component: ISceneComponent): void;
  1331. /**
  1332. * @hidden
  1333. * Gets a component from the scene.
  1334. * @param name defines the name of the component to retrieve
  1335. * @returns the component or null if not present
  1336. */
  1337. _getComponent(name: string): Nullable<ISceneComponent>;
  1338. /**
  1339. * @hidden
  1340. * Defines the actions happening before camera updates.
  1341. */
  1342. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  1343. /**
  1344. * @hidden
  1345. * Defines the actions happening before clear the canvas.
  1346. */
  1347. _beforeClearStage: Stage<SimpleStageAction>;
  1348. /**
  1349. * @hidden
  1350. * Defines the actions when collecting render targets for the frame.
  1351. */
  1352. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  1353. /**
  1354. * @hidden
  1355. * Defines the actions happening for one camera in the frame.
  1356. */
  1357. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  1358. /**
  1359. * @hidden
  1360. * Defines the actions happening during the per mesh ready checks.
  1361. */
  1362. _isReadyForMeshStage: Stage<MeshStageAction>;
  1363. /**
  1364. * @hidden
  1365. * Defines the actions happening before evaluate active mesh checks.
  1366. */
  1367. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  1368. /**
  1369. * @hidden
  1370. * Defines the actions happening during the evaluate sub mesh checks.
  1371. */
  1372. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  1373. /**
  1374. * @hidden
  1375. * Defines the actions happening during the active mesh stage.
  1376. */
  1377. _activeMeshStage: Stage<ActiveMeshStageAction>;
  1378. /**
  1379. * @hidden
  1380. * Defines the actions happening during the per camera render target step.
  1381. */
  1382. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  1383. /**
  1384. * @hidden
  1385. * Defines the actions happening just before the active camera is drawing.
  1386. */
  1387. _beforeCameraDrawStage: Stage<CameraStageAction>;
  1388. /**
  1389. * @hidden
  1390. * Defines the actions happening just before a rendering group is drawing.
  1391. */
  1392. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  1393. /**
  1394. * @hidden
  1395. * Defines the actions happening just before a mesh is drawing.
  1396. */
  1397. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  1398. /**
  1399. * @hidden
  1400. * Defines the actions happening just after a mesh has been drawn.
  1401. */
  1402. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  1403. /**
  1404. * @hidden
  1405. * Defines the actions happening just after a rendering group has been drawn.
  1406. */
  1407. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  1408. /**
  1409. * @hidden
  1410. * Defines the actions happening just after the active camera has been drawn.
  1411. */
  1412. _afterCameraDrawStage: Stage<CameraStageAction>;
  1413. /**
  1414. * @hidden
  1415. * Defines the actions happening just after rendering all cameras and computing intersections.
  1416. */
  1417. _afterRenderStage: Stage<SimpleStageAction>;
  1418. /**
  1419. * @hidden
  1420. * Defines the actions happening when a pointer move event happens.
  1421. */
  1422. _pointerMoveStage: Stage<PointerMoveStageAction>;
  1423. /**
  1424. * @hidden
  1425. * Defines the actions happening when a pointer down event happens.
  1426. */
  1427. _pointerDownStage: Stage<PointerUpDownStageAction>;
  1428. /**
  1429. * @hidden
  1430. * Defines the actions happening when a pointer up event happens.
  1431. */
  1432. _pointerUpStage: Stage<PointerUpDownStageAction>;
  1433. /**
  1434. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  1435. */
  1436. private geometriesById;
  1437. /**
  1438. * Creates a new Scene
  1439. * @param engine defines the engine to use to render this scene
  1440. */
  1441. constructor(engine: Engine, options?: SceneOptions);
  1442. private _defaultMeshCandidates;
  1443. /**
  1444. * @hidden
  1445. */
  1446. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  1447. private _defaultSubMeshCandidates;
  1448. /**
  1449. * @hidden
  1450. */
  1451. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  1452. /**
  1453. * Sets the default candidate providers for the scene.
  1454. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  1455. * and getCollidingSubMeshCandidates to their default function
  1456. */
  1457. setDefaultCandidateProviders(): void;
  1458. /**
  1459. * Gets a boolean indicating if collisions are processed on a web worker
  1460. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#web-worker-based-collision-system-since-21
  1461. */
  1462. workerCollisions: boolean;
  1463. /**
  1464. * Gets the mesh that is currently under the pointer
  1465. */
  1466. readonly meshUnderPointer: Nullable<AbstractMesh>;
  1467. /**
  1468. * Gets the current on-screen X position of the pointer
  1469. */
  1470. readonly pointerX: number;
  1471. /**
  1472. * Gets the current on-screen Y position of the pointer
  1473. */
  1474. readonly pointerY: number;
  1475. /**
  1476. * Gets the cached material (ie. the latest rendered one)
  1477. * @returns the cached material
  1478. */
  1479. getCachedMaterial(): Nullable<Material>;
  1480. /**
  1481. * Gets the cached effect (ie. the latest rendered one)
  1482. * @returns the cached effect
  1483. */
  1484. getCachedEffect(): Nullable<Effect>;
  1485. /**
  1486. * Gets the cached visibility state (ie. the latest rendered one)
  1487. * @returns the cached visibility state
  1488. */
  1489. getCachedVisibility(): Nullable<number>;
  1490. /**
  1491. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  1492. * @param material defines the current material
  1493. * @param effect defines the current effect
  1494. * @param visibility defines the current visibility state
  1495. * @returns true if one parameter is not cached
  1496. */
  1497. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  1498. /**
  1499. * Gets the engine associated with the scene
  1500. * @returns an Engine
  1501. */
  1502. getEngine(): Engine;
  1503. /**
  1504. * Gets the total number of vertices rendered per frame
  1505. * @returns the total number of vertices rendered per frame
  1506. */
  1507. getTotalVertices(): number;
  1508. /**
  1509. * Gets the performance counter for total vertices
  1510. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1511. */
  1512. readonly totalVerticesPerfCounter: PerfCounter;
  1513. /**
  1514. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  1515. * @returns the total number of active indices rendered per frame
  1516. */
  1517. getActiveIndices(): number;
  1518. /**
  1519. * Gets the performance counter for active indices
  1520. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1521. */
  1522. readonly totalActiveIndicesPerfCounter: PerfCounter;
  1523. /**
  1524. * Gets the total number of active particles rendered per frame
  1525. * @returns the total number of active particles rendered per frame
  1526. */
  1527. getActiveParticles(): number;
  1528. /**
  1529. * Gets the performance counter for active particles
  1530. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1531. */
  1532. readonly activeParticlesPerfCounter: PerfCounter;
  1533. /**
  1534. * Gets the total number of active bones rendered per frame
  1535. * @returns the total number of active bones rendered per frame
  1536. */
  1537. getActiveBones(): number;
  1538. /**
  1539. * Gets the performance counter for active bones
  1540. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1541. */
  1542. readonly activeBonesPerfCounter: PerfCounter;
  1543. /** @hidden */
  1544. getInterFramePerfCounter(): number;
  1545. /** @hidden */
  1546. readonly interFramePerfCounter: Nullable<PerfCounter>;
  1547. /** @hidden */
  1548. getLastFrameDuration(): number;
  1549. /** @hidden */
  1550. readonly lastFramePerfCounter: Nullable<PerfCounter>;
  1551. /** @hidden */
  1552. getEvaluateActiveMeshesDuration(): number;
  1553. /** @hidden */
  1554. readonly evaluateActiveMeshesDurationPerfCounter: Nullable<PerfCounter>;
  1555. /**
  1556. * Gets the array of active meshes
  1557. * @returns an array of AbstractMesh
  1558. */
  1559. getActiveMeshes(): SmartArray<AbstractMesh>;
  1560. /** @hidden */
  1561. getRenderTargetsDuration(): number;
  1562. /** @hidden */
  1563. getRenderDuration(): number;
  1564. /** @hidden */
  1565. readonly renderDurationPerfCounter: Nullable<PerfCounter>;
  1566. /** @hidden */
  1567. getParticlesDuration(): number;
  1568. /** @hidden */
  1569. readonly particlesDurationPerfCounter: Nullable<PerfCounter>;
  1570. /** @hidden */
  1571. getSpritesDuration(): number;
  1572. /** @hidden */
  1573. readonly spriteDuractionPerfCounter: Nullable<PerfCounter>;
  1574. /**
  1575. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  1576. * @returns a number
  1577. */
  1578. getAnimationRatio(): number;
  1579. /**
  1580. * Gets an unique Id for the current render phase
  1581. * @returns a number
  1582. */
  1583. getRenderId(): number;
  1584. /**
  1585. * Gets an unique Id for the current frame
  1586. * @returns a number
  1587. */
  1588. getFrameId(): number;
  1589. /** Call this function if you want to manually increment the render Id*/
  1590. incrementRenderId(): void;
  1591. private _updatePointerPosition;
  1592. private _createUbo;
  1593. private _createAlternateUbo;
  1594. private _setRayOnPointerInfo;
  1595. /**
  1596. * Use this method to simulate a pointer move on a mesh
  1597. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1598. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1599. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1600. * @returns the current scene
  1601. */
  1602. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1603. private _processPointerMove;
  1604. private _checkPrePointerObservable;
  1605. /**
  1606. * Use this method to simulate a pointer down on a mesh
  1607. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1608. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1609. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1610. * @returns the current scene
  1611. */
  1612. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1613. private _processPointerDown;
  1614. /**
  1615. * Use this method to simulate a pointer up on a mesh
  1616. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1617. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1618. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1619. * @returns the current scene
  1620. */
  1621. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1622. private _processPointerUp;
  1623. /**
  1624. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  1625. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  1626. * @returns true if the pointer was captured
  1627. */
  1628. isPointerCaptured(pointerId?: number): boolean;
  1629. /** @hidden */
  1630. _isPointerSwiping(): boolean;
  1631. /**
  1632. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  1633. * @param attachUp defines if you want to attach events to pointerup
  1634. * @param attachDown defines if you want to attach events to pointerdown
  1635. * @param attachMove defines if you want to attach events to pointermove
  1636. */
  1637. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  1638. /** Detaches all event handlers*/
  1639. detachControl(): void;
  1640. /**
  1641. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  1642. * Delay loaded resources are not taking in account
  1643. * @return true if all required resources are ready
  1644. */
  1645. isReady(): boolean;
  1646. /** Resets all cached information relative to material (including effect and visibility) */
  1647. resetCachedMaterial(): void;
  1648. /**
  1649. * Registers a function to be called before every frame render
  1650. * @param func defines the function to register
  1651. */
  1652. registerBeforeRender(func: () => void): void;
  1653. /**
  1654. * Unregisters a function called before every frame render
  1655. * @param func defines the function to unregister
  1656. */
  1657. unregisterBeforeRender(func: () => void): void;
  1658. /**
  1659. * Registers a function to be called after every frame render
  1660. * @param func defines the function to register
  1661. */
  1662. registerAfterRender(func: () => void): void;
  1663. /**
  1664. * Unregisters a function called after every frame render
  1665. * @param func defines the function to unregister
  1666. */
  1667. unregisterAfterRender(func: () => void): void;
  1668. private _executeOnceBeforeRender;
  1669. /**
  1670. * The provided function will run before render once and will be disposed afterwards.
  1671. * A timeout delay can be provided so that the function will be executed in N ms.
  1672. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  1673. * @param func The function to be executed.
  1674. * @param timeout optional delay in ms
  1675. */
  1676. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  1677. /** @hidden */
  1678. _addPendingData(data: any): void;
  1679. /** @hidden */
  1680. _removePendingData(data: any): void;
  1681. /**
  1682. * Returns the number of items waiting to be loaded
  1683. * @returns the number of items waiting to be loaded
  1684. */
  1685. getWaitingItemsCount(): number;
  1686. /**
  1687. * Returns a boolean indicating if the scene is still loading data
  1688. */
  1689. readonly isLoading: boolean;
  1690. /**
  1691. * Registers a function to be executed when the scene is ready
  1692. * @param {Function} func - the function to be executed
  1693. */
  1694. executeWhenReady(func: () => void): void;
  1695. /**
  1696. * Returns a promise that resolves when the scene is ready
  1697. * @returns A promise that resolves when the scene is ready
  1698. */
  1699. whenReadyAsync(): Promise<void>;
  1700. /** @hidden */
  1701. _checkIsReady(): void;
  1702. /**
  1703. * Will start the animation sequence of a given target
  1704. * @param target defines the target
  1705. * @param from defines from which frame should animation start
  1706. * @param to defines until which frame should animation run.
  1707. * @param weight defines the weight to apply to the animation (1.0 by default)
  1708. * @param loop defines if the animation loops
  1709. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1710. * @param onAnimationEnd defines the function to be executed when the animation ends
  1711. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1712. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  1713. * @returns the animatable object created for this animation
  1714. */
  1715. beginWeightedAnimation(target: any, from: number, to: number, weight?: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean): Animatable;
  1716. /**
  1717. * Will start the animation sequence of a given target
  1718. * @param target defines the target
  1719. * @param from defines from which frame should animation start
  1720. * @param to defines until which frame should animation run.
  1721. * @param loop defines if the animation loops
  1722. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1723. * @param onAnimationEnd defines the function to be executed when the animation ends
  1724. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1725. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  1726. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  1727. * @returns the animatable object created for this animation
  1728. */
  1729. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean): Animatable;
  1730. /**
  1731. * Begin a new animation on a given node
  1732. * @param target defines the target where the animation will take place
  1733. * @param animations defines the list of animations to start
  1734. * @param from defines the initial value
  1735. * @param to defines the final value
  1736. * @param loop defines if you want animation to loop (off by default)
  1737. * @param speedRatio defines the speed ratio to apply to all animations
  1738. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1739. * @returns the list of created animatables
  1740. */
  1741. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable;
  1742. /**
  1743. * Begin a new animation on a given node and its hierarchy
  1744. * @param target defines the root node where the animation will take place
  1745. * @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.
  1746. * @param animations defines the list of animations to start
  1747. * @param from defines the initial value
  1748. * @param to defines the final value
  1749. * @param loop defines if you want animation to loop (off by default)
  1750. * @param speedRatio defines the speed ratio to apply to all animations
  1751. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1752. * @returns the list of animatables created for all nodes
  1753. */
  1754. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable[];
  1755. /**
  1756. * Gets the animatable associated with a specific target
  1757. * @param target defines the target of the animatable
  1758. * @returns the required animatable if found
  1759. */
  1760. getAnimatableByTarget(target: any): Nullable<Animatable>;
  1761. /**
  1762. * Gets all animatables associated with a given target
  1763. * @param target defines the target to look animatables for
  1764. * @returns an array of Animatables
  1765. */
  1766. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  1767. /**
  1768. * Gets all animatable attached to the scene
  1769. */
  1770. readonly animatables: Animatable[];
  1771. /**
  1772. * Will stop the animation of the given target
  1773. * @param target - the target
  1774. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  1775. * @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)
  1776. */
  1777. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  1778. /**
  1779. * Stops and removes all animations that have been applied to the scene
  1780. */
  1781. stopAllAnimations(): void;
  1782. private _animate;
  1783. /** @hidden */
  1784. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  1785. private _processLateAnimationBindingsForMatrices;
  1786. private _processLateAnimationBindingsForQuaternions;
  1787. private _processLateAnimationBindings;
  1788. /** @hidden */
  1789. _switchToAlternateCameraConfiguration(active: boolean): void;
  1790. /**
  1791. * Gets the current view matrix
  1792. * @returns a Matrix
  1793. */
  1794. getViewMatrix(): Matrix;
  1795. /**
  1796. * Gets the current projection matrix
  1797. * @returns a Matrix
  1798. */
  1799. getProjectionMatrix(): Matrix;
  1800. /**
  1801. * Gets the current transform matrix
  1802. * @returns a Matrix made of View * Projection
  1803. */
  1804. getTransformMatrix(): Matrix;
  1805. /**
  1806. * Sets the current transform matrix
  1807. * @param view defines the View matrix to use
  1808. * @param projection defines the Projection matrix to use
  1809. */
  1810. setTransformMatrix(view: Matrix, projection: Matrix): void;
  1811. /** @hidden */
  1812. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  1813. /**
  1814. * Gets the uniform buffer used to store scene data
  1815. * @returns a UniformBuffer
  1816. */
  1817. getSceneUniformBuffer(): UniformBuffer;
  1818. /**
  1819. * Gets an unique (relatively to the current scene) Id
  1820. * @returns an unique number for the scene
  1821. */
  1822. getUniqueId(): number;
  1823. /**
  1824. * Add a mesh to the list of scene's meshes
  1825. * @param newMesh defines the mesh to add
  1826. * @param recursive if all child meshes should also be added to the scene
  1827. */
  1828. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  1829. /**
  1830. * Remove a mesh for the list of scene's meshes
  1831. * @param toRemove defines the mesh to remove
  1832. * @param recursive if all child meshes should also be removed from the scene
  1833. * @returns the index where the mesh was in the mesh list
  1834. */
  1835. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  1836. /**
  1837. * Add a transform node to the list of scene's transform nodes
  1838. * @param newTransformNode defines the transform node to add
  1839. */
  1840. addTransformNode(newTransformNode: TransformNode): void;
  1841. /**
  1842. * Remove a transform node for the list of scene's transform nodes
  1843. * @param toRemove defines the transform node to remove
  1844. * @returns the index where the transform node was in the transform node list
  1845. */
  1846. removeTransformNode(toRemove: TransformNode): number;
  1847. /**
  1848. * Remove a skeleton for the list of scene's skeletons
  1849. * @param toRemove defines the skeleton to remove
  1850. * @returns the index where the skeleton was in the skeleton list
  1851. */
  1852. removeSkeleton(toRemove: Skeleton): number;
  1853. /**
  1854. * Remove a morph target for the list of scene's morph targets
  1855. * @param toRemove defines the morph target to remove
  1856. * @returns the index where the morph target was in the morph target list
  1857. */
  1858. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  1859. /**
  1860. * Remove a light for the list of scene's lights
  1861. * @param toRemove defines the light to remove
  1862. * @returns the index where the light was in the light list
  1863. */
  1864. removeLight(toRemove: Light): number;
  1865. /**
  1866. * Remove a camera for the list of scene's cameras
  1867. * @param toRemove defines the camera to remove
  1868. * @returns the index where the camera was in the camera list
  1869. */
  1870. removeCamera(toRemove: Camera): number;
  1871. /**
  1872. * Remove a particle system for the list of scene's particle systems
  1873. * @param toRemove defines the particle system to remove
  1874. * @returns the index where the particle system was in the particle system list
  1875. */
  1876. removeParticleSystem(toRemove: IParticleSystem): number;
  1877. /**
  1878. * Remove a animation for the list of scene's animations
  1879. * @param toRemove defines the animation to remove
  1880. * @returns the index where the animation was in the animation list
  1881. */
  1882. removeAnimation(toRemove: Animation): number;
  1883. /**
  1884. * Removes the given animation group from this scene.
  1885. * @param toRemove The animation group to remove
  1886. * @returns The index of the removed animation group
  1887. */
  1888. removeAnimationGroup(toRemove: AnimationGroup): number;
  1889. /**
  1890. * Removes the given multi-material from this scene.
  1891. * @param toRemove The multi-material to remove
  1892. * @returns The index of the removed multi-material
  1893. */
  1894. removeMultiMaterial(toRemove: MultiMaterial): number;
  1895. /**
  1896. * Removes the given material from this scene.
  1897. * @param toRemove The material to remove
  1898. * @returns The index of the removed material
  1899. */
  1900. removeMaterial(toRemove: Material): number;
  1901. /**
  1902. * Removes the given action manager from this scene.
  1903. * @param toRemove The action manager to remove
  1904. * @returns The index of the removed action manager
  1905. */
  1906. removeActionManager(toRemove: ActionManager): number;
  1907. /**
  1908. * Removes the given texture from this scene.
  1909. * @param toRemove The texture to remove
  1910. * @returns The index of the removed texture
  1911. */
  1912. removeTexture(toRemove: BaseTexture): number;
  1913. /**
  1914. * Adds the given light to this scene
  1915. * @param newLight The light to add
  1916. */
  1917. addLight(newLight: Light): void;
  1918. /**
  1919. * Sorts the list list based on light priorities
  1920. */
  1921. sortLightsByPriority(): void;
  1922. /**
  1923. * Adds the given camera to this scene
  1924. * @param newCamera The camera to add
  1925. */
  1926. addCamera(newCamera: Camera): void;
  1927. /**
  1928. * Adds the given skeleton to this scene
  1929. * @param newSkeleton The skeleton to add
  1930. */
  1931. addSkeleton(newSkeleton: Skeleton): void;
  1932. /**
  1933. * Adds the given particle system to this scene
  1934. * @param newParticleSystem The particle system to add
  1935. */
  1936. addParticleSystem(newParticleSystem: IParticleSystem): void;
  1937. /**
  1938. * Adds the given animation to this scene
  1939. * @param newAnimation The animation to add
  1940. */
  1941. addAnimation(newAnimation: Animation): void;
  1942. /**
  1943. * Adds the given animation group to this scene.
  1944. * @param newAnimationGroup The animation group to add
  1945. */
  1946. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  1947. /**
  1948. * Adds the given multi-material to this scene
  1949. * @param newMultiMaterial The multi-material to add
  1950. */
  1951. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  1952. /**
  1953. * Adds the given material to this scene
  1954. * @param newMaterial The material to add
  1955. */
  1956. addMaterial(newMaterial: Material): void;
  1957. /**
  1958. * Adds the given morph target to this scene
  1959. * @param newMorphTargetManager The morph target to add
  1960. */
  1961. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  1962. /**
  1963. * Adds the given geometry to this scene
  1964. * @param newGeometry The geometry to add
  1965. */
  1966. addGeometry(newGeometry: Geometry): void;
  1967. /**
  1968. * Adds the given action manager to this scene
  1969. * @param newActionManager The action manager to add
  1970. */
  1971. addActionManager(newActionManager: ActionManager): void;
  1972. /**
  1973. * Adds the given texture to this scene.
  1974. * @param newTexture The texture to add
  1975. */
  1976. addTexture(newTexture: BaseTexture): void;
  1977. /**
  1978. * Switch active camera
  1979. * @param newCamera defines the new active camera
  1980. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  1981. */
  1982. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  1983. /**
  1984. * sets the active camera of the scene using its ID
  1985. * @param id defines the camera's ID
  1986. * @return the new active camera or null if none found.
  1987. */
  1988. setActiveCameraByID(id: string): Nullable<Camera>;
  1989. /**
  1990. * sets the active camera of the scene using its name
  1991. * @param name defines the camera's name
  1992. * @returns the new active camera or null if none found.
  1993. */
  1994. setActiveCameraByName(name: string): Nullable<Camera>;
  1995. /**
  1996. * get an animation group using its name
  1997. * @param name defines the material's name
  1998. * @return the animation group or null if none found.
  1999. */
  2000. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  2001. /**
  2002. * get a material using its id
  2003. * @param id defines the material's ID
  2004. * @return the material or null if none found.
  2005. */
  2006. getMaterialByID(id: string): Nullable<Material>;
  2007. /**
  2008. * Gets a material using its name
  2009. * @param name defines the material's name
  2010. * @return the material or null if none found.
  2011. */
  2012. getMaterialByName(name: string): Nullable<Material>;
  2013. /**
  2014. * Gets a camera using its id
  2015. * @param id defines the id to look for
  2016. * @returns the camera or null if not found
  2017. */
  2018. getCameraByID(id: string): Nullable<Camera>;
  2019. /**
  2020. * Gets a camera using its unique id
  2021. * @param uniqueId defines the unique id to look for
  2022. * @returns the camera or null if not found
  2023. */
  2024. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  2025. /**
  2026. * Gets a camera using its name
  2027. * @param name defines the camera's name
  2028. * @return the camera or null if none found.
  2029. */
  2030. getCameraByName(name: string): Nullable<Camera>;
  2031. /**
  2032. * Gets a bone using its id
  2033. * @param id defines the bone's id
  2034. * @return the bone or null if not found
  2035. */
  2036. getBoneByID(id: string): Nullable<Bone>;
  2037. /**
  2038. * Gets a bone using its id
  2039. * @param name defines the bone's name
  2040. * @return the bone or null if not found
  2041. */
  2042. getBoneByName(name: string): Nullable<Bone>;
  2043. /**
  2044. * Gets a light node using its name
  2045. * @param name defines the the light's name
  2046. * @return the light or null if none found.
  2047. */
  2048. getLightByName(name: string): Nullable<Light>;
  2049. /**
  2050. * Gets a light node using its id
  2051. * @param id defines the light's id
  2052. * @return the light or null if none found.
  2053. */
  2054. getLightByID(id: string): Nullable<Light>;
  2055. /**
  2056. * Gets a light node using its scene-generated unique ID
  2057. * @param uniqueId defines the light's unique id
  2058. * @return the light or null if none found.
  2059. */
  2060. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  2061. /**
  2062. * Gets a particle system by id
  2063. * @param id defines the particle system id
  2064. * @return the corresponding system or null if none found
  2065. */
  2066. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  2067. /**
  2068. * Gets a geometry using its ID
  2069. * @param id defines the geometry's id
  2070. * @return the geometry or null if none found.
  2071. */
  2072. getGeometryByID(id: string): Nullable<Geometry>;
  2073. /**
  2074. * Add a new geometry to this scene
  2075. * @param geometry defines the geometry to be added to the scene.
  2076. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  2077. * @return a boolean defining if the geometry was added or not
  2078. */
  2079. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  2080. /**
  2081. * Removes an existing geometry
  2082. * @param geometry defines the geometry to be removed from the scene
  2083. * @return a boolean defining if the geometry was removed or not
  2084. */
  2085. removeGeometry(geometry: Geometry): boolean;
  2086. /**
  2087. * Gets the list of geometries attached to the scene
  2088. * @returns an array of Geometry
  2089. */
  2090. getGeometries(): Geometry[];
  2091. /**
  2092. * Gets the first added mesh found of a given ID
  2093. * @param id defines the id to search for
  2094. * @return the mesh found or null if not found at all
  2095. */
  2096. getMeshByID(id: string): Nullable<AbstractMesh>;
  2097. /**
  2098. * Gets a list of meshes using their id
  2099. * @param id defines the id to search for
  2100. * @returns a list of meshes
  2101. */
  2102. getMeshesByID(id: string): Array<AbstractMesh>;
  2103. /**
  2104. * Gets the first added transform node found of a given ID
  2105. * @param id defines the id to search for
  2106. * @return the found transform node or null if not found at all.
  2107. */
  2108. getTransformNodeByID(id: string): Nullable<TransformNode>;
  2109. /**
  2110. * Gets a list of transform nodes using their id
  2111. * @param id defines the id to search for
  2112. * @returns a list of transform nodes
  2113. */
  2114. getTransformNodesByID(id: string): Array<TransformNode>;
  2115. /**
  2116. * Gets a mesh with its auto-generated unique id
  2117. * @param uniqueId defines the unique id to search for
  2118. * @return the found mesh or null if not found at all.
  2119. */
  2120. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  2121. /**
  2122. * Gets a the last added mesh using a given id
  2123. * @param id defines the id to search for
  2124. * @return the found mesh or null if not found at all.
  2125. */
  2126. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  2127. /**
  2128. * Gets a the last added node (Mesh, Camera, Light) using a given id
  2129. * @param id defines the id to search for
  2130. * @return the found node or null if not found at all
  2131. */
  2132. getLastEntryByID(id: string): Nullable<Node>;
  2133. /**
  2134. * Gets a node (Mesh, Camera, Light) using a given id
  2135. * @param id defines the id to search for
  2136. * @return the found node or null if not found at all
  2137. */
  2138. getNodeByID(id: string): Nullable<Node>;
  2139. /**
  2140. * Gets a node (Mesh, Camera, Light) using a given name
  2141. * @param name defines the name to search for
  2142. * @return the found node or null if not found at all.
  2143. */
  2144. getNodeByName(name: string): Nullable<Node>;
  2145. /**
  2146. * Gets a mesh using a given name
  2147. * @param name defines the name to search for
  2148. * @return the found mesh or null if not found at all.
  2149. */
  2150. getMeshByName(name: string): Nullable<AbstractMesh>;
  2151. /**
  2152. * Gets a transform node using a given name
  2153. * @param name defines the name to search for
  2154. * @return the found transform node or null if not found at all.
  2155. */
  2156. getTransformNodeByName(name: string): Nullable<TransformNode>;
  2157. /**
  2158. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  2159. * @param id defines the id to search for
  2160. * @return the found skeleton or null if not found at all.
  2161. */
  2162. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  2163. /**
  2164. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  2165. * @param id defines the id to search for
  2166. * @return the found skeleton or null if not found at all.
  2167. */
  2168. getSkeletonById(id: string): Nullable<Skeleton>;
  2169. /**
  2170. * Gets a skeleton using a given name
  2171. * @param name defines the name to search for
  2172. * @return the found skeleton or null if not found at all.
  2173. */
  2174. getSkeletonByName(name: string): Nullable<Skeleton>;
  2175. /**
  2176. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  2177. * @param id defines the id to search for
  2178. * @return the found morph target manager or null if not found at all.
  2179. */
  2180. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  2181. /**
  2182. * Gets a boolean indicating if the given mesh is active
  2183. * @param mesh defines the mesh to look for
  2184. * @returns true if the mesh is in the active list
  2185. */
  2186. isActiveMesh(mesh: AbstractMesh): boolean;
  2187. /**
  2188. * Return a unique id as a string which can serve as an identifier for the scene
  2189. */
  2190. readonly uid: string;
  2191. /**
  2192. * Add an externaly attached data from its key.
  2193. * This method call will fail and return false, if such key already exists.
  2194. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  2195. * @param key the unique key that identifies the data
  2196. * @param data the data object to associate to the key for this Engine instance
  2197. * @return true if no such key were already present and the data was added successfully, false otherwise
  2198. */
  2199. addExternalData<T>(key: string, data: T): boolean;
  2200. /**
  2201. * Get an externaly attached data from its key
  2202. * @param key the unique key that identifies the data
  2203. * @return the associated data, if present (can be null), or undefined if not present
  2204. */
  2205. getExternalData<T>(key: string): Nullable<T>;
  2206. /**
  2207. * Get an externaly attached data from its key, create it using a factory if it's not already present
  2208. * @param key the unique key that identifies the data
  2209. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  2210. * @return the associated data, can be null if the factory returned null.
  2211. */
  2212. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  2213. /**
  2214. * Remove an externaly attached data from the Engine instance
  2215. * @param key the unique key that identifies the data
  2216. * @return true if the data was successfully removed, false if it doesn't exist
  2217. */
  2218. removeExternalData(key: string): boolean;
  2219. private _evaluateSubMesh;
  2220. /**
  2221. * Clear the processed materials smart array preventing retention point in material dispose.
  2222. */
  2223. freeProcessedMaterials(): void;
  2224. /**
  2225. * Clear the active meshes smart array preventing retention point in mesh dispose.
  2226. */
  2227. freeActiveMeshes(): void;
  2228. /**
  2229. * Clear the info related to rendering groups preventing retention points during dispose.
  2230. */
  2231. freeRenderingGroups(): void;
  2232. /** @hidden */
  2233. _isInIntermediateRendering(): boolean;
  2234. /**
  2235. * Lambda returning the list of potentially active meshes.
  2236. */
  2237. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  2238. /**
  2239. * Lambda returning the list of potentially active sub meshes.
  2240. */
  2241. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  2242. /**
  2243. * Lambda returning the list of potentially intersecting sub meshes.
  2244. */
  2245. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  2246. /**
  2247. * Lambda returning the list of potentially colliding sub meshes.
  2248. */
  2249. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  2250. private _activeMeshesFrozen;
  2251. /**
  2252. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  2253. * @returns the current scene
  2254. */
  2255. freezeActiveMeshes(): Scene;
  2256. /**
  2257. * Use this function to restart evaluating active meshes on every frame
  2258. * @returns the current scene
  2259. */
  2260. unfreezeActiveMeshes(): Scene;
  2261. private _evaluateActiveMeshes;
  2262. private _activeMesh;
  2263. /**
  2264. * Update the transform matrix to update from the current active camera
  2265. * @param force defines a boolean used to force the update even if cache is up to date
  2266. */
  2267. updateTransformMatrix(force?: boolean): void;
  2268. /**
  2269. * 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)
  2270. * @param alternateCamera defines the camera to use
  2271. */
  2272. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  2273. /** @hidden */
  2274. _allowPostProcessClearColor: boolean;
  2275. private _renderForCamera;
  2276. private _processSubCameras;
  2277. private _checkIntersections;
  2278. /** @hidden */
  2279. _advancePhysicsEngineStep(step: number): void;
  2280. /**
  2281. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  2282. */
  2283. getDeterministicFrameTime: () => number;
  2284. /**
  2285. * Render the scene
  2286. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  2287. */
  2288. render(updateCameras?: boolean): void;
  2289. /**
  2290. * Freeze all materials
  2291. * A frozen material will not be updatable but should be faster to render
  2292. */
  2293. freezeMaterials(): void;
  2294. /**
  2295. * Unfreeze all materials
  2296. * A frozen material will not be updatable but should be faster to render
  2297. */
  2298. unfreezeMaterials(): void;
  2299. /**
  2300. * Releases all held ressources
  2301. */
  2302. dispose(): void;
  2303. /**
  2304. * Gets if the scene is already disposed
  2305. */
  2306. readonly isDisposed: boolean;
  2307. /**
  2308. * Call this function to reduce memory footprint of the scene.
  2309. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  2310. */
  2311. clearCachedVertexData(): void;
  2312. /**
  2313. * This function will remove the local cached buffer data from texture.
  2314. * It will save memory but will prevent the texture from being rebuilt
  2315. */
  2316. cleanCachedTextureBuffer(): void;
  2317. /**
  2318. * Get the world extend vectors with an optional filter
  2319. *
  2320. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  2321. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  2322. */
  2323. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  2324. min: Vector3;
  2325. max: Vector3;
  2326. };
  2327. /**
  2328. * Creates a ray that can be used to pick in the scene
  2329. * @param x defines the x coordinate of the origin (on-screen)
  2330. * @param y defines the y coordinate of the origin (on-screen)
  2331. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2332. * @param camera defines the camera to use for the picking
  2333. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2334. * @returns a Ray
  2335. */
  2336. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  2337. /**
  2338. * Creates a ray that can be used to pick in the scene
  2339. * @param x defines the x coordinate of the origin (on-screen)
  2340. * @param y defines the y coordinate of the origin (on-screen)
  2341. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2342. * @param result defines the ray where to store the picking ray
  2343. * @param camera defines the camera to use for the picking
  2344. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2345. * @returns the current scene
  2346. */
  2347. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  2348. /**
  2349. * Creates a ray that can be used to pick in the scene
  2350. * @param x defines the x coordinate of the origin (on-screen)
  2351. * @param y defines the y coordinate of the origin (on-screen)
  2352. * @param camera defines the camera to use for the picking
  2353. * @returns a Ray
  2354. */
  2355. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  2356. /**
  2357. * Creates a ray that can be used to pick in the scene
  2358. * @param x defines the x coordinate of the origin (on-screen)
  2359. * @param y defines the y coordinate of the origin (on-screen)
  2360. * @param result defines the ray where to store the picking ray
  2361. * @param camera defines the camera to use for the picking
  2362. * @returns the current scene
  2363. */
  2364. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  2365. private _internalPick;
  2366. private _internalMultiPick;
  2367. private _tempPickingRay;
  2368. /** Launch a ray to try to pick a mesh in the scene
  2369. * @param x position on screen
  2370. * @param y position on screen
  2371. * @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
  2372. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  2373. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2374. * @returns a PickingInfo
  2375. */
  2376. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  2377. private _cachedRayForTransform;
  2378. /** Use the given ray to pick a mesh in the scene
  2379. * @param ray The ray to use to pick meshes
  2380. * @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
  2381. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  2382. * @returns a PickingInfo
  2383. */
  2384. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  2385. /**
  2386. * Launch a ray to try to pick a mesh in the scene
  2387. * @param x X position on screen
  2388. * @param y Y position on screen
  2389. * @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
  2390. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2391. * @returns an array of PickingInfo
  2392. */
  2393. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  2394. /**
  2395. * Launch a ray to try to pick a mesh in the scene
  2396. * @param ray Ray to use
  2397. * @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
  2398. * @returns an array of PickingInfo
  2399. */
  2400. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  2401. /**
  2402. * Force the value of meshUnderPointer
  2403. * @param mesh defines the mesh to use
  2404. */
  2405. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  2406. /**
  2407. * Gets the mesh under the pointer
  2408. * @returns a Mesh or null if no mesh is under the pointer
  2409. */
  2410. getPointerOverMesh(): Nullable<AbstractMesh>;
  2411. /** @hidden */
  2412. _rebuildGeometries(): void;
  2413. /** @hidden */
  2414. _rebuildTextures(): void;
  2415. private _getByTags;
  2416. /**
  2417. * Get a list of meshes by tags
  2418. * @param tagsQuery defines the tags query to use
  2419. * @param forEach defines a predicate used to filter results
  2420. * @returns an array of Mesh
  2421. */
  2422. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  2423. /**
  2424. * Get a list of cameras by tags
  2425. * @param tagsQuery defines the tags query to use
  2426. * @param forEach defines a predicate used to filter results
  2427. * @returns an array of Camera
  2428. */
  2429. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  2430. /**
  2431. * Get a list of lights by tags
  2432. * @param tagsQuery defines the tags query to use
  2433. * @param forEach defines a predicate used to filter results
  2434. * @returns an array of Light
  2435. */
  2436. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  2437. /**
  2438. * Get a list of materials by tags
  2439. * @param tagsQuery defines the tags query to use
  2440. * @param forEach defines a predicate used to filter results
  2441. * @returns an array of Material
  2442. */
  2443. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  2444. /**
  2445. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  2446. * This allowed control for front to back rendering or reversly depending of the special needs.
  2447. *
  2448. * @param renderingGroupId The rendering group id corresponding to its index
  2449. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  2450. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  2451. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  2452. */
  2453. 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;
  2454. /**
  2455. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  2456. *
  2457. * @param renderingGroupId The rendering group id corresponding to its index
  2458. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  2459. * @param depth Automatically clears depth between groups if true and autoClear is true.
  2460. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  2461. */
  2462. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  2463. /**
  2464. * Gets the current auto clear configuration for one rendering group of the rendering
  2465. * manager.
  2466. * @param index the rendering group index to get the information for
  2467. * @returns The auto clear setup for the requested rendering group
  2468. */
  2469. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  2470. private _blockMaterialDirtyMechanism;
  2471. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  2472. blockMaterialDirtyMechanism: boolean;
  2473. /**
  2474. * Will flag all materials as dirty to trigger new shader compilation
  2475. * @param flag defines the flag used to specify which material part must be marked as dirty
  2476. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  2477. */
  2478. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  2479. /** @hidden */
  2480. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useDatabase?: boolean, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  2481. /** @hidden */
  2482. _loadFileAsync(url: string, useDatabase?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  2483. }
  2484. }
  2485. declare module BABYLON {
  2486. /**
  2487. * Groups all the scene component constants in one place to ease maintenance.
  2488. * @hidden
  2489. */
  2490. class SceneComponentConstants {
  2491. static readonly NAME_EFFECTLAYER: string;
  2492. static readonly NAME_LAYER: string;
  2493. static readonly NAME_LENSFLARESYSTEM: string;
  2494. static readonly NAME_BOUNDINGBOXRENDERER: string;
  2495. static readonly NAME_PARTICLESYSTEM: string;
  2496. static readonly NAME_GAMEPAD: string;
  2497. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  2498. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  2499. static readonly NAME_DEPTHRENDERER: string;
  2500. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  2501. static readonly NAME_SPRITE: string;
  2502. static readonly NAME_OUTLINERENDERER: string;
  2503. static readonly NAME_PROCEDURALTEXTURE: string;
  2504. static readonly NAME_SHADOWGENERATOR: string;
  2505. static readonly NAME_OCTREE: string;
  2506. static readonly NAME_PHYSICSENGINE: string;
  2507. static readonly NAME_AUDIO: string;
  2508. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  2509. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  2510. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  2511. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  2512. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  2513. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  2514. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  2515. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  2516. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  2517. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  2518. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  2519. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  2520. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  2521. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  2522. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  2523. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  2524. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  2525. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  2526. static readonly STEP_AFTERRENDER_AUDIO: number;
  2527. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  2528. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  2529. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  2530. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  2531. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  2532. static readonly STEP_POINTERMOVE_SPRITE: number;
  2533. static readonly STEP_POINTERDOWN_SPRITE: number;
  2534. static readonly STEP_POINTERUP_SPRITE: number;
  2535. }
  2536. /**
  2537. * This represents a scene component.
  2538. *
  2539. * This is used to decouple the dependency the scene is having on the different workloads like
  2540. * layers, post processes...
  2541. */
  2542. interface ISceneComponent {
  2543. /**
  2544. * The name of the component. Each component must have a unique name.
  2545. */
  2546. name: string;
  2547. /**
  2548. * The scene the component belongs to.
  2549. */
  2550. scene: Scene;
  2551. /**
  2552. * Register the component to one instance of a scene.
  2553. */
  2554. register(): void;
  2555. /**
  2556. * Rebuilds the elements related to this component in case of
  2557. * context lost for instance.
  2558. */
  2559. rebuild(): void;
  2560. /**
  2561. * Disposes the component and the associated ressources.
  2562. */
  2563. dispose(): void;
  2564. }
  2565. /**
  2566. * This represents a SERIALIZABLE scene component.
  2567. *
  2568. * This extends Scene Component to add Serialization methods on top.
  2569. */
  2570. interface ISceneSerializableComponent extends ISceneComponent {
  2571. /**
  2572. * Adds all the element from the container to the scene
  2573. * @param container the container holding the elements
  2574. */
  2575. addFromContainer(container: AbstractScene): void;
  2576. /**
  2577. * Removes all the elements in the container from the scene
  2578. * @param container contains the elements to remove
  2579. */
  2580. removeFromContainer(container: AbstractScene): void;
  2581. /**
  2582. * Serializes the component data to the specified json object
  2583. * @param serializationObject The object to serialize to
  2584. */
  2585. serialize(serializationObject: any): void;
  2586. }
  2587. /**
  2588. * Strong typing of a Mesh related stage step action
  2589. */
  2590. type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  2591. /**
  2592. * Strong typing of a Evaluate Sub Mesh related stage step action
  2593. */
  2594. type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  2595. /**
  2596. * Strong typing of a Active Mesh related stage step action
  2597. */
  2598. type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  2599. /**
  2600. * Strong typing of a Camera related stage step action
  2601. */
  2602. type CameraStageAction = (camera: Camera) => void;
  2603. /**
  2604. * Strong typing of a RenderingGroup related stage step action
  2605. */
  2606. type RenderingGroupStageAction = (renderingGroupId: number) => void;
  2607. /**
  2608. * Strong typing of a Mesh Render related stage step action
  2609. */
  2610. type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  2611. /**
  2612. * Strong typing of a simple stage step action
  2613. */
  2614. type SimpleStageAction = () => void;
  2615. /**
  2616. * Strong typing of a render target action.
  2617. */
  2618. type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  2619. /**
  2620. * Strong typing of a pointer move action.
  2621. */
  2622. type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  2623. /**
  2624. * Strong typing of a pointer up/down action.
  2625. */
  2626. type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  2627. /**
  2628. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  2629. * @hidden
  2630. */
  2631. class Stage<T extends Function> extends Array<{
  2632. index: number;
  2633. component: ISceneComponent;
  2634. action: T;
  2635. }> {
  2636. /**
  2637. * Hide ctor from the rest of the world.
  2638. * @param items The items to add.
  2639. */
  2640. private constructor();
  2641. /**
  2642. * Creates a new Stage.
  2643. * @returns A new instance of a Stage
  2644. */
  2645. static Create<T extends Function>(): Stage<T>;
  2646. /**
  2647. * Registers a step in an ordered way in the targeted stage.
  2648. * @param index Defines the position to register the step in
  2649. * @param component Defines the component attached to the step
  2650. * @param action Defines the action to launch during the step
  2651. */
  2652. registerStep(index: number, component: ISceneComponent, action: T): void;
  2653. /**
  2654. * Clears all the steps from the stage.
  2655. */
  2656. clear(): void;
  2657. }
  2658. }
  2659. declare module BABYLON {
  2660. /** Alias type for value that can be null */
  2661. type Nullable<T> = T | null;
  2662. /**
  2663. * Alias type for number that are floats
  2664. * @ignorenaming
  2665. */
  2666. type float = number;
  2667. /**
  2668. * Alias type for number that are doubles.
  2669. * @ignorenaming
  2670. */
  2671. type double = number;
  2672. /**
  2673. * Alias type for number that are integer
  2674. * @ignorenaming
  2675. */
  2676. type int = number;
  2677. /** Alias type for number array or Float32Array */
  2678. type FloatArray = number[] | Float32Array;
  2679. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  2680. type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  2681. /**
  2682. * Alias for types that can be used by a Buffer or VertexBuffer.
  2683. */
  2684. type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  2685. }
  2686. declare module BABYLON {
  2687. /**
  2688. * Class used to store an actual running animation
  2689. */
  2690. class Animatable {
  2691. /** defines the target object */
  2692. target: any;
  2693. /** defines the starting frame number (default is 0) */
  2694. fromFrame: number;
  2695. /** defines the ending frame number (default is 100) */
  2696. toFrame: number;
  2697. /** defines if the animation must loop (default is false) */
  2698. loopAnimation: boolean;
  2699. /** defines a callback to call when animation ends if it is not looping */
  2700. onAnimationEnd?: (() => void) | null | undefined;
  2701. private _localDelayOffset;
  2702. private _pausedDelay;
  2703. private _runtimeAnimations;
  2704. private _paused;
  2705. private _scene;
  2706. private _speedRatio;
  2707. private _weight;
  2708. private _syncRoot;
  2709. /**
  2710. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  2711. * This will only apply for non looping animation (default is true)
  2712. */
  2713. disposeOnEnd: boolean;
  2714. /**
  2715. * Gets a boolean indicating if the animation has started
  2716. */
  2717. animationStarted: boolean;
  2718. /**
  2719. * Observer raised when the animation ends
  2720. */
  2721. onAnimationEndObservable: Observable<Animatable>;
  2722. /**
  2723. * Gets the root Animatable used to synchronize and normalize animations
  2724. */
  2725. readonly syncRoot: Animatable;
  2726. /**
  2727. * Gets the current frame of the first RuntimeAnimation
  2728. * Used to synchronize Animatables
  2729. */
  2730. readonly masterFrame: number;
  2731. /**
  2732. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  2733. */
  2734. weight: number;
  2735. /**
  2736. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  2737. */
  2738. speedRatio: number;
  2739. /**
  2740. * Creates a new Animatable
  2741. * @param scene defines the hosting scene
  2742. * @param target defines the target object
  2743. * @param fromFrame defines the starting frame number (default is 0)
  2744. * @param toFrame defines the ending frame number (default is 100)
  2745. * @param loopAnimation defines if the animation must loop (default is false)
  2746. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  2747. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  2748. * @param animations defines a group of animation to add to the new Animatable
  2749. */
  2750. constructor(scene: Scene,
  2751. /** defines the target object */
  2752. target: any,
  2753. /** defines the starting frame number (default is 0) */
  2754. fromFrame?: number,
  2755. /** defines the ending frame number (default is 100) */
  2756. toFrame?: number,
  2757. /** defines if the animation must loop (default is false) */
  2758. loopAnimation?: boolean, speedRatio?: number,
  2759. /** defines a callback to call when animation ends if it is not looping */
  2760. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[]);
  2761. /**
  2762. * Synchronize and normalize current Animatable with a source Animatable
  2763. * This is useful when using animation weights and when animations are not of the same length
  2764. * @param root defines the root Animatable to synchronize with
  2765. * @returns the current Animatable
  2766. */
  2767. syncWith(root: Animatable): Animatable;
  2768. /**
  2769. * Gets the list of runtime animations
  2770. * @returns an array of RuntimeAnimation
  2771. */
  2772. getAnimations(): RuntimeAnimation[];
  2773. /**
  2774. * Adds more animations to the current animatable
  2775. * @param target defines the target of the animations
  2776. * @param animations defines the new animations to add
  2777. */
  2778. appendAnimations(target: any, animations: Animation[]): void;
  2779. /**
  2780. * Gets the source animation for a specific property
  2781. * @param property defines the propertyu to look for
  2782. * @returns null or the source animation for the given property
  2783. */
  2784. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  2785. /**
  2786. * Gets the runtime animation for a specific property
  2787. * @param property defines the propertyu to look for
  2788. * @returns null or the runtime animation for the given property
  2789. */
  2790. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  2791. /**
  2792. * Resets the animatable to its original state
  2793. */
  2794. reset(): void;
  2795. /**
  2796. * Allows the animatable to blend with current running animations
  2797. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  2798. * @param blendingSpeed defines the blending speed to use
  2799. */
  2800. enableBlending(blendingSpeed: number): void;
  2801. /**
  2802. * Disable animation blending
  2803. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  2804. */
  2805. disableBlending(): void;
  2806. /**
  2807. * Jump directly to a given frame
  2808. * @param frame defines the frame to jump to
  2809. */
  2810. goToFrame(frame: number): void;
  2811. /**
  2812. * Pause the animation
  2813. */
  2814. pause(): void;
  2815. /**
  2816. * Restart the animation
  2817. */
  2818. restart(): void;
  2819. private _raiseOnAnimationEnd;
  2820. /**
  2821. * Stop and delete the current animation
  2822. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  2823. * @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)
  2824. */
  2825. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  2826. /**
  2827. * Wait asynchronously for the animation to end
  2828. * @returns a promise which will be fullfilled when the animation ends
  2829. */
  2830. waitAsync(): Promise<Animatable>;
  2831. /** @hidden */
  2832. _animate(delay: number): boolean;
  2833. }
  2834. }
  2835. declare module BABYLON {
  2836. /**
  2837. * Represents the range of an animation
  2838. */
  2839. class AnimationRange {
  2840. /**The name of the animation range**/
  2841. name: string;
  2842. /**The starting frame of the animation */
  2843. from: number;
  2844. /**The ending frame of the animation*/
  2845. to: number;
  2846. /**
  2847. * Initializes the range of an animation
  2848. * @param name The name of the animation range
  2849. * @param from The starting frame of the animation
  2850. * @param to The ending frame of the animation
  2851. */
  2852. constructor(
  2853. /**The name of the animation range**/
  2854. name: string,
  2855. /**The starting frame of the animation */
  2856. from: number,
  2857. /**The ending frame of the animation*/
  2858. to: number);
  2859. /**
  2860. * Makes a copy of the animation range
  2861. * @returns A copy of the animation range
  2862. */
  2863. clone(): AnimationRange;
  2864. }
  2865. /**
  2866. * Composed of a frame, and an action function
  2867. */
  2868. class AnimationEvent {
  2869. /** The frame for which the event is triggered **/
  2870. frame: number;
  2871. /** The event to perform when triggered **/
  2872. action: (currentFrame: number) => void;
  2873. /** Specifies if the event should be triggered only once**/
  2874. onlyOnce?: boolean | undefined;
  2875. /**
  2876. * Specifies if the animation event is done
  2877. */
  2878. isDone: boolean;
  2879. /**
  2880. * Initializes the animation event
  2881. * @param frame The frame for which the event is triggered
  2882. * @param action The event to perform when triggered
  2883. * @param onlyOnce Specifies if the event should be triggered only once
  2884. */
  2885. constructor(
  2886. /** The frame for which the event is triggered **/
  2887. frame: number,
  2888. /** The event to perform when triggered **/
  2889. action: (currentFrame: number) => void,
  2890. /** Specifies if the event should be triggered only once**/
  2891. onlyOnce?: boolean | undefined);
  2892. /** @hidden */
  2893. _clone(): AnimationEvent;
  2894. }
  2895. /**
  2896. * A cursor which tracks a point on a path
  2897. */
  2898. class PathCursor {
  2899. private path;
  2900. /**
  2901. * Stores path cursor callbacks for when an onchange event is triggered
  2902. */
  2903. private _onchange;
  2904. /**
  2905. * The value of the path cursor
  2906. */
  2907. value: number;
  2908. /**
  2909. * The animation array of the path cursor
  2910. */
  2911. animations: Animation[];
  2912. /**
  2913. * Initializes the path cursor
  2914. * @param path The path to track
  2915. */
  2916. constructor(path: Path2);
  2917. /**
  2918. * Gets the cursor point on the path
  2919. * @returns A point on the path cursor at the cursor location
  2920. */
  2921. getPoint(): Vector3;
  2922. /**
  2923. * Moves the cursor ahead by the step amount
  2924. * @param step The amount to move the cursor forward
  2925. * @returns This path cursor
  2926. */
  2927. moveAhead(step?: number): PathCursor;
  2928. /**
  2929. * Moves the cursor behind by the step amount
  2930. * @param step The amount to move the cursor back
  2931. * @returns This path cursor
  2932. */
  2933. moveBack(step?: number): PathCursor;
  2934. /**
  2935. * Moves the cursor by the step amount
  2936. * If the step amount is greater than one, an exception is thrown
  2937. * @param step The amount to move the cursor
  2938. * @returns This path cursor
  2939. */
  2940. move(step: number): PathCursor;
  2941. /**
  2942. * Ensures that the value is limited between zero and one
  2943. * @returns This path cursor
  2944. */
  2945. private ensureLimits;
  2946. /**
  2947. * Runs onchange callbacks on change (used by the animation engine)
  2948. * @returns This path cursor
  2949. */
  2950. private raiseOnChange;
  2951. /**
  2952. * Executes a function on change
  2953. * @param f A path cursor onchange callback
  2954. * @returns This path cursor
  2955. */
  2956. onchange(f: (cursor: PathCursor) => void): PathCursor;
  2957. }
  2958. /**
  2959. * Defines an interface which represents an animation key frame
  2960. */
  2961. interface IAnimationKey {
  2962. /**
  2963. * Frame of the key frame
  2964. */
  2965. frame: number;
  2966. /**
  2967. * Value at the specifies key frame
  2968. */
  2969. value: any;
  2970. /**
  2971. * The input tangent for the cubic hermite spline
  2972. */
  2973. inTangent?: any;
  2974. /**
  2975. * The output tangent for the cubic hermite spline
  2976. */
  2977. outTangent?: any;
  2978. /**
  2979. * The animation interpolation type
  2980. */
  2981. interpolation?: AnimationKeyInterpolation;
  2982. }
  2983. /**
  2984. * Enum for the animation key frame interpolation type
  2985. */
  2986. enum AnimationKeyInterpolation {
  2987. /**
  2988. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  2989. */
  2990. STEP = 1
  2991. }
  2992. /**
  2993. * Class used to store any kind of animation
  2994. */
  2995. class Animation {
  2996. /**Name of the animation */
  2997. name: string;
  2998. /**Property to animate */
  2999. targetProperty: string;
  3000. /**The frames per second of the animation */
  3001. framePerSecond: number;
  3002. /**The data type of the animation */
  3003. dataType: number;
  3004. /**The loop mode of the animation */
  3005. loopMode?: number | undefined;
  3006. /**Specifies if blending should be enabled */
  3007. enableBlending?: boolean | undefined;
  3008. /**
  3009. * Use matrix interpolation instead of using direct key value when animating matrices
  3010. */
  3011. static AllowMatricesInterpolation: boolean;
  3012. /**
  3013. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  3014. */
  3015. static AllowMatrixDecomposeForInterpolation: boolean;
  3016. /**
  3017. * Stores the key frames of the animation
  3018. */
  3019. private _keys;
  3020. /**
  3021. * Stores the easing function of the animation
  3022. */
  3023. private _easingFunction;
  3024. /**
  3025. * @hidden Internal use only
  3026. */
  3027. _runtimeAnimations: RuntimeAnimation[];
  3028. /**
  3029. * The set of event that will be linked to this animation
  3030. */
  3031. private _events;
  3032. /**
  3033. * Stores an array of target property paths
  3034. */
  3035. targetPropertyPath: string[];
  3036. /**
  3037. * Stores the blending speed of the animation
  3038. */
  3039. blendingSpeed: number;
  3040. /**
  3041. * Stores the animation ranges for the animation
  3042. */
  3043. private _ranges;
  3044. /**
  3045. * @hidden Internal use
  3046. */
  3047. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  3048. /**
  3049. * Sets up an animation
  3050. * @param property The property to animate
  3051. * @param animationType The animation type to apply
  3052. * @param framePerSecond The frames per second of the animation
  3053. * @param easingFunction The easing function used in the animation
  3054. * @returns The created animation
  3055. */
  3056. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  3057. /**
  3058. * Create and start an animation on a node
  3059. * @param name defines the name of the global animation that will be run on all nodes
  3060. * @param node defines the root node where the animation will take place
  3061. * @param targetProperty defines property to animate
  3062. * @param framePerSecond defines the number of frame per second yo use
  3063. * @param totalFrame defines the number of frames in total
  3064. * @param from defines the initial value
  3065. * @param to defines the final value
  3066. * @param loopMode defines which loop mode you want to use (off by default)
  3067. * @param easingFunction defines the easing function to use (linear by default)
  3068. * @param onAnimationEnd defines the callback to call when animation end
  3069. * @returns the animatable created for this animation
  3070. */
  3071. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  3072. /**
  3073. * Create and start an animation on a node and its descendants
  3074. * @param name defines the name of the global animation that will be run on all nodes
  3075. * @param node defines the root node where the animation will take place
  3076. * @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
  3077. * @param targetProperty defines property to animate
  3078. * @param framePerSecond defines the number of frame per second to use
  3079. * @param totalFrame defines the number of frames in total
  3080. * @param from defines the initial value
  3081. * @param to defines the final value
  3082. * @param loopMode defines which loop mode you want to use (off by default)
  3083. * @param easingFunction defines the easing function to use (linear by default)
  3084. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  3085. * @returns the list of animatables created for all nodes
  3086. * @example https://www.babylonjs-playground.com/#MH0VLI
  3087. */
  3088. 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[]>;
  3089. /**
  3090. * Creates a new animation, merges it with the existing animations and starts it
  3091. * @param name Name of the animation
  3092. * @param node Node which contains the scene that begins the animations
  3093. * @param targetProperty Specifies which property to animate
  3094. * @param framePerSecond The frames per second of the animation
  3095. * @param totalFrame The total number of frames
  3096. * @param from The frame at the beginning of the animation
  3097. * @param to The frame at the end of the animation
  3098. * @param loopMode Specifies the loop mode of the animation
  3099. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  3100. * @param onAnimationEnd Callback to run once the animation is complete
  3101. * @returns Nullable animation
  3102. */
  3103. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  3104. /**
  3105. * Transition property of an host to the target Value
  3106. * @param property The property to transition
  3107. * @param targetValue The target Value of the property
  3108. * @param host The object where the property to animate belongs
  3109. * @param scene Scene used to run the animation
  3110. * @param frameRate Framerate (in frame/s) to use
  3111. * @param transition The transition type we want to use
  3112. * @param duration The duration of the animation, in milliseconds
  3113. * @param onAnimationEnd Callback trigger at the end of the animation
  3114. * @returns Nullable animation
  3115. */
  3116. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  3117. /**
  3118. * Return the array of runtime animations currently using this animation
  3119. */
  3120. readonly runtimeAnimations: RuntimeAnimation[];
  3121. /**
  3122. * Specifies if any of the runtime animations are currently running
  3123. */
  3124. readonly hasRunningRuntimeAnimations: boolean;
  3125. /**
  3126. * Initializes the animation
  3127. * @param name Name of the animation
  3128. * @param targetProperty Property to animate
  3129. * @param framePerSecond The frames per second of the animation
  3130. * @param dataType The data type of the animation
  3131. * @param loopMode The loop mode of the animation
  3132. * @param enableBlendings Specifies if blending should be enabled
  3133. */
  3134. constructor(
  3135. /**Name of the animation */
  3136. name: string,
  3137. /**Property to animate */
  3138. targetProperty: string,
  3139. /**The frames per second of the animation */
  3140. framePerSecond: number,
  3141. /**The data type of the animation */
  3142. dataType: number,
  3143. /**The loop mode of the animation */
  3144. loopMode?: number | undefined,
  3145. /**Specifies if blending should be enabled */
  3146. enableBlending?: boolean | undefined);
  3147. /**
  3148. * Converts the animation to a string
  3149. * @param fullDetails support for multiple levels of logging within scene loading
  3150. * @returns String form of the animation
  3151. */
  3152. toString(fullDetails?: boolean): string;
  3153. /**
  3154. * Add an event to this animation
  3155. * @param event Event to add
  3156. */
  3157. addEvent(event: AnimationEvent): void;
  3158. /**
  3159. * Remove all events found at the given frame
  3160. * @param frame The frame to remove events from
  3161. */
  3162. removeEvents(frame: number): void;
  3163. /**
  3164. * Retrieves all the events from the animation
  3165. * @returns Events from the animation
  3166. */
  3167. getEvents(): AnimationEvent[];
  3168. /**
  3169. * Creates an animation range
  3170. * @param name Name of the animation range
  3171. * @param from Starting frame of the animation range
  3172. * @param to Ending frame of the animation
  3173. */
  3174. createRange(name: string, from: number, to: number): void;
  3175. /**
  3176. * Deletes an animation range by name
  3177. * @param name Name of the animation range to delete
  3178. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  3179. */
  3180. deleteRange(name: string, deleteFrames?: boolean): void;
  3181. /**
  3182. * Gets the animation range by name, or null if not defined
  3183. * @param name Name of the animation range
  3184. * @returns Nullable animation range
  3185. */
  3186. getRange(name: string): Nullable<AnimationRange>;
  3187. /**
  3188. * Gets the key frames from the animation
  3189. * @returns The key frames of the animation
  3190. */
  3191. getKeys(): Array<IAnimationKey>;
  3192. /**
  3193. * Gets the highest frame rate of the animation
  3194. * @returns Highest frame rate of the animation
  3195. */
  3196. getHighestFrame(): number;
  3197. /**
  3198. * Gets the easing function of the animation
  3199. * @returns Easing function of the animation
  3200. */
  3201. getEasingFunction(): IEasingFunction;
  3202. /**
  3203. * Sets the easing function of the animation
  3204. * @param easingFunction A custom mathematical formula for animation
  3205. */
  3206. setEasingFunction(easingFunction: EasingFunction): void;
  3207. /**
  3208. * Interpolates a scalar linearly
  3209. * @param startValue Start value of the animation curve
  3210. * @param endValue End value of the animation curve
  3211. * @param gradient Scalar amount to interpolate
  3212. * @returns Interpolated scalar value
  3213. */
  3214. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  3215. /**
  3216. * Interpolates a scalar cubically
  3217. * @param startValue Start value of the animation curve
  3218. * @param outTangent End tangent of the animation
  3219. * @param endValue End value of the animation curve
  3220. * @param inTangent Start tangent of the animation curve
  3221. * @param gradient Scalar amount to interpolate
  3222. * @returns Interpolated scalar value
  3223. */
  3224. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  3225. /**
  3226. * Interpolates a quaternion using a spherical linear interpolation
  3227. * @param startValue Start value of the animation curve
  3228. * @param endValue End value of the animation curve
  3229. * @param gradient Scalar amount to interpolate
  3230. * @returns Interpolated quaternion value
  3231. */
  3232. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  3233. /**
  3234. * Interpolates a quaternion cubically
  3235. * @param startValue Start value of the animation curve
  3236. * @param outTangent End tangent of the animation curve
  3237. * @param endValue End value of the animation curve
  3238. * @param inTangent Start tangent of the animation curve
  3239. * @param gradient Scalar amount to interpolate
  3240. * @returns Interpolated quaternion value
  3241. */
  3242. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  3243. /**
  3244. * Interpolates a Vector3 linearl
  3245. * @param startValue Start value of the animation curve
  3246. * @param endValue End value of the animation curve
  3247. * @param gradient Scalar amount to interpolate
  3248. * @returns Interpolated scalar value
  3249. */
  3250. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  3251. /**
  3252. * Interpolates a Vector3 cubically
  3253. * @param startValue Start value of the animation curve
  3254. * @param outTangent End tangent of the animation
  3255. * @param endValue End value of the animation curve
  3256. * @param inTangent Start tangent of the animation curve
  3257. * @param gradient Scalar amount to interpolate
  3258. * @returns InterpolatedVector3 value
  3259. */
  3260. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  3261. /**
  3262. * Interpolates a Vector2 linearly
  3263. * @param startValue Start value of the animation curve
  3264. * @param endValue End value of the animation curve
  3265. * @param gradient Scalar amount to interpolate
  3266. * @returns Interpolated Vector2 value
  3267. */
  3268. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  3269. /**
  3270. * Interpolates a Vector2 cubically
  3271. * @param startValue Start value of the animation curve
  3272. * @param outTangent End tangent of the animation
  3273. * @param endValue End value of the animation curve
  3274. * @param inTangent Start tangent of the animation curve
  3275. * @param gradient Scalar amount to interpolate
  3276. * @returns Interpolated Vector2 value
  3277. */
  3278. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  3279. /**
  3280. * Interpolates a size linearly
  3281. * @param startValue Start value of the animation curve
  3282. * @param endValue End value of the animation curve
  3283. * @param gradient Scalar amount to interpolate
  3284. * @returns Interpolated Size value
  3285. */
  3286. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  3287. /**
  3288. * Interpolates a Color3 linearly
  3289. * @param startValue Start value of the animation curve
  3290. * @param endValue End value of the animation curve
  3291. * @param gradient Scalar amount to interpolate
  3292. * @returns Interpolated Color3 value
  3293. */
  3294. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  3295. /**
  3296. * @hidden Internal use only
  3297. */
  3298. _getKeyValue(value: any): any;
  3299. /**
  3300. * @hidden Internal use only
  3301. */
  3302. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  3303. /**
  3304. * Defines the function to use to interpolate matrices
  3305. * @param startValue defines the start matrix
  3306. * @param endValue defines the end matrix
  3307. * @param gradient defines the gradient between both matrices
  3308. * @param result defines an optional target matrix where to store the interpolation
  3309. * @returns the interpolated matrix
  3310. */
  3311. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  3312. /**
  3313. * Makes a copy of the animation
  3314. * @returns Cloned animation
  3315. */
  3316. clone(): Animation;
  3317. /**
  3318. * Sets the key frames of the animation
  3319. * @param values The animation key frames to set
  3320. */
  3321. setKeys(values: Array<IAnimationKey>): void;
  3322. /**
  3323. * Serializes the animation to an object
  3324. * @returns Serialized object
  3325. */
  3326. serialize(): any;
  3327. /**
  3328. * Float animation type
  3329. */
  3330. private static _ANIMATIONTYPE_FLOAT;
  3331. /**
  3332. * Vector3 animation type
  3333. */
  3334. private static _ANIMATIONTYPE_VECTOR3;
  3335. /**
  3336. * Quaternion animation type
  3337. */
  3338. private static _ANIMATIONTYPE_QUATERNION;
  3339. /**
  3340. * Matrix animation type
  3341. */
  3342. private static _ANIMATIONTYPE_MATRIX;
  3343. /**
  3344. * Color3 animation type
  3345. */
  3346. private static _ANIMATIONTYPE_COLOR3;
  3347. /**
  3348. * Vector2 animation type
  3349. */
  3350. private static _ANIMATIONTYPE_VECTOR2;
  3351. /**
  3352. * Size animation type
  3353. */
  3354. private static _ANIMATIONTYPE_SIZE;
  3355. /**
  3356. * Relative Loop Mode
  3357. */
  3358. private static _ANIMATIONLOOPMODE_RELATIVE;
  3359. /**
  3360. * Cycle Loop Mode
  3361. */
  3362. private static _ANIMATIONLOOPMODE_CYCLE;
  3363. /**
  3364. * Constant Loop Mode
  3365. */
  3366. private static _ANIMATIONLOOPMODE_CONSTANT;
  3367. /**
  3368. * Get the float animation type
  3369. */
  3370. static readonly ANIMATIONTYPE_FLOAT: number;
  3371. /**
  3372. * Get the Vector3 animation type
  3373. */
  3374. static readonly ANIMATIONTYPE_VECTOR3: number;
  3375. /**
  3376. * Get the Vector2 animation type
  3377. */
  3378. static readonly ANIMATIONTYPE_VECTOR2: number;
  3379. /**
  3380. * Get the Size animation type
  3381. */
  3382. static readonly ANIMATIONTYPE_SIZE: number;
  3383. /**
  3384. * Get the Quaternion animation type
  3385. */
  3386. static readonly ANIMATIONTYPE_QUATERNION: number;
  3387. /**
  3388. * Get the Matrix animation type
  3389. */
  3390. static readonly ANIMATIONTYPE_MATRIX: number;
  3391. /**
  3392. * Get the Color3 animation type
  3393. */
  3394. static readonly ANIMATIONTYPE_COLOR3: number;
  3395. /**
  3396. * Get the Relative Loop Mode
  3397. */
  3398. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  3399. /**
  3400. * Get the Cycle Loop Mode
  3401. */
  3402. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  3403. /**
  3404. * Get the Constant Loop Mode
  3405. */
  3406. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  3407. /** @hidden */
  3408. static _UniversalLerp(left: any, right: any, amount: number): any;
  3409. /**
  3410. * Parses an animation object and creates an animation
  3411. * @param parsedAnimation Parsed animation object
  3412. * @returns Animation object
  3413. */
  3414. static Parse(parsedAnimation: any): Animation;
  3415. /**
  3416. * Appends the serialized animations from the source animations
  3417. * @param source Source containing the animations
  3418. * @param destination Target to store the animations
  3419. */
  3420. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  3421. }
  3422. }
  3423. declare module BABYLON {
  3424. /**
  3425. * This class defines the direct association between an animation and a target
  3426. */
  3427. class TargetedAnimation {
  3428. /**
  3429. * Animation to perform
  3430. */
  3431. animation: Animation;
  3432. /**
  3433. * Target to animate
  3434. */
  3435. target: any;
  3436. }
  3437. /**
  3438. * Use this class to create coordinated animations on multiple targets
  3439. */
  3440. class AnimationGroup implements IDisposable {
  3441. /** The name of the animation group */
  3442. name: string;
  3443. private _scene;
  3444. private _targetedAnimations;
  3445. private _animatables;
  3446. private _from;
  3447. private _to;
  3448. private _isStarted;
  3449. private _speedRatio;
  3450. /**
  3451. * This observable will notify when one animation have ended.
  3452. */
  3453. onAnimationEndObservable: Observable<TargetedAnimation>;
  3454. /**
  3455. * This observable will notify when all animations have ended.
  3456. */
  3457. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  3458. /**
  3459. * This observable will notify when all animations have paused.
  3460. */
  3461. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  3462. /**
  3463. * Gets the first frame
  3464. */
  3465. readonly from: number;
  3466. /**
  3467. * Gets the last frame
  3468. */
  3469. readonly to: number;
  3470. /**
  3471. * Define if the animations are started
  3472. */
  3473. readonly isStarted: boolean;
  3474. /**
  3475. * Gets or sets the speed ratio to use for all animations
  3476. */
  3477. /**
  3478. * Gets or sets the speed ratio to use for all animations
  3479. */
  3480. speedRatio: number;
  3481. /**
  3482. * Gets the targeted animations for this animation group
  3483. */
  3484. readonly targetedAnimations: Array<TargetedAnimation>;
  3485. /**
  3486. * returning the list of animatables controlled by this animation group.
  3487. */
  3488. readonly animatables: Array<Animatable>;
  3489. /**
  3490. * Instantiates a new Animation Group.
  3491. * This helps managing several animations at once.
  3492. * @see http://doc.babylonjs.com/how_to/group
  3493. * @param name Defines the name of the group
  3494. * @param scene Defines the scene the group belongs to
  3495. */
  3496. constructor(
  3497. /** The name of the animation group */
  3498. name: string, scene?: Nullable<Scene>);
  3499. /**
  3500. * Add an animation (with its target) in the group
  3501. * @param animation defines the animation we want to add
  3502. * @param target defines the target of the animation
  3503. * @returns the TargetedAnimation object
  3504. */
  3505. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  3506. /**
  3507. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  3508. * It can add constant keys at begin or end
  3509. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  3510. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  3511. * @returns the animation group
  3512. */
  3513. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  3514. /**
  3515. * Start all animations on given targets
  3516. * @param loop defines if animations must loop
  3517. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  3518. * @param from defines the from key (optional)
  3519. * @param to defines the to key (optional)
  3520. * @returns the current animation group
  3521. */
  3522. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  3523. /**
  3524. * Pause all animations
  3525. * @returns the animation group
  3526. */
  3527. pause(): AnimationGroup;
  3528. /**
  3529. * Play all animations to initial state
  3530. * This function will start() the animations if they were not started or will restart() them if they were paused
  3531. * @param loop defines if animations must loop
  3532. * @returns the animation group
  3533. */
  3534. play(loop?: boolean): AnimationGroup;
  3535. /**
  3536. * Reset all animations to initial state
  3537. * @returns the animation group
  3538. */
  3539. reset(): AnimationGroup;
  3540. /**
  3541. * Restart animations from key 0
  3542. * @returns the animation group
  3543. */
  3544. restart(): AnimationGroup;
  3545. /**
  3546. * Stop all animations
  3547. * @returns the animation group
  3548. */
  3549. stop(): AnimationGroup;
  3550. /**
  3551. * Set animation weight for all animatables
  3552. * @param weight defines the weight to use
  3553. * @return the animationGroup
  3554. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  3555. */
  3556. setWeightForAllAnimatables(weight: number): AnimationGroup;
  3557. /**
  3558. * Synchronize and normalize all animatables with a source animatable
  3559. * @param root defines the root animatable to synchronize with
  3560. * @return the animationGroup
  3561. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  3562. */
  3563. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  3564. /**
  3565. * Goes to a specific frame in this animation group
  3566. * @param frame the frame number to go to
  3567. * @return the animationGroup
  3568. */
  3569. goToFrame(frame: number): AnimationGroup;
  3570. /**
  3571. * Dispose all associated resources
  3572. */
  3573. dispose(): void;
  3574. private _checkAnimationGroupEnded;
  3575. /**
  3576. * Returns a new AnimationGroup object parsed from the source provided.
  3577. * @param parsedAnimationGroup defines the source
  3578. * @param scene defines the scene that will receive the animationGroup
  3579. * @returns a new AnimationGroup
  3580. */
  3581. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  3582. /**
  3583. * Returns the string "AnimationGroup"
  3584. * @returns "AnimationGroup"
  3585. */
  3586. getClassName(): string;
  3587. /**
  3588. * Creates a detailled string about the object
  3589. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  3590. * @returns a string representing the object
  3591. */
  3592. toString(fullDetails?: boolean): string;
  3593. }
  3594. }
  3595. declare module BABYLON {
  3596. /**
  3597. * Class used to override all child animations of a given target
  3598. */
  3599. class AnimationPropertiesOverride {
  3600. /**
  3601. * Gets or sets a value indicating if animation blending must be used
  3602. */
  3603. enableBlending: boolean;
  3604. /**
  3605. * Gets or sets the blending speed to use when enableBlending is true
  3606. */
  3607. blendingSpeed: number;
  3608. /**
  3609. * Gets or sets the default loop mode to use
  3610. */
  3611. loopMode: number;
  3612. }
  3613. }
  3614. declare module BABYLON {
  3615. /**
  3616. * This represents the main contract an easing function should follow.
  3617. * Easing functions are used throughout the animation system.
  3618. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  3619. */
  3620. interface IEasingFunction {
  3621. /**
  3622. * Given an input gradient between 0 and 1, this returns the corrseponding value
  3623. * of the easing function.
  3624. * The link below provides some of the most common examples of easing functions.
  3625. * @see https://easings.net/
  3626. * @param gradient Defines the value between 0 and 1 we want the easing value for
  3627. * @returns the corresponding value on the curve defined by the easing function
  3628. */
  3629. ease(gradient: number): number;
  3630. }
  3631. /**
  3632. * Base class used for every default easing function.
  3633. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  3634. */
  3635. class EasingFunction implements IEasingFunction {
  3636. /**
  3637. * Interpolation follows the mathematical formula associated with the easing function.
  3638. */
  3639. static readonly EASINGMODE_EASEIN: number;
  3640. /**
  3641. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  3642. */
  3643. static readonly EASINGMODE_EASEOUT: number;
  3644. /**
  3645. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  3646. */
  3647. static readonly EASINGMODE_EASEINOUT: number;
  3648. private _easingMode;
  3649. /**
  3650. * Sets the easing mode of the current function.
  3651. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  3652. */
  3653. setEasingMode(easingMode: number): void;
  3654. /**
  3655. * Gets the current easing mode.
  3656. * @returns the easing mode
  3657. */
  3658. getEasingMode(): number;
  3659. /**
  3660. * @hidden
  3661. */
  3662. easeInCore(gradient: number): number;
  3663. /**
  3664. * Given an input gradient between 0 and 1, this returns the corrseponding value
  3665. * of the easing function.
  3666. * @param gradient Defines the value between 0 and 1 we want the easing value for
  3667. * @returns the corresponding value on the curve defined by the easing function
  3668. */
  3669. ease(gradient: number): number;
  3670. }
  3671. /**
  3672. * Easing function with a circle shape (see link below).
  3673. * @see https://easings.net/#easeInCirc
  3674. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  3675. */
  3676. class CircleEase extends EasingFunction implements IEasingFunction {
  3677. /** @hidden */
  3678. easeInCore(gradient: number): number;
  3679. }
  3680. /**
  3681. * Easing function with a ease back shape (see link below).
  3682. * @see https://easings.net/#easeInBack
  3683. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  3684. */
  3685. class BackEase extends EasingFunction implements IEasingFunction {
  3686. /** Defines the amplitude of the function */
  3687. amplitude: number;
  3688. /**
  3689. * Instantiates a back ease easing
  3690. * @see https://easings.net/#easeInBack
  3691. * @param amplitude Defines the amplitude of the function
  3692. */
  3693. constructor(
  3694. /** Defines the amplitude of the function */
  3695. amplitude?: number);
  3696. /** @hidden */
  3697. easeInCore(gradient: number): number;
  3698. }
  3699. /**
  3700. * Easing function with a bouncing shape (see link below).
  3701. * @see https://easings.net/#easeInBounce
  3702. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  3703. */
  3704. class BounceEase extends EasingFunction implements IEasingFunction {
  3705. /** Defines the number of bounces */
  3706. bounces: number;
  3707. /** Defines the amplitude of the bounce */
  3708. bounciness: number;
  3709. /**
  3710. * Instantiates a bounce easing
  3711. * @see https://easings.net/#easeInBounce
  3712. * @param bounces Defines the number of bounces
  3713. * @param bounciness Defines the amplitude of the bounce
  3714. */
  3715. constructor(
  3716. /** Defines the number of bounces */
  3717. bounces?: number,
  3718. /** Defines the amplitude of the bounce */
  3719. bounciness?: number);
  3720. /** @hidden */
  3721. easeInCore(gradient: number): number;
  3722. }
  3723. /**
  3724. * Easing function with a power of 3 shape (see link below).
  3725. * @see https://easings.net/#easeInCubic
  3726. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  3727. */
  3728. class CubicEase extends EasingFunction implements IEasingFunction {
  3729. /** @hidden */
  3730. easeInCore(gradient: number): number;
  3731. }
  3732. /**
  3733. * Easing function with an elastic shape (see link below).
  3734. * @see https://easings.net/#easeInElastic
  3735. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  3736. */
  3737. class ElasticEase extends EasingFunction implements IEasingFunction {
  3738. /** Defines the number of oscillations*/
  3739. oscillations: number;
  3740. /** Defines the amplitude of the oscillations*/
  3741. springiness: number;
  3742. /**
  3743. * Instantiates an elastic easing function
  3744. * @see https://easings.net/#easeInElastic
  3745. * @param oscillations Defines the number of oscillations
  3746. * @param springiness Defines the amplitude of the oscillations
  3747. */
  3748. constructor(
  3749. /** Defines the number of oscillations*/
  3750. oscillations?: number,
  3751. /** Defines the amplitude of the oscillations*/
  3752. springiness?: number);
  3753. /** @hidden */
  3754. easeInCore(gradient: number): number;
  3755. }
  3756. /**
  3757. * Easing function with an exponential shape (see link below).
  3758. * @see https://easings.net/#easeInExpo
  3759. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  3760. */
  3761. class ExponentialEase extends EasingFunction implements IEasingFunction {
  3762. /** Defines the exponent of the function */
  3763. exponent: number;
  3764. /**
  3765. * Instantiates an exponential easing function
  3766. * @see https://easings.net/#easeInExpo
  3767. * @param exponent Defines the exponent of the function
  3768. */
  3769. constructor(
  3770. /** Defines the exponent of the function */
  3771. exponent?: number);
  3772. /** @hidden */
  3773. easeInCore(gradient: number): number;
  3774. }
  3775. /**
  3776. * Easing function with a power shape (see link below).
  3777. * @see https://easings.net/#easeInQuad
  3778. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  3779. */
  3780. class PowerEase extends EasingFunction implements IEasingFunction {
  3781. /** Defines the power of the function */
  3782. power: number;
  3783. /**
  3784. * Instantiates an power base easing function
  3785. * @see https://easings.net/#easeInQuad
  3786. * @param power Defines the power of the function
  3787. */
  3788. constructor(
  3789. /** Defines the power of the function */
  3790. power?: number);
  3791. /** @hidden */
  3792. easeInCore(gradient: number): number;
  3793. }
  3794. /**
  3795. * Easing function with a power of 2 shape (see link below).
  3796. * @see https://easings.net/#easeInQuad
  3797. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  3798. */
  3799. class QuadraticEase extends EasingFunction implements IEasingFunction {
  3800. /** @hidden */
  3801. easeInCore(gradient: number): number;
  3802. }
  3803. /**
  3804. * Easing function with a power of 4 shape (see link below).
  3805. * @see https://easings.net/#easeInQuart
  3806. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  3807. */
  3808. class QuarticEase extends EasingFunction implements IEasingFunction {
  3809. /** @hidden */
  3810. easeInCore(gradient: number): number;
  3811. }
  3812. /**
  3813. * Easing function with a power of 5 shape (see link below).
  3814. * @see https://easings.net/#easeInQuint
  3815. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  3816. */
  3817. class QuinticEase extends EasingFunction implements IEasingFunction {
  3818. /** @hidden */
  3819. easeInCore(gradient: number): number;
  3820. }
  3821. /**
  3822. * Easing function with a sin shape (see link below).
  3823. * @see https://easings.net/#easeInSine
  3824. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  3825. */
  3826. class SineEase extends EasingFunction implements IEasingFunction {
  3827. /** @hidden */
  3828. easeInCore(gradient: number): number;
  3829. }
  3830. /**
  3831. * Easing function with a bezier shape (see link below).
  3832. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  3833. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  3834. */
  3835. class BezierCurveEase extends EasingFunction implements IEasingFunction {
  3836. /** Defines the x component of the start tangent in the bezier curve */
  3837. x1: number;
  3838. /** Defines the y component of the start tangent in the bezier curve */
  3839. y1: number;
  3840. /** Defines the x component of the end tangent in the bezier curve */
  3841. x2: number;
  3842. /** Defines the y component of the end tangent in the bezier curve */
  3843. y2: number;
  3844. /**
  3845. * Instantiates a bezier function
  3846. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  3847. * @param x1 Defines the x component of the start tangent in the bezier curve
  3848. * @param y1 Defines the y component of the start tangent in the bezier curve
  3849. * @param x2 Defines the x component of the end tangent in the bezier curve
  3850. * @param y2 Defines the y component of the end tangent in the bezier curve
  3851. */
  3852. constructor(
  3853. /** Defines the x component of the start tangent in the bezier curve */
  3854. x1?: number,
  3855. /** Defines the y component of the start tangent in the bezier curve */
  3856. y1?: number,
  3857. /** Defines the x component of the end tangent in the bezier curve */
  3858. x2?: number,
  3859. /** Defines the y component of the end tangent in the bezier curve */
  3860. y2?: number);
  3861. /** @hidden */
  3862. easeInCore(gradient: number): number;
  3863. }
  3864. }
  3865. declare module BABYLON {
  3866. /**
  3867. * Defines a runtime animation
  3868. */
  3869. class RuntimeAnimation {
  3870. private _events;
  3871. /**
  3872. * The current frame of the runtime animation
  3873. */
  3874. private _currentFrame;
  3875. /**
  3876. * The animation used by the runtime animation
  3877. */
  3878. private _animation;
  3879. /**
  3880. * The target of the runtime animation
  3881. */
  3882. private _target;
  3883. /**
  3884. * The initiating animatable
  3885. */
  3886. private _host;
  3887. /**
  3888. * The original value of the runtime animation
  3889. */
  3890. private _originalValue;
  3891. /**
  3892. * The original blend value of the runtime animation
  3893. */
  3894. private _originalBlendValue;
  3895. /**
  3896. * The offsets cache of the runtime animation
  3897. */
  3898. private _offsetsCache;
  3899. /**
  3900. * The high limits cache of the runtime animation
  3901. */
  3902. private _highLimitsCache;
  3903. /**
  3904. * Specifies if the runtime animation has been stopped
  3905. */
  3906. private _stopped;
  3907. /**
  3908. * The blending factor of the runtime animation
  3909. */
  3910. private _blendingFactor;
  3911. /**
  3912. * The BabylonJS scene
  3913. */
  3914. private _scene;
  3915. /**
  3916. * The current value of the runtime animation
  3917. */
  3918. private _currentValue;
  3919. /** @hidden */
  3920. _workValue: any;
  3921. /**
  3922. * The active target of the runtime animation
  3923. */
  3924. private _activeTarget;
  3925. /**
  3926. * The target path of the runtime animation
  3927. */
  3928. private _targetPath;
  3929. /**
  3930. * The weight of the runtime animation
  3931. */
  3932. private _weight;
  3933. /**
  3934. * The ratio offset of the runtime animation
  3935. */
  3936. private _ratioOffset;
  3937. /**
  3938. * The previous delay of the runtime animation
  3939. */
  3940. private _previousDelay;
  3941. /**
  3942. * The previous ratio of the runtime animation
  3943. */
  3944. private _previousRatio;
  3945. /**
  3946. * Gets the current frame of the runtime animation
  3947. */
  3948. readonly currentFrame: number;
  3949. /**
  3950. * Gets the weight of the runtime animation
  3951. */
  3952. readonly weight: number;
  3953. /**
  3954. * Gets the current value of the runtime animation
  3955. */
  3956. readonly currentValue: any;
  3957. /**
  3958. * Gets the target path of the runtime animation
  3959. */
  3960. readonly targetPath: string;
  3961. /**
  3962. * Gets the actual target of the runtime animation
  3963. */
  3964. readonly target: any;
  3965. /**
  3966. * Create a new RuntimeAnimation object
  3967. * @param target defines the target of the animation
  3968. * @param animation defines the source animation object
  3969. * @param scene defines the hosting scene
  3970. * @param host defines the initiating Animatable
  3971. */
  3972. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  3973. /**
  3974. * Gets the animation from the runtime animation
  3975. */
  3976. readonly animation: Animation;
  3977. /**
  3978. * Resets the runtime animation to the beginning
  3979. * @param restoreOriginal defines whether to restore the target property to the original value
  3980. */
  3981. reset(restoreOriginal?: boolean): void;
  3982. /**
  3983. * Specifies if the runtime animation is stopped
  3984. * @returns Boolean specifying if the runtime animation is stopped
  3985. */
  3986. isStopped(): boolean;
  3987. /**
  3988. * Disposes of the runtime animation
  3989. */
  3990. dispose(): void;
  3991. /**
  3992. * Interpolates the animation from the current frame
  3993. * @param currentFrame The frame to interpolate the animation to
  3994. * @param repeatCount The number of times that the animation should loop
  3995. * @param loopMode The type of looping mode to use
  3996. * @param offsetValue Animation offset value
  3997. * @param highLimitValue The high limit value
  3998. * @returns The interpolated value
  3999. */
  4000. private _interpolate;
  4001. /**
  4002. * Apply the interpolated value to the target
  4003. * @param currentValue defines the value computed by the animation
  4004. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  4005. */
  4006. setValue(currentValue: any, weight?: number): void;
  4007. private _setValue;
  4008. /**
  4009. * Gets the loop pmode of the runtime animation
  4010. * @returns Loop Mode
  4011. */
  4012. private _getCorrectLoopMode;
  4013. /**
  4014. * Move the current animation to a given frame
  4015. * @param frame defines the frame to move to
  4016. */
  4017. goToFrame(frame: number): void;
  4018. /**
  4019. * @hidden Internal use only
  4020. */
  4021. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  4022. /**
  4023. * Execute the current animation
  4024. * @param delay defines the delay to add to the current frame
  4025. * @param from defines the lower bound of the animation range
  4026. * @param to defines the upper bound of the animation range
  4027. * @param loop defines if the current animation must loop
  4028. * @param speedRatio defines the current speed ratio
  4029. * @param weight defines the weight of the animation (default is -1 so no weight)
  4030. * @returns a boolean indicating if the animation is running
  4031. */
  4032. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  4033. }
  4034. }
  4035. declare module BABYLON {
  4036. /**
  4037. * Class used to work with sound analyzer using fast fourier transform (FFT)
  4038. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  4039. */
  4040. class Analyser {
  4041. /**
  4042. * Gets or sets the smoothing
  4043. * @ignorenaming
  4044. */
  4045. SMOOTHING: number;
  4046. /**
  4047. * Gets or sets the FFT table size
  4048. * @ignorenaming
  4049. */
  4050. FFT_SIZE: number;
  4051. /**
  4052. * Gets or sets the bar graph amplitude
  4053. * @ignorenaming
  4054. */
  4055. BARGRAPHAMPLITUDE: number;
  4056. /**
  4057. * Gets or sets the position of the debug canvas
  4058. * @ignorenaming
  4059. */
  4060. DEBUGCANVASPOS: {
  4061. x: number;
  4062. y: number;
  4063. };
  4064. /**
  4065. * Gets or sets the debug canvas size
  4066. * @ignorenaming
  4067. */
  4068. DEBUGCANVASSIZE: {
  4069. width: number;
  4070. height: number;
  4071. };
  4072. private _byteFreqs;
  4073. private _byteTime;
  4074. private _floatFreqs;
  4075. private _webAudioAnalyser;
  4076. private _debugCanvas;
  4077. private _debugCanvasContext;
  4078. private _scene;
  4079. private _registerFunc;
  4080. private _audioEngine;
  4081. /**
  4082. * Creates a new analyser
  4083. * @param scene defines hosting scene
  4084. */
  4085. constructor(scene: Scene);
  4086. /**
  4087. * Get the number of data values you will have to play with for the visualization
  4088. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  4089. * @returns a number
  4090. */
  4091. getFrequencyBinCount(): number;
  4092. /**
  4093. * Gets the current frequency data as a byte array
  4094. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  4095. * @returns a Uint8Array
  4096. */
  4097. getByteFrequencyData(): Uint8Array;
  4098. /**
  4099. * Gets the current waveform as a byte array
  4100. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  4101. * @returns a Uint8Array
  4102. */
  4103. getByteTimeDomainData(): Uint8Array;
  4104. /**
  4105. * Gets the current frequency data as a float array
  4106. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  4107. * @returns a Float32Array
  4108. */
  4109. getFloatFrequencyData(): Float32Array;
  4110. /**
  4111. * Renders the debug canvas
  4112. */
  4113. drawDebugCanvas(): void;
  4114. /**
  4115. * Stops rendering the debug canvas and removes it
  4116. */
  4117. stopDebugCanvas(): void;
  4118. /**
  4119. * Connects two audio nodes
  4120. * @param inputAudioNode defines first node to connect
  4121. * @param outputAudioNode defines second node to connect
  4122. */
  4123. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  4124. /**
  4125. * Releases all associated resources
  4126. */
  4127. dispose(): void;
  4128. }
  4129. }
  4130. declare module BABYLON {
  4131. /**
  4132. * This represents an audio engine and it is responsible
  4133. * to play, synchronize and analyse sounds throughout the application.
  4134. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  4135. */
  4136. interface IAudioEngine extends IDisposable {
  4137. /**
  4138. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  4139. */
  4140. readonly canUseWebAudio: boolean;
  4141. /**
  4142. * Gets the current AudioContext if available.
  4143. */
  4144. readonly audioContext: Nullable<AudioContext>;
  4145. /**
  4146. * The master gain node defines the global audio volume of your audio engine.
  4147. */
  4148. readonly masterGain: GainNode;
  4149. /**
  4150. * Gets whether or not mp3 are supported by your browser.
  4151. */
  4152. readonly isMP3supported: boolean;
  4153. /**
  4154. * Gets whether or not ogg are supported by your browser.
  4155. */
  4156. readonly isOGGsupported: boolean;
  4157. /**
  4158. * Defines if Babylon should emit a warning if WebAudio is not supported.
  4159. * @ignoreNaming
  4160. */
  4161. WarnedWebAudioUnsupported: boolean;
  4162. /**
  4163. * Defines if the audio engine relies on a custom unlocked button.
  4164. * In this case, the embedded button will not be displayed.
  4165. */
  4166. useCustomUnlockedButton: boolean;
  4167. /**
  4168. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  4169. */
  4170. readonly unlocked: boolean;
  4171. /**
  4172. * Event raised when audio has been unlocked on the browser.
  4173. */
  4174. onAudioUnlockedObservable: Observable<AudioEngine>;
  4175. /**
  4176. * Event raised when audio has been locked on the browser.
  4177. */
  4178. onAudioLockedObservable: Observable<AudioEngine>;
  4179. /**
  4180. * Flags the audio engine in Locked state.
  4181. * This happens due to new browser policies preventing audio to autoplay.
  4182. */
  4183. lock(): void;
  4184. /**
  4185. * Unlocks the audio engine once a user action has been done on the dom.
  4186. * This is helpful to resume play once browser policies have been satisfied.
  4187. */
  4188. unlock(): void;
  4189. }
  4190. /**
  4191. * This represents the default audio engine used in babylon.
  4192. * It is responsible to play, synchronize and analyse sounds throughout the application.
  4193. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  4194. */
  4195. class AudioEngine implements IAudioEngine {
  4196. private _audioContext;
  4197. private _audioContextInitialized;
  4198. private _muteButton;
  4199. private _hostElement;
  4200. /**
  4201. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  4202. */
  4203. canUseWebAudio: boolean;
  4204. /**
  4205. * The master gain node defines the global audio volume of your audio engine.
  4206. */
  4207. masterGain: GainNode;
  4208. /**
  4209. * Defines if Babylon should emit a warning if WebAudio is not supported.
  4210. * @ignoreNaming
  4211. */
  4212. WarnedWebAudioUnsupported: boolean;
  4213. /**
  4214. * Gets whether or not mp3 are supported by your browser.
  4215. */
  4216. isMP3supported: boolean;
  4217. /**
  4218. * Gets whether or not ogg are supported by your browser.
  4219. */
  4220. isOGGsupported: boolean;
  4221. /**
  4222. * Gets whether audio has been unlocked on the device.
  4223. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  4224. * a user interaction has happened.
  4225. */
  4226. unlocked: boolean;
  4227. /**
  4228. * Defines if the audio engine relies on a custom unlocked button.
  4229. * In this case, the embedded button will not be displayed.
  4230. */
  4231. useCustomUnlockedButton: boolean;
  4232. /**
  4233. * Event raised when audio has been unlocked on the browser.
  4234. */
  4235. onAudioUnlockedObservable: Observable<AudioEngine>;
  4236. /**
  4237. * Event raised when audio has been locked on the browser.
  4238. */
  4239. onAudioLockedObservable: Observable<AudioEngine>;
  4240. /**
  4241. * Gets the current AudioContext if available.
  4242. */
  4243. readonly audioContext: Nullable<AudioContext>;
  4244. private _connectedAnalyser;
  4245. /**
  4246. * Instantiates a new audio engine.
  4247. *
  4248. * There should be only one per page as some browsers restrict the number
  4249. * of audio contexts you can create.
  4250. * @param hostElement defines the host element where to display the mute icon if necessary
  4251. */
  4252. constructor(hostElement?: Nullable<HTMLElement>);
  4253. /**
  4254. * Flags the audio engine in Locked state.
  4255. * This happens due to new browser policies preventing audio to autoplay.
  4256. */
  4257. lock(): void;
  4258. /**
  4259. * Unlocks the audio engine once a user action has been done on the dom.
  4260. * This is helpful to resume play once browser policies have been satisfied.
  4261. */
  4262. unlock(): void;
  4263. private _resumeAudioContext;
  4264. private _initializeAudioContext;
  4265. private _tryToRun;
  4266. private _triggerRunningState;
  4267. private _triggerSuspendedState;
  4268. private _displayMuteButton;
  4269. private _moveButtonToTopLeft;
  4270. private _onResize;
  4271. private _hideMuteButton;
  4272. /**
  4273. * Destroy and release the resources associated with the audio ccontext.
  4274. */
  4275. dispose(): void;
  4276. /**
  4277. * Gets the global volume sets on the master gain.
  4278. * @returns the global volume if set or -1 otherwise
  4279. */
  4280. getGlobalVolume(): number;
  4281. /**
  4282. * Sets the global volume of your experience (sets on the master gain).
  4283. * @param newVolume Defines the new global volume of the application
  4284. */
  4285. setGlobalVolume(newVolume: number): void;
  4286. /**
  4287. * Connect the audio engine to an audio analyser allowing some amazing
  4288. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  4289. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  4290. * @param analyser The analyser to connect to the engine
  4291. */
  4292. connectToAnalyser(analyser: Analyser): void;
  4293. }
  4294. }
  4295. declare module BABYLON {
  4296. interface AbstractScene {
  4297. /**
  4298. * The list of sounds used in the scene.
  4299. */
  4300. sounds: Nullable<Array<Sound>>;
  4301. }
  4302. interface Scene {
  4303. /**
  4304. * @hidden
  4305. * Backing field
  4306. */
  4307. _mainSoundTrack: SoundTrack;
  4308. /**
  4309. * The main sound track played by the scene.
  4310. * It cotains your primary collection of sounds.
  4311. */
  4312. mainSoundTrack: SoundTrack;
  4313. /**
  4314. * The list of sound tracks added to the scene
  4315. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  4316. */
  4317. soundTracks: Nullable<Array<SoundTrack>>;
  4318. /**
  4319. * Gets a sound using a given name
  4320. * @param name defines the name to search for
  4321. * @return the found sound or null if not found at all.
  4322. */
  4323. getSoundByName(name: string): Nullable<Sound>;
  4324. /**
  4325. * Gets or sets if audio support is enabled
  4326. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  4327. */
  4328. audioEnabled: boolean;
  4329. /**
  4330. * Gets or sets if audio will be output to headphones
  4331. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  4332. */
  4333. headphone: boolean;
  4334. }
  4335. /**
  4336. * Defines the sound scene component responsible to manage any sounds
  4337. * in a given scene.
  4338. */
  4339. class AudioSceneComponent implements ISceneSerializableComponent {
  4340. /**
  4341. * The component name helpfull to identify the component in the list of scene components.
  4342. */
  4343. readonly name: string;
  4344. /**
  4345. * The scene the component belongs to.
  4346. */
  4347. scene: Scene;
  4348. private _audioEnabled;
  4349. /**
  4350. * Gets whether audio is enabled or not.
  4351. * Please use related enable/disable method to switch state.
  4352. */
  4353. readonly audioEnabled: boolean;
  4354. private _headphone;
  4355. /**
  4356. * Gets whether audio is outputing to headphone or not.
  4357. * Please use the according Switch methods to change output.
  4358. */
  4359. readonly headphone: boolean;
  4360. /**
  4361. * Creates a new instance of the component for the given scene
  4362. * @param scene Defines the scene to register the component in
  4363. */
  4364. constructor(scene: Scene);
  4365. /**
  4366. * Registers the component in a given scene
  4367. */
  4368. register(): void;
  4369. /**
  4370. * Rebuilds the elements related to this component in case of
  4371. * context lost for instance.
  4372. */
  4373. rebuild(): void;
  4374. /**
  4375. * Serializes the component data to the specified json object
  4376. * @param serializationObject The object to serialize to
  4377. */
  4378. serialize(serializationObject: any): void;
  4379. /**
  4380. * Adds all the element from the container to the scene
  4381. * @param container the container holding the elements
  4382. */
  4383. addFromContainer(container: AbstractScene): void;
  4384. /**
  4385. * Removes all the elements in the container from the scene
  4386. * @param container contains the elements to remove
  4387. */
  4388. removeFromContainer(container: AbstractScene): void;
  4389. /**
  4390. * Disposes the component and the associated ressources.
  4391. */
  4392. dispose(): void;
  4393. /**
  4394. * Disables audio in the associated scene.
  4395. */
  4396. disableAudio(): void;
  4397. /**
  4398. * Enables audio in the associated scene.
  4399. */
  4400. enableAudio(): void;
  4401. /**
  4402. * Switch audio to headphone output.
  4403. */
  4404. switchAudioModeForHeadphones(): void;
  4405. /**
  4406. * Switch audio to normal speakers.
  4407. */
  4408. switchAudioModeForNormalSpeakers(): void;
  4409. private _afterRender;
  4410. }
  4411. }
  4412. declare module BABYLON {
  4413. /**
  4414. * Defines a sound that can be played in the application.
  4415. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  4416. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  4417. */
  4418. class Sound {
  4419. /**
  4420. * The name of the sound in the scene.
  4421. */
  4422. name: string;
  4423. /**
  4424. * Does the sound autoplay once loaded.
  4425. */
  4426. autoplay: boolean;
  4427. /**
  4428. * Does the sound loop after it finishes playing once.
  4429. */
  4430. loop: boolean;
  4431. /**
  4432. * Does the sound use a custom attenuation curve to simulate the falloff
  4433. * happening when the source gets further away from the camera.
  4434. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  4435. */
  4436. useCustomAttenuation: boolean;
  4437. /**
  4438. * The sound track id this sound belongs to.
  4439. */
  4440. soundTrackId: number;
  4441. /**
  4442. * Is this sound currently played.
  4443. */
  4444. isPlaying: boolean;
  4445. /**
  4446. * Is this sound currently paused.
  4447. */
  4448. isPaused: boolean;
  4449. /**
  4450. * Does this sound enables spatial sound.
  4451. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  4452. */
  4453. spatialSound: boolean;
  4454. /**
  4455. * Define the reference distance the sound should be heard perfectly.
  4456. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  4457. */
  4458. refDistance: number;
  4459. /**
  4460. * Define the roll off factor of spatial sounds.
  4461. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  4462. */
  4463. rolloffFactor: number;
  4464. /**
  4465. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  4466. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  4467. */
  4468. maxDistance: number;
  4469. /**
  4470. * Define the distance attenuation model the sound will follow.
  4471. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  4472. */
  4473. distanceModel: string;
  4474. /**
  4475. * @hidden
  4476. * Back Compat
  4477. **/
  4478. onended: () => any;
  4479. /**
  4480. * Observable event when the current playing sound finishes.
  4481. */
  4482. onEndedObservable: Observable<Sound>;
  4483. private _panningModel;
  4484. private _playbackRate;
  4485. private _streaming;
  4486. private _startTime;
  4487. private _startOffset;
  4488. private _position;
  4489. /** @hidden */
  4490. _positionInEmitterSpace: boolean;
  4491. private _localDirection;
  4492. private _volume;
  4493. private _isReadyToPlay;
  4494. private _isDirectional;
  4495. private _readyToPlayCallback;
  4496. private _audioBuffer;
  4497. private _soundSource;
  4498. private _streamingSource;
  4499. private _soundPanner;
  4500. private _soundGain;
  4501. private _inputAudioNode;
  4502. private _outputAudioNode;
  4503. private _coneInnerAngle;
  4504. private _coneOuterAngle;
  4505. private _coneOuterGain;
  4506. private _scene;
  4507. private _connectedMesh;
  4508. private _customAttenuationFunction;
  4509. private _registerFunc;
  4510. private _isOutputConnected;
  4511. private _htmlAudioElement;
  4512. private _urlType;
  4513. /**
  4514. * Create a sound and attach it to a scene
  4515. * @param name Name of your sound
  4516. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  4517. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  4518. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  4519. */
  4520. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  4521. /**
  4522. * Release the sound and its associated resources
  4523. */
  4524. dispose(): void;
  4525. /**
  4526. * Gets if the sounds is ready to be played or not.
  4527. * @returns true if ready, otherwise false
  4528. */
  4529. isReady(): boolean;
  4530. private _soundLoaded;
  4531. /**
  4532. * Sets the data of the sound from an audiobuffer
  4533. * @param audioBuffer The audioBuffer containing the data
  4534. */
  4535. setAudioBuffer(audioBuffer: AudioBuffer): void;
  4536. /**
  4537. * Updates the current sounds options such as maxdistance, loop...
  4538. * @param options A JSON object containing values named as the object properties
  4539. */
  4540. updateOptions(options: any): void;
  4541. private _createSpatialParameters;
  4542. private _updateSpatialParameters;
  4543. /**
  4544. * Switch the panning model to HRTF:
  4545. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  4546. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  4547. */
  4548. switchPanningModelToHRTF(): void;
  4549. /**
  4550. * Switch the panning model to Equal Power:
  4551. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  4552. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  4553. */
  4554. switchPanningModelToEqualPower(): void;
  4555. private _switchPanningModel;
  4556. /**
  4557. * Connect this sound to a sound track audio node like gain...
  4558. * @param soundTrackAudioNode the sound track audio node to connect to
  4559. */
  4560. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  4561. /**
  4562. * Transform this sound into a directional source
  4563. * @param coneInnerAngle Size of the inner cone in degree
  4564. * @param coneOuterAngle Size of the outer cone in degree
  4565. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  4566. */
  4567. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  4568. /**
  4569. * Gets or sets the inner angle for the directional cone.
  4570. */
  4571. /**
  4572. * Gets or sets the inner angle for the directional cone.
  4573. */
  4574. directionalConeInnerAngle: number;
  4575. /**
  4576. * Gets or sets the outer angle for the directional cone.
  4577. */
  4578. /**
  4579. * Gets or sets the outer angle for the directional cone.
  4580. */
  4581. directionalConeOuterAngle: number;
  4582. /**
  4583. * Sets the position of the emitter if spatial sound is enabled
  4584. * @param newPosition Defines the new posisiton
  4585. */
  4586. setPosition(newPosition: Vector3): void;
  4587. /**
  4588. * Sets the local direction of the emitter if spatial sound is enabled
  4589. * @param newLocalDirection Defines the new local direction
  4590. */
  4591. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  4592. private _updateDirection;
  4593. /** @hidden */
  4594. updateDistanceFromListener(): void;
  4595. /**
  4596. * Sets a new custom attenuation function for the sound.
  4597. * @param callback Defines the function used for the attenuation
  4598. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  4599. */
  4600. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  4601. /**
  4602. * Play the sound
  4603. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  4604. * @param offset (optional) Start the sound setting it at a specific time
  4605. */
  4606. play(time?: number, offset?: number): void;
  4607. private _onended;
  4608. /**
  4609. * Stop the sound
  4610. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  4611. */
  4612. stop(time?: number): void;
  4613. /**
  4614. * Put the sound in pause
  4615. */
  4616. pause(): void;
  4617. /**
  4618. * Sets a dedicated volume for this sounds
  4619. * @param newVolume Define the new volume of the sound
  4620. * @param time Define in how long the sound should be at this value
  4621. */
  4622. setVolume(newVolume: number, time?: number): void;
  4623. /**
  4624. * Set the sound play back rate
  4625. * @param newPlaybackRate Define the playback rate the sound should be played at
  4626. */
  4627. setPlaybackRate(newPlaybackRate: number): void;
  4628. /**
  4629. * Gets the volume of the sound.
  4630. * @returns the volume of the sound
  4631. */
  4632. getVolume(): number;
  4633. /**
  4634. * Attach the sound to a dedicated mesh
  4635. * @param meshToConnectTo The mesh to connect the sound with
  4636. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  4637. */
  4638. attachToMesh(meshToConnectTo: AbstractMesh): void;
  4639. /**
  4640. * Detach the sound from the previously attached mesh
  4641. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  4642. */
  4643. detachFromMesh(): void;
  4644. private _onRegisterAfterWorldMatrixUpdate;
  4645. /**
  4646. * Clone the current sound in the scene.
  4647. * @returns the new sound clone
  4648. */
  4649. clone(): Nullable<Sound>;
  4650. /**
  4651. * Gets the current underlying audio buffer containing the data
  4652. * @returns the audio buffer
  4653. */
  4654. getAudioBuffer(): Nullable<AudioBuffer>;
  4655. /**
  4656. * Serializes the Sound in a JSON representation
  4657. * @returns the JSON representation of the sound
  4658. */
  4659. serialize(): any;
  4660. /**
  4661. * Parse a JSON representation of a sound to innstantiate in a given scene
  4662. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  4663. * @param scene Define the scene the new parsed sound should be created in
  4664. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  4665. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  4666. * @returns the newly parsed sound
  4667. */
  4668. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  4669. }
  4670. }
  4671. declare module BABYLON {
  4672. /**
  4673. * Options allowed during the creation of a sound track.
  4674. */
  4675. interface ISoundTrackOptions {
  4676. /**
  4677. * The volume the sound track should take during creation
  4678. */
  4679. volume?: number;
  4680. /**
  4681. * Define if the sound track is the main sound track of the scene
  4682. */
  4683. mainTrack?: boolean;
  4684. }
  4685. /**
  4686. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  4687. * It will be also used in a future release to apply effects on a specific track.
  4688. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  4689. */
  4690. class SoundTrack {
  4691. /**
  4692. * The unique identifier of the sound track in the scene.
  4693. */
  4694. id: number;
  4695. /**
  4696. * The list of sounds included in the sound track.
  4697. */
  4698. soundCollection: Array<Sound>;
  4699. private _outputAudioNode;
  4700. private _scene;
  4701. private _isMainTrack;
  4702. private _connectedAnalyser;
  4703. private _options;
  4704. private _isInitialized;
  4705. /**
  4706. * Creates a new sound track.
  4707. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  4708. * @param scene Define the scene the sound track belongs to
  4709. * @param options
  4710. */
  4711. constructor(scene: Scene, options?: ISoundTrackOptions);
  4712. private _initializeSoundTrackAudioGraph;
  4713. /**
  4714. * Release the sound track and its associated resources
  4715. */
  4716. dispose(): void;
  4717. /**
  4718. * Adds a sound to this sound track
  4719. * @param sound define the cound to add
  4720. * @ignoreNaming
  4721. */
  4722. AddSound(sound: Sound): void;
  4723. /**
  4724. * Removes a sound to this sound track
  4725. * @param sound define the cound to remove
  4726. * @ignoreNaming
  4727. */
  4728. RemoveSound(sound: Sound): void;
  4729. /**
  4730. * Set a global volume for the full sound track.
  4731. * @param newVolume Define the new volume of the sound track
  4732. */
  4733. setVolume(newVolume: number): void;
  4734. /**
  4735. * Switch the panning model to HRTF:
  4736. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  4737. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  4738. */
  4739. switchPanningModelToHRTF(): void;
  4740. /**
  4741. * Switch the panning model to Equal Power:
  4742. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  4743. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  4744. */
  4745. switchPanningModelToEqualPower(): void;
  4746. /**
  4747. * Connect the sound track to an audio analyser allowing some amazing
  4748. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  4749. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  4750. * @param analyser The analyser to connect to the engine
  4751. */
  4752. connectToAnalyser(analyser: Analyser): void;
  4753. }
  4754. }
  4755. declare module BABYLON {
  4756. /**
  4757. * Wraps one or more Sound objects and selects one with random weight for playback.
  4758. */
  4759. class WeightedSound {
  4760. /** When true a Sound will be selected and played when the current playing Sound completes. */
  4761. loop: boolean;
  4762. private _coneInnerAngle;
  4763. private _coneOuterAngle;
  4764. private _volume;
  4765. /** A Sound is currently playing. */
  4766. isPlaying: boolean;
  4767. /** A Sound is currently paused. */
  4768. isPaused: boolean;
  4769. private _sounds;
  4770. private _weights;
  4771. private _currentIndex?;
  4772. /**
  4773. * Creates a new WeightedSound from the list of sounds given.
  4774. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  4775. * @param sounds Array of Sounds that will be selected from.
  4776. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  4777. */
  4778. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  4779. /**
  4780. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  4781. */
  4782. /**
  4783. * The size of cone in degress for a directional sound in which there will be no attenuation.
  4784. */
  4785. directionalConeInnerAngle: number;
  4786. /**
  4787. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  4788. * Listener angles between innerAngle and outerAngle will falloff linearly.
  4789. */
  4790. /**
  4791. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  4792. * Listener angles between innerAngle and outerAngle will falloff linearly.
  4793. */
  4794. directionalConeOuterAngle: number;
  4795. /**
  4796. * Playback volume.
  4797. */
  4798. /**
  4799. * Playback volume.
  4800. */
  4801. volume: number;
  4802. private _onended;
  4803. /**
  4804. * Suspend playback
  4805. */
  4806. pause(): void;
  4807. /**
  4808. * Stop playback
  4809. */
  4810. stop(): void;
  4811. /**
  4812. * Start playback.
  4813. * @param startOffset Position the clip head at a specific time in seconds.
  4814. */
  4815. play(startOffset?: number): void;
  4816. }
  4817. }
  4818. declare module BABYLON {
  4819. /**
  4820. * The action to be carried out following a trigger
  4821. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  4822. */
  4823. class Action {
  4824. /** the trigger, with or without parameters, for the action */
  4825. triggerOptions: any;
  4826. /**
  4827. * Trigger for the action
  4828. */
  4829. trigger: number;
  4830. /**
  4831. * Internal only - manager for action
  4832. * @hidden
  4833. */
  4834. _actionManager: ActionManager;
  4835. private _nextActiveAction;
  4836. private _child;
  4837. private _condition?;
  4838. private _triggerParameter;
  4839. /**
  4840. * An event triggered prior to action being executed.
  4841. */
  4842. onBeforeExecuteObservable: Observable<Action>;
  4843. /**
  4844. * Creates a new Action
  4845. * @param triggerOptions the trigger, with or without parameters, for the action
  4846. * @param condition an optional determinant of action
  4847. */
  4848. constructor(
  4849. /** the trigger, with or without parameters, for the action */
  4850. triggerOptions: any, condition?: Condition);
  4851. /**
  4852. * Internal only
  4853. * @hidden
  4854. */
  4855. _prepare(): void;
  4856. /**
  4857. * Gets the trigger parameters
  4858. * @returns the trigger parameters
  4859. */
  4860. getTriggerParameter(): any;
  4861. /**
  4862. * Internal only - executes current action event
  4863. * @hidden
  4864. */
  4865. _executeCurrent(evt?: ActionEvent): void;
  4866. /**
  4867. * Execute placeholder for child classes
  4868. * @param evt optional action event
  4869. */
  4870. execute(evt?: ActionEvent): void;
  4871. /**
  4872. * Skips to next active action
  4873. */
  4874. skipToNextActiveAction(): void;
  4875. /**
  4876. * Adds action to chain of actions, may be a DoNothingAction
  4877. * @param action defines the next action to execute
  4878. * @returns The action passed in
  4879. * @see https://www.babylonjs-playground.com/#1T30HR#0
  4880. */
  4881. then(action: Action): Action;
  4882. /**
  4883. * Internal only
  4884. * @hidden
  4885. */
  4886. _getProperty(propertyPath: string): string;
  4887. /**
  4888. * Internal only
  4889. * @hidden
  4890. */
  4891. _getEffectiveTarget(target: any, propertyPath: string): any;
  4892. /**
  4893. * Serialize placeholder for child classes
  4894. * @param parent of child
  4895. * @returns the serialized object
  4896. */
  4897. serialize(parent: any): any;
  4898. /**
  4899. * Internal only called by serialize
  4900. * @hidden
  4901. */
  4902. protected _serialize(serializedAction: any, parent?: any): any;
  4903. /**
  4904. * Internal only
  4905. * @hidden
  4906. */
  4907. static _SerializeValueAsString: (value: any) => string;
  4908. /**
  4909. * Internal only
  4910. * @hidden
  4911. */
  4912. static _GetTargetProperty: (target: Scene | Node) => {
  4913. name: string;
  4914. targetType: string;
  4915. value: string;
  4916. };
  4917. }
  4918. }
  4919. declare module BABYLON {
  4920. /**
  4921. * ActionEvent is the event being sent when an action is triggered.
  4922. */
  4923. class ActionEvent {
  4924. /** The mesh or sprite that triggered the action */
  4925. source: any;
  4926. /** The X mouse cursor position at the time of the event */
  4927. pointerX: number;
  4928. /** The Y mouse cursor position at the time of the event */
  4929. pointerY: number;
  4930. /** The mesh that is currently pointed at (can be null) */
  4931. meshUnderPointer: Nullable<AbstractMesh>;
  4932. /** the original (browser) event that triggered the ActionEvent */
  4933. sourceEvent?: any;
  4934. /** additional data for the event */
  4935. additionalData?: any;
  4936. /**
  4937. * Creates a new ActionEvent
  4938. * @param source The mesh or sprite that triggered the action
  4939. * @param pointerX The X mouse cursor position at the time of the event
  4940. * @param pointerY The Y mouse cursor position at the time of the event
  4941. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  4942. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  4943. * @param additionalData additional data for the event
  4944. */
  4945. constructor(
  4946. /** The mesh or sprite that triggered the action */
  4947. source: any,
  4948. /** The X mouse cursor position at the time of the event */
  4949. pointerX: number,
  4950. /** The Y mouse cursor position at the time of the event */
  4951. pointerY: number,
  4952. /** The mesh that is currently pointed at (can be null) */
  4953. meshUnderPointer: Nullable<AbstractMesh>,
  4954. /** the original (browser) event that triggered the ActionEvent */
  4955. sourceEvent?: any,
  4956. /** additional data for the event */
  4957. additionalData?: any);
  4958. /**
  4959. * Helper function to auto-create an ActionEvent from a source mesh.
  4960. * @param source The source mesh that triggered the event
  4961. * @param evt The original (browser) event
  4962. * @param additionalData additional data for the event
  4963. * @returns the new ActionEvent
  4964. */
  4965. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  4966. /**
  4967. * Helper function to auto-create an ActionEvent from a source sprite
  4968. * @param source The source sprite that triggered the event
  4969. * @param scene Scene associated with the sprite
  4970. * @param evt The original (browser) event
  4971. * @param additionalData additional data for the event
  4972. * @returns the new ActionEvent
  4973. */
  4974. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  4975. /**
  4976. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  4977. * @param scene the scene where the event occurred
  4978. * @param evt The original (browser) event
  4979. * @returns the new ActionEvent
  4980. */
  4981. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  4982. /**
  4983. * Helper function to auto-create an ActionEvent from a primitive
  4984. * @param prim defines the target primitive
  4985. * @param pointerPos defines the pointer position
  4986. * @param evt The original (browser) event
  4987. * @param additionalData additional data for the event
  4988. * @returns the new ActionEvent
  4989. */
  4990. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  4991. }
  4992. /**
  4993. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  4994. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  4995. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  4996. */
  4997. class ActionManager {
  4998. /**
  4999. * Nothing
  5000. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  5001. */
  5002. static readonly NothingTrigger: number;
  5003. /**
  5004. * On pick
  5005. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  5006. */
  5007. static readonly OnPickTrigger: number;
  5008. /**
  5009. * On left pick
  5010. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  5011. */
  5012. static readonly OnLeftPickTrigger: number;
  5013. /**
  5014. * On right pick
  5015. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  5016. */
  5017. static readonly OnRightPickTrigger: number;
  5018. /**
  5019. * On center pick
  5020. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  5021. */
  5022. static readonly OnCenterPickTrigger: number;
  5023. /**
  5024. * On pick down
  5025. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  5026. */
  5027. static readonly OnPickDownTrigger: number;
  5028. /**
  5029. * On double pick
  5030. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  5031. */
  5032. static readonly OnDoublePickTrigger: number;
  5033. /**
  5034. * On pick up
  5035. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  5036. */
  5037. static readonly OnPickUpTrigger: number;
  5038. /**
  5039. * On pick out.
  5040. * This trigger will only be raised if you also declared a OnPickDown
  5041. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  5042. */
  5043. static readonly OnPickOutTrigger: number;
  5044. /**
  5045. * On long press
  5046. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  5047. */
  5048. static readonly OnLongPressTrigger: number;
  5049. /**
  5050. * On pointer over
  5051. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  5052. */
  5053. static readonly OnPointerOverTrigger: number;
  5054. /**
  5055. * On pointer out
  5056. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  5057. */
  5058. static readonly OnPointerOutTrigger: number;
  5059. /**
  5060. * On every frame
  5061. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  5062. */
  5063. static readonly OnEveryFrameTrigger: number;
  5064. /**
  5065. * On intersection enter
  5066. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  5067. */
  5068. static readonly OnIntersectionEnterTrigger: number;
  5069. /**
  5070. * On intersection exit
  5071. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  5072. */
  5073. static readonly OnIntersectionExitTrigger: number;
  5074. /**
  5075. * On key down
  5076. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  5077. */
  5078. static readonly OnKeyDownTrigger: number;
  5079. /**
  5080. * On key up
  5081. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  5082. */
  5083. static readonly OnKeyUpTrigger: number;
  5084. /** Gets the list of active triggers */
  5085. static Triggers: {
  5086. [key: string]: number;
  5087. };
  5088. /** Gets the list of actions */
  5089. actions: Action[];
  5090. /** Gets the cursor to use when hovering items */
  5091. hoverCursor: string;
  5092. private _scene;
  5093. /**
  5094. * Creates a new action manager
  5095. * @param scene defines the hosting scene
  5096. */
  5097. constructor(scene: Scene);
  5098. /**
  5099. * Releases all associated resources
  5100. */
  5101. dispose(): void;
  5102. /**
  5103. * Gets hosting scene
  5104. * @returns the hosting scene
  5105. */
  5106. getScene(): Scene;
  5107. /**
  5108. * Does this action manager handles actions of any of the given triggers
  5109. * @param triggers defines the triggers to be tested
  5110. * @return a boolean indicating whether one (or more) of the triggers is handled
  5111. */
  5112. hasSpecificTriggers(triggers: number[]): boolean;
  5113. /**
  5114. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  5115. * speed.
  5116. * @param triggerA defines the trigger to be tested
  5117. * @param triggerB defines the trigger to be tested
  5118. * @return a boolean indicating whether one (or more) of the triggers is handled
  5119. */
  5120. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  5121. /**
  5122. * Does this action manager handles actions of a given trigger
  5123. * @param trigger defines the trigger to be tested
  5124. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  5125. * @return whether the trigger is handled
  5126. */
  5127. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  5128. /**
  5129. * Does this action manager has pointer triggers
  5130. */
  5131. readonly hasPointerTriggers: boolean;
  5132. /**
  5133. * Does this action manager has pick triggers
  5134. */
  5135. readonly hasPickTriggers: boolean;
  5136. /**
  5137. * Does exist one action manager with at least one trigger
  5138. **/
  5139. static readonly HasTriggers: boolean;
  5140. /**
  5141. * Does exist one action manager with at least one pick trigger
  5142. **/
  5143. static readonly HasPickTriggers: boolean;
  5144. /**
  5145. * Does exist one action manager that handles actions of a given trigger
  5146. * @param trigger defines the trigger to be tested
  5147. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  5148. **/
  5149. static HasSpecificTrigger(trigger: number): boolean;
  5150. /**
  5151. * Registers an action to this action manager
  5152. * @param action defines the action to be registered
  5153. * @return the action amended (prepared) after registration
  5154. */
  5155. registerAction(action: Action): Nullable<Action>;
  5156. /**
  5157. * Unregisters an action to this action manager
  5158. * @param action defines the action to be unregistered
  5159. * @return a boolean indicating whether the action has been unregistered
  5160. */
  5161. unregisterAction(action: Action): Boolean;
  5162. /**
  5163. * Process a specific trigger
  5164. * @param trigger defines the trigger to process
  5165. * @param evt defines the event details to be processed
  5166. */
  5167. processTrigger(trigger: number, evt?: ActionEvent): void;
  5168. /** @hidden */
  5169. _getEffectiveTarget(target: any, propertyPath: string): any;
  5170. /** @hidden */
  5171. _getProperty(propertyPath: string): string;
  5172. /**
  5173. * Serialize this manager to a JSON object
  5174. * @param name defines the property name to store this manager
  5175. * @returns a JSON representation of this manager
  5176. */
  5177. serialize(name: string): any;
  5178. /**
  5179. * Creates a new ActionManager from a JSON data
  5180. * @param parsedActions defines the JSON data to read from
  5181. * @param object defines the hosting mesh
  5182. * @param scene defines the hosting scene
  5183. */
  5184. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  5185. /**
  5186. * Get a trigger name by index
  5187. * @param trigger defines the trigger index
  5188. * @returns a trigger name
  5189. */
  5190. static GetTriggerName(trigger: number): string;
  5191. }
  5192. }
  5193. declare module BABYLON {
  5194. /**
  5195. * A Condition applied to an Action
  5196. */
  5197. class Condition {
  5198. /**
  5199. * Internal only - manager for action
  5200. * @hidden
  5201. */
  5202. _actionManager: ActionManager;
  5203. /**
  5204. * Internal only
  5205. * @hidden
  5206. */
  5207. _evaluationId: number;
  5208. /**
  5209. * Internal only
  5210. * @hidden
  5211. */
  5212. _currentResult: boolean;
  5213. /**
  5214. * Creates a new Condition
  5215. * @param actionManager the manager of the action the condition is applied to
  5216. */
  5217. constructor(actionManager: ActionManager);
  5218. /**
  5219. * Check if the current condition is valid
  5220. * @returns a boolean
  5221. */
  5222. isValid(): boolean;
  5223. /**
  5224. * Internal only
  5225. * @hidden
  5226. */
  5227. _getProperty(propertyPath: string): string;
  5228. /**
  5229. * Internal only
  5230. * @hidden
  5231. */
  5232. _getEffectiveTarget(target: any, propertyPath: string): any;
  5233. /**
  5234. * Serialize placeholder for child classes
  5235. * @returns the serialized object
  5236. */
  5237. serialize(): any;
  5238. /**
  5239. * Internal only
  5240. * @hidden
  5241. */
  5242. protected _serialize(serializedCondition: any): any;
  5243. }
  5244. /**
  5245. * Defines specific conditional operators as extensions of Condition
  5246. */
  5247. class ValueCondition extends Condition {
  5248. /** path to specify the property of the target the conditional operator uses */
  5249. propertyPath: string;
  5250. /** the value compared by the conditional operator against the current value of the property */
  5251. value: any;
  5252. /** the conditional operator, default ValueCondition.IsEqual */
  5253. operator: number;
  5254. /**
  5255. * Internal only
  5256. * @hidden
  5257. */
  5258. private static _IsEqual;
  5259. /**
  5260. * Internal only
  5261. * @hidden
  5262. */
  5263. private static _IsDifferent;
  5264. /**
  5265. * Internal only
  5266. * @hidden
  5267. */
  5268. private static _IsGreater;
  5269. /**
  5270. * Internal only
  5271. * @hidden
  5272. */
  5273. private static _IsLesser;
  5274. /**
  5275. * returns the number for IsEqual
  5276. */
  5277. static readonly IsEqual: number;
  5278. /**
  5279. * Returns the number for IsDifferent
  5280. */
  5281. static readonly IsDifferent: number;
  5282. /**
  5283. * Returns the number for IsGreater
  5284. */
  5285. static readonly IsGreater: number;
  5286. /**
  5287. * Returns the number for IsLesser
  5288. */
  5289. static readonly IsLesser: number;
  5290. /**
  5291. * Internal only The action manager for the condition
  5292. * @hidden
  5293. */
  5294. _actionManager: ActionManager;
  5295. /**
  5296. * Internal only
  5297. * @hidden
  5298. */
  5299. private _target;
  5300. /**
  5301. * Internal only
  5302. * @hidden
  5303. */
  5304. private _effectiveTarget;
  5305. /**
  5306. * Internal only
  5307. * @hidden
  5308. */
  5309. private _property;
  5310. /**
  5311. * Creates a new ValueCondition
  5312. * @param actionManager manager for the action the condition applies to
  5313. * @param target for the action
  5314. * @param propertyPath path to specify the property of the target the conditional operator uses
  5315. * @param value the value compared by the conditional operator against the current value of the property
  5316. * @param operator the conditional operator, default ValueCondition.IsEqual
  5317. */
  5318. constructor(actionManager: ActionManager, target: any,
  5319. /** path to specify the property of the target the conditional operator uses */
  5320. propertyPath: string,
  5321. /** the value compared by the conditional operator against the current value of the property */
  5322. value: any,
  5323. /** the conditional operator, default ValueCondition.IsEqual */
  5324. operator?: number);
  5325. /**
  5326. * Compares the given value with the property value for the specified conditional operator
  5327. * @returns the result of the comparison
  5328. */
  5329. isValid(): boolean;
  5330. /**
  5331. * Serialize the ValueCondition into a JSON compatible object
  5332. * @returns serialization object
  5333. */
  5334. serialize(): any;
  5335. /**
  5336. * Gets the name of the conditional operator for the ValueCondition
  5337. * @param operator the conditional operator
  5338. * @returns the name
  5339. */
  5340. static GetOperatorName(operator: number): string;
  5341. }
  5342. /**
  5343. * Defines a predicate condition as an extension of Condition
  5344. */
  5345. class PredicateCondition extends Condition {
  5346. /** defines the predicate function used to validate the condition */
  5347. predicate: () => boolean;
  5348. /**
  5349. * Internal only - manager for action
  5350. * @hidden
  5351. */
  5352. _actionManager: ActionManager;
  5353. /**
  5354. * Creates a new PredicateCondition
  5355. * @param actionManager manager for the action the condition applies to
  5356. * @param predicate defines the predicate function used to validate the condition
  5357. */
  5358. constructor(actionManager: ActionManager,
  5359. /** defines the predicate function used to validate the condition */
  5360. predicate: () => boolean);
  5361. /**
  5362. * @returns the validity of the predicate condition
  5363. */
  5364. isValid(): boolean;
  5365. }
  5366. /**
  5367. * Defines a state condition as an extension of Condition
  5368. */
  5369. class StateCondition extends Condition {
  5370. /** Value to compare with target state */
  5371. value: string;
  5372. /**
  5373. * Internal only - manager for action
  5374. * @hidden
  5375. */
  5376. _actionManager: ActionManager;
  5377. /**
  5378. * Internal only
  5379. * @hidden
  5380. */
  5381. private _target;
  5382. /**
  5383. * Creates a new StateCondition
  5384. * @param actionManager manager for the action the condition applies to
  5385. * @param target of the condition
  5386. * @param value to compare with target state
  5387. */
  5388. constructor(actionManager: ActionManager, target: any,
  5389. /** Value to compare with target state */
  5390. value: string);
  5391. /**
  5392. * Gets a boolean indicating if the current condition is met
  5393. * @returns the validity of the state
  5394. */
  5395. isValid(): boolean;
  5396. /**
  5397. * Serialize the StateCondition into a JSON compatible object
  5398. * @returns serialization object
  5399. */
  5400. serialize(): any;
  5401. }
  5402. }
  5403. declare module BABYLON {
  5404. /**
  5405. * This defines an action responsible to toggle a boolean once triggered.
  5406. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  5407. */
  5408. class SwitchBooleanAction extends Action {
  5409. /**
  5410. * The path to the boolean property in the target object
  5411. */
  5412. propertyPath: string;
  5413. private _target;
  5414. private _effectiveTarget;
  5415. private _property;
  5416. /**
  5417. * Instantiate the action
  5418. * @param triggerOptions defines the trigger options
  5419. * @param target defines the object containing the boolean
  5420. * @param propertyPath defines the path to the boolean property in the target object
  5421. * @param condition defines the trigger related conditions
  5422. */
  5423. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  5424. /** @hidden */
  5425. _prepare(): void;
  5426. /**
  5427. * Execute the action toggle the boolean value.
  5428. */
  5429. execute(): void;
  5430. /**
  5431. * Serializes the actions and its related information.
  5432. * @param parent defines the object to serialize in
  5433. * @returns the serialized object
  5434. */
  5435. serialize(parent: any): any;
  5436. }
  5437. /**
  5438. * This defines an action responsible to set a the state field of the target
  5439. * to a desired value once triggered.
  5440. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  5441. */
  5442. class SetStateAction extends Action {
  5443. /**
  5444. * The value to store in the state field.
  5445. */
  5446. value: string;
  5447. private _target;
  5448. /**
  5449. * Instantiate the action
  5450. * @param triggerOptions defines the trigger options
  5451. * @param target defines the object containing the state property
  5452. * @param value defines the value to store in the state field
  5453. * @param condition defines the trigger related conditions
  5454. */
  5455. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  5456. /**
  5457. * Execute the action and store the value on the target state property.
  5458. */
  5459. execute(): void;
  5460. /**
  5461. * Serializes the actions and its related information.
  5462. * @param parent defines the object to serialize in
  5463. * @returns the serialized object
  5464. */
  5465. serialize(parent: any): any;
  5466. }
  5467. /**
  5468. * This defines an action responsible to set a property of the target
  5469. * to a desired value once triggered.
  5470. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  5471. */
  5472. class SetValueAction extends Action {
  5473. /**
  5474. * The path of the property to set in the target.
  5475. */
  5476. propertyPath: string;
  5477. /**
  5478. * The value to set in the property
  5479. */
  5480. value: any;
  5481. private _target;
  5482. private _effectiveTarget;
  5483. private _property;
  5484. /**
  5485. * Instantiate the action
  5486. * @param triggerOptions defines the trigger options
  5487. * @param target defines the object containing the property
  5488. * @param propertyPath defines the path of the property to set in the target
  5489. * @param value defines the value to set in the property
  5490. * @param condition defines the trigger related conditions
  5491. */
  5492. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  5493. /** @hidden */
  5494. _prepare(): void;
  5495. /**
  5496. * Execute the action and set the targetted property to the desired value.
  5497. */
  5498. execute(): void;
  5499. /**
  5500. * Serializes the actions and its related information.
  5501. * @param parent defines the object to serialize in
  5502. * @returns the serialized object
  5503. */
  5504. serialize(parent: any): any;
  5505. }
  5506. /**
  5507. * This defines an action responsible to increment the target value
  5508. * to a desired value once triggered.
  5509. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  5510. */
  5511. class IncrementValueAction extends Action {
  5512. /**
  5513. * The path of the property to increment in the target.
  5514. */
  5515. propertyPath: string;
  5516. /**
  5517. * The value we should increment the property by.
  5518. */
  5519. value: any;
  5520. private _target;
  5521. private _effectiveTarget;
  5522. private _property;
  5523. /**
  5524. * Instantiate the action
  5525. * @param triggerOptions defines the trigger options
  5526. * @param target defines the object containing the property
  5527. * @param propertyPath defines the path of the property to increment in the target
  5528. * @param value defines the value value we should increment the property by
  5529. * @param condition defines the trigger related conditions
  5530. */
  5531. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  5532. /** @hidden */
  5533. _prepare(): void;
  5534. /**
  5535. * Execute the action and increment the target of the value amount.
  5536. */
  5537. execute(): void;
  5538. /**
  5539. * Serializes the actions and its related information.
  5540. * @param parent defines the object to serialize in
  5541. * @returns the serialized object
  5542. */
  5543. serialize(parent: any): any;
  5544. }
  5545. /**
  5546. * This defines an action responsible to start an animation once triggered.
  5547. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  5548. */
  5549. class PlayAnimationAction extends Action {
  5550. /**
  5551. * Where the animation should start (animation frame)
  5552. */
  5553. from: number;
  5554. /**
  5555. * Where the animation should stop (animation frame)
  5556. */
  5557. to: number;
  5558. /**
  5559. * Define if the animation should loop or stop after the first play.
  5560. */
  5561. loop?: boolean;
  5562. private _target;
  5563. /**
  5564. * Instantiate the action
  5565. * @param triggerOptions defines the trigger options
  5566. * @param target defines the target animation or animation name
  5567. * @param from defines from where the animation should start (animation frame)
  5568. * @param end defines where the animation should stop (animation frame)
  5569. * @param loop defines if the animation should loop or stop after the first play
  5570. * @param condition defines the trigger related conditions
  5571. */
  5572. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  5573. /** @hidden */
  5574. _prepare(): void;
  5575. /**
  5576. * Execute the action and play the animation.
  5577. */
  5578. execute(): void;
  5579. /**
  5580. * Serializes the actions and its related information.
  5581. * @param parent defines the object to serialize in
  5582. * @returns the serialized object
  5583. */
  5584. serialize(parent: any): any;
  5585. }
  5586. /**
  5587. * This defines an action responsible to stop an animation once triggered.
  5588. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  5589. */
  5590. class StopAnimationAction extends Action {
  5591. private _target;
  5592. /**
  5593. * Instantiate the action
  5594. * @param triggerOptions defines the trigger options
  5595. * @param target defines the target animation or animation name
  5596. * @param condition defines the trigger related conditions
  5597. */
  5598. constructor(triggerOptions: any, target: any, condition?: Condition);
  5599. /** @hidden */
  5600. _prepare(): void;
  5601. /**
  5602. * Execute the action and stop the animation.
  5603. */
  5604. execute(): void;
  5605. /**
  5606. * Serializes the actions and its related information.
  5607. * @param parent defines the object to serialize in
  5608. * @returns the serialized object
  5609. */
  5610. serialize(parent: any): any;
  5611. }
  5612. /**
  5613. * This defines an action responsible that does nothing once triggered.
  5614. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  5615. */
  5616. class DoNothingAction extends Action {
  5617. /**
  5618. * Instantiate the action
  5619. * @param triggerOptions defines the trigger options
  5620. * @param condition defines the trigger related conditions
  5621. */
  5622. constructor(triggerOptions?: any, condition?: Condition);
  5623. /**
  5624. * Execute the action and do nothing.
  5625. */
  5626. execute(): void;
  5627. /**
  5628. * Serializes the actions and its related information.
  5629. * @param parent defines the object to serialize in
  5630. * @returns the serialized object
  5631. */
  5632. serialize(parent: any): any;
  5633. }
  5634. /**
  5635. * This defines an action responsible to trigger several actions once triggered.
  5636. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  5637. */
  5638. class CombineAction extends Action {
  5639. /**
  5640. * The list of aggregated animations to run.
  5641. */
  5642. children: Action[];
  5643. /**
  5644. * Instantiate the action
  5645. * @param triggerOptions defines the trigger options
  5646. * @param children defines the list of aggregated animations to run
  5647. * @param condition defines the trigger related conditions
  5648. */
  5649. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  5650. /** @hidden */
  5651. _prepare(): void;
  5652. /**
  5653. * Execute the action and executes all the aggregated actions.
  5654. */
  5655. execute(evt: ActionEvent): void;
  5656. /**
  5657. * Serializes the actions and its related information.
  5658. * @param parent defines the object to serialize in
  5659. * @returns the serialized object
  5660. */
  5661. serialize(parent: any): any;
  5662. }
  5663. /**
  5664. * This defines an action responsible to run code (external event) once triggered.
  5665. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  5666. */
  5667. class ExecuteCodeAction extends Action {
  5668. /**
  5669. * The callback function to run.
  5670. */
  5671. func: (evt: ActionEvent) => void;
  5672. /**
  5673. * Instantiate the action
  5674. * @param triggerOptions defines the trigger options
  5675. * @param func defines the callback function to run
  5676. * @param condition defines the trigger related conditions
  5677. */
  5678. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  5679. /**
  5680. * Execute the action and run the attached code.
  5681. */
  5682. execute(evt: ActionEvent): void;
  5683. }
  5684. /**
  5685. * This defines an action responsible to set the parent property of the target once triggered.
  5686. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  5687. */
  5688. class SetParentAction extends Action {
  5689. private _parent;
  5690. private _target;
  5691. /**
  5692. * Instantiate the action
  5693. * @param triggerOptions defines the trigger options
  5694. * @param target defines the target containing the parent property
  5695. * @param parent defines from where the animation should start (animation frame)
  5696. * @param condition defines the trigger related conditions
  5697. */
  5698. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  5699. /** @hidden */
  5700. _prepare(): void;
  5701. /**
  5702. * Execute the action and set the parent property.
  5703. */
  5704. execute(): void;
  5705. /**
  5706. * Serializes the actions and its related information.
  5707. * @param parent defines the object to serialize in
  5708. * @returns the serialized object
  5709. */
  5710. serialize(parent: any): any;
  5711. }
  5712. }
  5713. declare module BABYLON {
  5714. /**
  5715. * This defines an action helpful to play a defined sound on a triggered action.
  5716. */
  5717. class PlaySoundAction extends Action {
  5718. private _sound;
  5719. /**
  5720. * Instantiate the action
  5721. * @param triggerOptions defines the trigger options
  5722. * @param sound defines the sound to play
  5723. * @param condition defines the trigger related conditions
  5724. */
  5725. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  5726. /** @hidden */
  5727. _prepare(): void;
  5728. /**
  5729. * Execute the action and play the sound.
  5730. */
  5731. execute(): void;
  5732. /**
  5733. * Serializes the actions and its related information.
  5734. * @param parent defines the object to serialize in
  5735. * @returns the serialized object
  5736. */
  5737. serialize(parent: any): any;
  5738. }
  5739. /**
  5740. * This defines an action helpful to stop a defined sound on a triggered action.
  5741. */
  5742. class StopSoundAction extends Action {
  5743. private _sound;
  5744. /**
  5745. * Instantiate the action
  5746. * @param triggerOptions defines the trigger options
  5747. * @param sound defines the sound to stop
  5748. * @param condition defines the trigger related conditions
  5749. */
  5750. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  5751. /** @hidden */
  5752. _prepare(): void;
  5753. /**
  5754. * Execute the action and stop the sound.
  5755. */
  5756. execute(): void;
  5757. /**
  5758. * Serializes the actions and its related information.
  5759. * @param parent defines the object to serialize in
  5760. * @returns the serialized object
  5761. */
  5762. serialize(parent: any): any;
  5763. }
  5764. }
  5765. declare module BABYLON {
  5766. /**
  5767. * This defines an action responsible to change the value of a property
  5768. * by interpolating between its current value and the newly set one once triggered.
  5769. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  5770. */
  5771. class InterpolateValueAction extends Action {
  5772. /**
  5773. * Defines the path of the property where the value should be interpolated
  5774. */
  5775. propertyPath: string;
  5776. /**
  5777. * Defines the target value at the end of the interpolation.
  5778. */
  5779. value: any;
  5780. /**
  5781. * Defines the time it will take for the property to interpolate to the value.
  5782. */
  5783. duration: number;
  5784. /**
  5785. * Defines if the other scene animations should be stopped when the action has been triggered
  5786. */
  5787. stopOtherAnimations?: boolean;
  5788. /**
  5789. * Defines a callback raised once the interpolation animation has been done.
  5790. */
  5791. onInterpolationDone?: () => void;
  5792. /**
  5793. * Observable triggered once the interpolation animation has been done.
  5794. */
  5795. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  5796. private _target;
  5797. private _effectiveTarget;
  5798. private _property;
  5799. /**
  5800. * Instantiate the action
  5801. * @param triggerOptions defines the trigger options
  5802. * @param target defines the object containing the value to interpolate
  5803. * @param propertyPath defines the path to the property in the target object
  5804. * @param value defines the target value at the end of the interpolation
  5805. * @param duration deines the time it will take for the property to interpolate to the value.
  5806. * @param condition defines the trigger related conditions
  5807. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  5808. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  5809. */
  5810. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  5811. /** @hidden */
  5812. _prepare(): void;
  5813. /**
  5814. * Execute the action starts the value interpolation.
  5815. */
  5816. execute(): void;
  5817. /**
  5818. * Serializes the actions and its related information.
  5819. * @param parent defines the object to serialize in
  5820. * @returns the serialized object
  5821. */
  5822. serialize(parent: any): any;
  5823. }
  5824. }
  5825. declare module BABYLON {
  5826. /**
  5827. * Interface used to define a behavior
  5828. */
  5829. interface Behavior<T> {
  5830. /** gets or sets behavior's name */
  5831. name: string;
  5832. /**
  5833. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5834. */
  5835. init(): void;
  5836. /**
  5837. * Called when the behavior is attached to a target
  5838. * @param target defines the target where the behavior is attached to
  5839. */
  5840. attach(target: T): void;
  5841. /**
  5842. * Called when the behavior is detached from its target
  5843. */
  5844. detach(): void;
  5845. }
  5846. /**
  5847. * Interface implemented by classes supporting behaviors
  5848. */
  5849. interface IBehaviorAware<T> {
  5850. /**
  5851. * Attach a behavior
  5852. * @param behavior defines the behavior to attach
  5853. * @returns the current host
  5854. */
  5855. addBehavior(behavior: Behavior<T>): T;
  5856. /**
  5857. * Remove a behavior from the current object
  5858. * @param behavior defines the behavior to detach
  5859. * @returns the current host
  5860. */
  5861. removeBehavior(behavior: Behavior<T>): T;
  5862. /**
  5863. * Gets a behavior using its name to search
  5864. * @param name defines the name to search
  5865. * @returns the behavior or null if not found
  5866. */
  5867. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  5868. }
  5869. }
  5870. declare module BABYLON {
  5871. /**
  5872. * Class used to store bone information
  5873. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  5874. */
  5875. class Bone extends Node {
  5876. /**
  5877. * defines the bone name
  5878. */
  5879. name: string;
  5880. private static _tmpVecs;
  5881. private static _tmpQuat;
  5882. private static _tmpMats;
  5883. /**
  5884. * Gets the list of child bones
  5885. */
  5886. children: Bone[];
  5887. /** Gets the animations associated with this bone */
  5888. animations: Animation[];
  5889. /**
  5890. * Gets or sets bone length
  5891. */
  5892. length: number;
  5893. /**
  5894. * @hidden Internal only
  5895. * Set this value to map this bone to a different index in the transform matrices
  5896. * Set this value to -1 to exclude the bone from the transform matrices
  5897. */
  5898. _index: Nullable<number>;
  5899. private _skeleton;
  5900. private _localMatrix;
  5901. private _restPose;
  5902. private _baseMatrix;
  5903. private _absoluteTransform;
  5904. private _invertedAbsoluteTransform;
  5905. private _parent;
  5906. private _scalingDeterminant;
  5907. private _worldTransform;
  5908. private _localScaling;
  5909. private _localRotation;
  5910. private _localPosition;
  5911. private _needToDecompose;
  5912. private _needToCompose;
  5913. /** @hidden */
  5914. /** @hidden */
  5915. _matrix: Matrix;
  5916. /**
  5917. * Create a new bone
  5918. * @param name defines the bone name
  5919. * @param skeleton defines the parent skeleton
  5920. * @param parentBone defines the parent (can be null if the bone is the root)
  5921. * @param localMatrix defines the local matrix
  5922. * @param restPose defines the rest pose matrix
  5923. * @param baseMatrix defines the base matrix
  5924. * @param index defines index of the bone in the hiearchy
  5925. */
  5926. constructor(
  5927. /**
  5928. * defines the bone name
  5929. */
  5930. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  5931. /**
  5932. * Gets the parent skeleton
  5933. * @returns a skeleton
  5934. */
  5935. getSkeleton(): Skeleton;
  5936. /**
  5937. * Gets parent bone
  5938. * @returns a bone or null if the bone is the root of the bone hierarchy
  5939. */
  5940. getParent(): Nullable<Bone>;
  5941. /**
  5942. * Sets the parent bone
  5943. * @param parent defines the parent (can be null if the bone is the root)
  5944. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  5945. */
  5946. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  5947. /**
  5948. * Gets the local matrix
  5949. * @returns a matrix
  5950. */
  5951. getLocalMatrix(): Matrix;
  5952. /**
  5953. * Gets the base matrix (initial matrix which remains unchanged)
  5954. * @returns a matrix
  5955. */
  5956. getBaseMatrix(): Matrix;
  5957. /**
  5958. * Gets the rest pose matrix
  5959. * @returns a matrix
  5960. */
  5961. getRestPose(): Matrix;
  5962. /**
  5963. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  5964. */
  5965. getWorldMatrix(): Matrix;
  5966. /**
  5967. * Sets the local matrix to rest pose matrix
  5968. */
  5969. returnToRest(): void;
  5970. /**
  5971. * Gets the inverse of the absolute transform matrix.
  5972. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  5973. * @returns a matrix
  5974. */
  5975. getInvertedAbsoluteTransform(): Matrix;
  5976. /**
  5977. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  5978. * @returns a matrix
  5979. */
  5980. getAbsoluteTransform(): Matrix;
  5981. /** Gets or sets current position (in local space) */
  5982. position: Vector3;
  5983. /** Gets or sets current rotation (in local space) */
  5984. rotation: Vector3;
  5985. /** Gets or sets current rotation quaternion (in local space) */
  5986. rotationQuaternion: Quaternion;
  5987. /** Gets or sets current scaling (in local space) */
  5988. scaling: Vector3;
  5989. /**
  5990. * Gets the animation properties override
  5991. */
  5992. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  5993. private _decompose;
  5994. private _compose;
  5995. /**
  5996. * Update the base and local matrices
  5997. * @param matrix defines the new base or local matrix
  5998. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  5999. * @param updateLocalMatrix defines if the local matrix should be updated
  6000. */
  6001. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  6002. /** @hidden */
  6003. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  6004. /**
  6005. * Flag the bone as dirty (Forcing it to update everything)
  6006. */
  6007. markAsDirty(): void;
  6008. private _markAsDirtyAndCompose;
  6009. private _markAsDirtyAndDecompose;
  6010. /**
  6011. * Copy an animation range from another bone
  6012. * @param source defines the source bone
  6013. * @param rangeName defines the range name to copy
  6014. * @param frameOffset defines the frame offset
  6015. * @param rescaleAsRequired defines if rescaling must be applied if required
  6016. * @param skelDimensionsRatio defines the scaling ratio
  6017. * @returns true if operation was successful
  6018. */
  6019. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired?: boolean, skelDimensionsRatio?: Nullable<Vector3>): boolean;
  6020. /**
  6021. * Translate the bone in local or world space
  6022. * @param vec The amount to translate the bone
  6023. * @param space The space that the translation is in
  6024. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6025. */
  6026. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  6027. /**
  6028. * Set the postion of the bone in local or world space
  6029. * @param position The position to set the bone
  6030. * @param space The space that the position is in
  6031. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6032. */
  6033. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  6034. /**
  6035. * Set the absolute position of the bone (world space)
  6036. * @param position The position to set the bone
  6037. * @param mesh The mesh that this bone is attached to
  6038. */
  6039. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  6040. /**
  6041. * Scale the bone on the x, y and z axes (in local space)
  6042. * @param x The amount to scale the bone on the x axis
  6043. * @param y The amount to scale the bone on the y axis
  6044. * @param z The amount to scale the bone on the z axis
  6045. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  6046. */
  6047. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  6048. /**
  6049. * Set the bone scaling in local space
  6050. * @param scale defines the scaling vector
  6051. */
  6052. setScale(scale: Vector3): void;
  6053. /**
  6054. * Gets the current scaling in local space
  6055. * @returns the current scaling vector
  6056. */
  6057. getScale(): Vector3;
  6058. /**
  6059. * Gets the current scaling in local space and stores it in a target vector
  6060. * @param result defines the target vector
  6061. */
  6062. getScaleToRef(result: Vector3): void;
  6063. /**
  6064. * Set the yaw, pitch, and roll of the bone in local or world space
  6065. * @param yaw The rotation of the bone on the y axis
  6066. * @param pitch The rotation of the bone on the x axis
  6067. * @param roll The rotation of the bone on the z axis
  6068. * @param space The space that the axes of rotation are in
  6069. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6070. */
  6071. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  6072. /**
  6073. * Add a rotation to the bone on an axis in local or world space
  6074. * @param axis The axis to rotate the bone on
  6075. * @param amount The amount to rotate the bone
  6076. * @param space The space that the axis is in
  6077. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6078. */
  6079. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  6080. /**
  6081. * Set the rotation of the bone to a particular axis angle in local or world space
  6082. * @param axis The axis to rotate the bone on
  6083. * @param angle The angle that the bone should be rotated to
  6084. * @param space The space that the axis is in
  6085. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6086. */
  6087. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  6088. /**
  6089. * Set the euler rotation of the bone in local of world space
  6090. * @param rotation The euler rotation that the bone should be set to
  6091. * @param space The space that the rotation is in
  6092. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6093. */
  6094. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  6095. /**
  6096. * Set the quaternion rotation of the bone in local of world space
  6097. * @param quat The quaternion rotation that the bone should be set to
  6098. * @param space The space that the rotation is in
  6099. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6100. */
  6101. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  6102. /**
  6103. * Set the rotation matrix of the bone in local of world space
  6104. * @param rotMat The rotation matrix that the bone should be set to
  6105. * @param space The space that the rotation is in
  6106. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6107. */
  6108. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  6109. private _rotateWithMatrix;
  6110. private _getNegativeRotationToRef;
  6111. /**
  6112. * Get the position of the bone in local or world space
  6113. * @param space The space that the returned position is in
  6114. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6115. * @returns The position of the bone
  6116. */
  6117. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  6118. /**
  6119. * Copy the position of the bone to a vector3 in local or world space
  6120. * @param space The space that the returned position is in
  6121. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6122. * @param result The vector3 to copy the position to
  6123. */
  6124. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  6125. /**
  6126. * Get the absolute position of the bone (world space)
  6127. * @param mesh The mesh that this bone is attached to
  6128. * @returns The absolute position of the bone
  6129. */
  6130. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  6131. /**
  6132. * Copy the absolute position of the bone (world space) to the result param
  6133. * @param mesh The mesh that this bone is attached to
  6134. * @param result The vector3 to copy the absolute position to
  6135. */
  6136. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  6137. /**
  6138. * Compute the absolute transforms of this bone and its children
  6139. */
  6140. computeAbsoluteTransforms(): void;
  6141. /**
  6142. * Get the world direction from an axis that is in the local space of the bone
  6143. * @param localAxis The local direction that is used to compute the world direction
  6144. * @param mesh The mesh that this bone is attached to
  6145. * @returns The world direction
  6146. */
  6147. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  6148. /**
  6149. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  6150. * @param localAxis The local direction that is used to compute the world direction
  6151. * @param mesh The mesh that this bone is attached to
  6152. * @param result The vector3 that the world direction will be copied to
  6153. */
  6154. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6155. /**
  6156. * Get the euler rotation of the bone in local or world space
  6157. * @param space The space that the rotation should be in
  6158. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6159. * @returns The euler rotation
  6160. */
  6161. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  6162. /**
  6163. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  6164. * @param space The space that the rotation should be in
  6165. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6166. * @param result The vector3 that the rotation should be copied to
  6167. */
  6168. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6169. /**
  6170. * Get the quaternion rotation of the bone in either local or world space
  6171. * @param space The space that the rotation should be in
  6172. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6173. * @returns The quaternion rotation
  6174. */
  6175. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  6176. /**
  6177. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  6178. * @param space The space that the rotation should be in
  6179. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6180. * @param result The quaternion that the rotation should be copied to
  6181. */
  6182. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  6183. /**
  6184. * Get the rotation matrix of the bone in local or world space
  6185. * @param space The space that the rotation should be in
  6186. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6187. * @returns The rotation matrix
  6188. */
  6189. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  6190. /**
  6191. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  6192. * @param space The space that the rotation should be in
  6193. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6194. * @param result The quaternion that the rotation should be copied to
  6195. */
  6196. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  6197. /**
  6198. * Get the world position of a point that is in the local space of the bone
  6199. * @param position The local position
  6200. * @param mesh The mesh that this bone is attached to
  6201. * @returns The world position
  6202. */
  6203. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  6204. /**
  6205. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  6206. * @param position The local position
  6207. * @param mesh The mesh that this bone is attached to
  6208. * @param result The vector3 that the world position should be copied to
  6209. */
  6210. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6211. /**
  6212. * Get the local position of a point that is in world space
  6213. * @param position The world position
  6214. * @param mesh The mesh that this bone is attached to
  6215. * @returns The local position
  6216. */
  6217. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  6218. /**
  6219. * Get the local position of a point that is in world space and copy it to the result param
  6220. * @param position The world position
  6221. * @param mesh The mesh that this bone is attached to
  6222. * @param result The vector3 that the local position should be copied to
  6223. */
  6224. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6225. }
  6226. }
  6227. declare module BABYLON {
  6228. /**
  6229. * Class used to apply inverse kinematics to bones
  6230. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  6231. */
  6232. class BoneIKController {
  6233. private static _tmpVecs;
  6234. private static _tmpQuat;
  6235. private static _tmpMats;
  6236. /**
  6237. * Gets or sets the target mesh
  6238. */
  6239. targetMesh: AbstractMesh;
  6240. /** Gets or sets the mesh used as pole */
  6241. poleTargetMesh: AbstractMesh;
  6242. /**
  6243. * Gets or sets the bone used as pole
  6244. */
  6245. poleTargetBone: Nullable<Bone>;
  6246. /**
  6247. * Gets or sets the target position
  6248. */
  6249. targetPosition: Vector3;
  6250. /**
  6251. * Gets or sets the pole target position
  6252. */
  6253. poleTargetPosition: Vector3;
  6254. /**
  6255. * Gets or sets the pole target local offset
  6256. */
  6257. poleTargetLocalOffset: Vector3;
  6258. /**
  6259. * Gets or sets the pole angle
  6260. */
  6261. poleAngle: number;
  6262. /**
  6263. * Gets or sets the mesh associated with the controller
  6264. */
  6265. mesh: AbstractMesh;
  6266. /**
  6267. * 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)
  6268. */
  6269. slerpAmount: number;
  6270. private _bone1Quat;
  6271. private _bone1Mat;
  6272. private _bone2Ang;
  6273. private _bone1;
  6274. private _bone2;
  6275. private _bone1Length;
  6276. private _bone2Length;
  6277. private _maxAngle;
  6278. private _maxReach;
  6279. private _rightHandedSystem;
  6280. private _bendAxis;
  6281. private _slerping;
  6282. private _adjustRoll;
  6283. /**
  6284. * Gets or sets maximum allowed angle
  6285. */
  6286. maxAngle: number;
  6287. /**
  6288. * Creates a new BoneIKController
  6289. * @param mesh defines the mesh to control
  6290. * @param bone defines the bone to control
  6291. * @param options defines options to set up the controller
  6292. */
  6293. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  6294. targetMesh?: AbstractMesh;
  6295. poleTargetMesh?: AbstractMesh;
  6296. poleTargetBone?: Bone;
  6297. poleTargetLocalOffset?: Vector3;
  6298. poleAngle?: number;
  6299. bendAxis?: Vector3;
  6300. maxAngle?: number;
  6301. slerpAmount?: number;
  6302. });
  6303. private _setMaxAngle;
  6304. /**
  6305. * Force the controller to update the bones
  6306. */
  6307. update(): void;
  6308. }
  6309. }
  6310. declare module BABYLON {
  6311. /**
  6312. * Class used to make a bone look toward a point in space
  6313. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  6314. */
  6315. class BoneLookController {
  6316. private static _tmpVecs;
  6317. private static _tmpQuat;
  6318. private static _tmpMats;
  6319. /**
  6320. * The target Vector3 that the bone will look at
  6321. */
  6322. target: Vector3;
  6323. /**
  6324. * The mesh that the bone is attached to
  6325. */
  6326. mesh: AbstractMesh;
  6327. /**
  6328. * The bone that will be looking to the target
  6329. */
  6330. bone: Bone;
  6331. /**
  6332. * The up axis of the coordinate system that is used when the bone is rotated
  6333. */
  6334. upAxis: Vector3;
  6335. /**
  6336. * The space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD
  6337. */
  6338. upAxisSpace: Space;
  6339. /**
  6340. * Used to make an adjustment to the yaw of the bone
  6341. */
  6342. adjustYaw: number;
  6343. /**
  6344. * Used to make an adjustment to the pitch of the bone
  6345. */
  6346. adjustPitch: number;
  6347. /**
  6348. * Used to make an adjustment to the roll of the bone
  6349. */
  6350. adjustRoll: number;
  6351. /**
  6352. * 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)
  6353. */
  6354. slerpAmount: number;
  6355. private _minYaw;
  6356. private _maxYaw;
  6357. private _minPitch;
  6358. private _maxPitch;
  6359. private _minYawSin;
  6360. private _minYawCos;
  6361. private _maxYawSin;
  6362. private _maxYawCos;
  6363. private _midYawConstraint;
  6364. private _minPitchTan;
  6365. private _maxPitchTan;
  6366. private _boneQuat;
  6367. private _slerping;
  6368. private _transformYawPitch;
  6369. private _transformYawPitchInv;
  6370. private _firstFrameSkipped;
  6371. private _yawRange;
  6372. private _fowardAxis;
  6373. /**
  6374. * Gets or sets the minimum yaw angle that the bone can look to
  6375. */
  6376. minYaw: number;
  6377. /**
  6378. * Gets or sets the maximum yaw angle that the bone can look to
  6379. */
  6380. maxYaw: number;
  6381. /**
  6382. * Gets or sets the minimum pitch angle that the bone can look to
  6383. */
  6384. minPitch: number;
  6385. /**
  6386. * Gets or sets the maximum pitch angle that the bone can look to
  6387. */
  6388. maxPitch: number;
  6389. /**
  6390. * Create a BoneLookController
  6391. * @param mesh the mesh that the bone belongs to
  6392. * @param bone the bone that will be looking to the target
  6393. * @param target the target Vector3 to look at
  6394. * @param settings optional settings:
  6395. * * maxYaw: the maximum angle the bone will yaw to
  6396. * * minYaw: the minimum angle the bone will yaw to
  6397. * * maxPitch: the maximum angle the bone will pitch to
  6398. * * minPitch: the minimum angle the bone will yaw to
  6399. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  6400. * * upAxis: the up axis of the coordinate system
  6401. * * upAxisSpace: the space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD.
  6402. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  6403. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  6404. * * adjustYaw: used to make an adjustment to the yaw of the bone
  6405. * * adjustPitch: used to make an adjustment to the pitch of the bone
  6406. * * adjustRoll: used to make an adjustment to the roll of the bone
  6407. **/
  6408. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  6409. maxYaw?: number;
  6410. minYaw?: number;
  6411. maxPitch?: number;
  6412. minPitch?: number;
  6413. slerpAmount?: number;
  6414. upAxis?: Vector3;
  6415. upAxisSpace?: Space;
  6416. yawAxis?: Vector3;
  6417. pitchAxis?: Vector3;
  6418. adjustYaw?: number;
  6419. adjustPitch?: number;
  6420. adjustRoll?: number;
  6421. });
  6422. /**
  6423. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  6424. */
  6425. update(): void;
  6426. private _getAngleDiff;
  6427. private _getAngleBetween;
  6428. private _isAngleBetween;
  6429. }
  6430. }
  6431. declare module BABYLON {
  6432. /**
  6433. * Class used to handle skinning animations
  6434. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  6435. */
  6436. class Skeleton implements IAnimatable {
  6437. /** defines the skeleton name */
  6438. name: string;
  6439. /** defines the skeleton Id */
  6440. id: string;
  6441. /**
  6442. * Gets the list of child bones
  6443. */
  6444. bones: Bone[];
  6445. /**
  6446. * Gets an estimate of the dimension of the skeleton at rest
  6447. */
  6448. dimensionsAtRest: Vector3;
  6449. /**
  6450. * Gets a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  6451. */
  6452. needInitialSkinMatrix: boolean;
  6453. /**
  6454. * Gets the list of animations attached to this skeleton
  6455. */
  6456. animations: Array<Animation>;
  6457. private _scene;
  6458. private _isDirty;
  6459. private _transformMatrices;
  6460. private _meshesWithPoseMatrix;
  6461. private _animatables;
  6462. private _identity;
  6463. private _synchronizedWithMesh;
  6464. private _ranges;
  6465. private _lastAbsoluteTransformsUpdateId;
  6466. /**
  6467. * Specifies if the skeleton should be serialized
  6468. */
  6469. doNotSerialize: boolean;
  6470. private _animationPropertiesOverride;
  6471. /**
  6472. * Gets or sets the animation properties override
  6473. */
  6474. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  6475. /**
  6476. * An observable triggered before computing the skeleton's matrices
  6477. */
  6478. onBeforeComputeObservable: Observable<Skeleton>;
  6479. /**
  6480. * Creates a new skeleton
  6481. * @param name defines the skeleton name
  6482. * @param id defines the skeleton Id
  6483. * @param scene defines the hosting scene
  6484. */
  6485. constructor(
  6486. /** defines the skeleton name */
  6487. name: string,
  6488. /** defines the skeleton Id */
  6489. id: string, scene: Scene);
  6490. /**
  6491. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  6492. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  6493. * @returns a Float32Array containing matrices data
  6494. */
  6495. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  6496. /**
  6497. * Gets the current hosting scene
  6498. * @returns a scene object
  6499. */
  6500. getScene(): Scene;
  6501. /**
  6502. * Gets a string representing the current skeleton data
  6503. * @param fullDetails defines a boolean indicating if we want a verbose version
  6504. * @returns a string representing the current skeleton data
  6505. */
  6506. toString(fullDetails?: boolean): string;
  6507. /**
  6508. * Get bone's index searching by name
  6509. * @param name defines bone's name to search for
  6510. * @return the indice of the bone. Returns -1 if not found
  6511. */
  6512. getBoneIndexByName(name: string): number;
  6513. /**
  6514. * Creater a new animation range
  6515. * @param name defines the name of the range
  6516. * @param from defines the start key
  6517. * @param to defines the end key
  6518. */
  6519. createAnimationRange(name: string, from: number, to: number): void;
  6520. /**
  6521. * Delete a specific animation range
  6522. * @param name defines the name of the range
  6523. * @param deleteFrames defines if frames must be removed as well
  6524. */
  6525. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  6526. /**
  6527. * Gets a specific animation range
  6528. * @param name defines the name of the range to look for
  6529. * @returns the requested animation range or null if not found
  6530. */
  6531. getAnimationRange(name: string): Nullable<AnimationRange>;
  6532. /**
  6533. * Gets the list of all animation ranges defined on this skeleton
  6534. * @returns an array
  6535. */
  6536. getAnimationRanges(): Nullable<AnimationRange>[];
  6537. /**
  6538. * Copy animation range from a source skeleton.
  6539. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  6540. * @param source defines the source skeleton
  6541. * @param name defines the name of the range to copy
  6542. * @param rescaleAsRequired defines if rescaling must be applied if required
  6543. * @returns true if operation was successful
  6544. */
  6545. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  6546. /**
  6547. * Forces the skeleton to go to rest pose
  6548. */
  6549. returnToRest(): void;
  6550. private _getHighestAnimationFrame;
  6551. /**
  6552. * Begin a specific animation range
  6553. * @param name defines the name of the range to start
  6554. * @param loop defines if looping must be turned on (false by default)
  6555. * @param speedRatio defines the speed ratio to apply (1 by default)
  6556. * @param onAnimationEnd defines a callback which will be called when animation will end
  6557. * @returns a new animatable
  6558. */
  6559. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  6560. /** @hidden */
  6561. _markAsDirty(): void;
  6562. /** @hidden */
  6563. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  6564. /** @hidden */
  6565. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  6566. /** @hidden */
  6567. _computeTransformMatrices(targetMatrix: Float32Array, initialSkinMatrix: Nullable<Matrix>): void;
  6568. /**
  6569. * Build all resources required to render a skeleton
  6570. */
  6571. prepare(): void;
  6572. /**
  6573. * Gets the list of animatables currently running for this skeleton
  6574. * @returns an array of animatables
  6575. */
  6576. getAnimatables(): IAnimatable[];
  6577. /**
  6578. * Clone the current skeleton
  6579. * @param name defines the name of the new skeleton
  6580. * @param id defines the id of the enw skeleton
  6581. * @returns the new skeleton
  6582. */
  6583. clone(name: string, id: string): Skeleton;
  6584. /**
  6585. * Enable animation blending for this skeleton
  6586. * @param blendingSpeed defines the blending speed to apply
  6587. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  6588. */
  6589. enableBlending(blendingSpeed?: number): void;
  6590. /**
  6591. * Releases all resources associated with the current skeleton
  6592. */
  6593. dispose(): void;
  6594. /**
  6595. * Serialize the skeleton in a JSON object
  6596. * @returns a JSON object
  6597. */
  6598. serialize(): any;
  6599. /**
  6600. * Creates a new skeleton from serialized data
  6601. * @param parsedSkeleton defines the serialized data
  6602. * @param scene defines the hosting scene
  6603. * @returns a new skeleton
  6604. */
  6605. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  6606. /**
  6607. * Compute all node absolute transforms
  6608. * @param forceUpdate defines if computation must be done even if cache is up to date
  6609. */
  6610. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  6611. /**
  6612. * Gets the root pose matrix
  6613. * @returns a matrix
  6614. */
  6615. getPoseMatrix(): Nullable<Matrix>;
  6616. /**
  6617. * Sorts bones per internal index
  6618. */
  6619. sortBones(): void;
  6620. private _sortBones;
  6621. }
  6622. }
  6623. declare module BABYLON {
  6624. /**
  6625. * This represents an orbital type of camera.
  6626. *
  6627. * 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.
  6628. * 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.
  6629. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  6630. */
  6631. class ArcRotateCamera extends TargetCamera {
  6632. /**
  6633. * Defines the rotation angle of the camera along the longitudinal axis.
  6634. */
  6635. alpha: number;
  6636. /**
  6637. * Defines the rotation angle of the camera along the latitudinal axis.
  6638. */
  6639. beta: number;
  6640. /**
  6641. * Defines the radius of the camera from it s target point.
  6642. */
  6643. radius: number;
  6644. protected _target: Vector3;
  6645. protected _targetHost: Nullable<AbstractMesh>;
  6646. /**
  6647. * Defines the target point of the camera.
  6648. * The camera looks towards it form the radius distance.
  6649. */
  6650. target: Vector3;
  6651. /**
  6652. * Current inertia value on the longitudinal axis.
  6653. * The bigger this number the longer it will take for the camera to stop.
  6654. */
  6655. inertialAlphaOffset: number;
  6656. /**
  6657. * Current inertia value on the latitudinal axis.
  6658. * The bigger this number the longer it will take for the camera to stop.
  6659. */
  6660. inertialBetaOffset: number;
  6661. /**
  6662. * Current inertia value on the radius axis.
  6663. * The bigger this number the longer it will take for the camera to stop.
  6664. */
  6665. inertialRadiusOffset: number;
  6666. /**
  6667. * Minimum allowed angle on the longitudinal axis.
  6668. * This can help limiting how the Camera is able to move in the scene.
  6669. */
  6670. lowerAlphaLimit: Nullable<number>;
  6671. /**
  6672. * Maximum allowed angle on the longitudinal axis.
  6673. * This can help limiting how the Camera is able to move in the scene.
  6674. */
  6675. upperAlphaLimit: Nullable<number>;
  6676. /**
  6677. * Minimum allowed angle on the latitudinal axis.
  6678. * This can help limiting how the Camera is able to move in the scene.
  6679. */
  6680. lowerBetaLimit: number;
  6681. /**
  6682. * Maximum allowed angle on the latitudinal axis.
  6683. * This can help limiting how the Camera is able to move in the scene.
  6684. */
  6685. upperBetaLimit: number;
  6686. /**
  6687. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  6688. * This can help limiting how the Camera is able to move in the scene.
  6689. */
  6690. lowerRadiusLimit: Nullable<number>;
  6691. /**
  6692. * Maximum allowed distance of the camera to the target (The camera can not get further).
  6693. * This can help limiting how the Camera is able to move in the scene.
  6694. */
  6695. upperRadiusLimit: Nullable<number>;
  6696. /**
  6697. * Defines the current inertia value used during panning of the camera along the X axis.
  6698. */
  6699. inertialPanningX: number;
  6700. /**
  6701. * Defines the current inertia value used during panning of the camera along the Y axis.
  6702. */
  6703. inertialPanningY: number;
  6704. /**
  6705. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  6706. * Basically if your fingers moves away from more than this distance you will be considered
  6707. * in pinch mode.
  6708. */
  6709. pinchToPanMaxDistance: number;
  6710. /**
  6711. * Defines the maximum distance the camera can pan.
  6712. * This could help keeping the cammera always in your scene.
  6713. */
  6714. panningDistanceLimit: Nullable<number>;
  6715. /**
  6716. * Defines the target of the camera before paning.
  6717. */
  6718. panningOriginTarget: Vector3;
  6719. /**
  6720. * Defines the value of the inertia used during panning.
  6721. * 0 would mean stop inertia and one would mean no decelleration at all.
  6722. */
  6723. panningInertia: number;
  6724. /**
  6725. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  6726. */
  6727. angularSensibilityX: number;
  6728. /**
  6729. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  6730. */
  6731. angularSensibilityY: number;
  6732. /**
  6733. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  6734. */
  6735. pinchPrecision: number;
  6736. /**
  6737. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  6738. * It will be used instead of pinchDeltaPrecision if different from 0.
  6739. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  6740. */
  6741. pinchDeltaPercentage: number;
  6742. /**
  6743. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  6744. */
  6745. panningSensibility: number;
  6746. /**
  6747. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  6748. */
  6749. keysUp: number[];
  6750. /**
  6751. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  6752. */
  6753. keysDown: number[];
  6754. /**
  6755. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  6756. */
  6757. keysLeft: number[];
  6758. /**
  6759. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  6760. */
  6761. keysRight: number[];
  6762. /**
  6763. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  6764. */
  6765. wheelPrecision: number;
  6766. /**
  6767. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  6768. * It will be used instead of pinchDeltaPrecision if different from 0.
  6769. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  6770. */
  6771. wheelDeltaPercentage: number;
  6772. /**
  6773. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  6774. */
  6775. zoomOnFactor: number;
  6776. /**
  6777. * Defines a screen offset for the camera position.
  6778. */
  6779. targetScreenOffset: Vector2;
  6780. /**
  6781. * Allows the camera to be completely reversed.
  6782. * If false the camera can not arrive upside down.
  6783. */
  6784. allowUpsideDown: boolean;
  6785. /**
  6786. * Define if double tap/click is used to restore the previously saved state of the camera.
  6787. */
  6788. useInputToRestoreState: boolean;
  6789. /** @hidden */
  6790. _viewMatrix: Matrix;
  6791. /** @hidden */
  6792. _useCtrlForPanning: boolean;
  6793. /** @hidden */
  6794. _panningMouseButton: number;
  6795. /**
  6796. * Defines the inpute associated to the camera.
  6797. */
  6798. inputs: ArcRotateCameraInputsManager;
  6799. /** @hidden */
  6800. _reset: () => void;
  6801. /**
  6802. * Defines the allowed panning axis.
  6803. */
  6804. panningAxis: Vector3;
  6805. protected _localDirection: Vector3;
  6806. protected _transformedDirection: Vector3;
  6807. private _bouncingBehavior;
  6808. /**
  6809. * Gets the bouncing behavior of the camera if it has been enabled.
  6810. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  6811. */
  6812. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  6813. /**
  6814. * Defines if the bouncing behavior of the camera is enabled on the camera.
  6815. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  6816. */
  6817. useBouncingBehavior: boolean;
  6818. private _framingBehavior;
  6819. /**
  6820. * Gets the framing behavior of the camera if it has been enabled.
  6821. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  6822. */
  6823. readonly framingBehavior: Nullable<FramingBehavior>;
  6824. /**
  6825. * Defines if the framing behavior of the camera is enabled on the camera.
  6826. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  6827. */
  6828. useFramingBehavior: boolean;
  6829. private _autoRotationBehavior;
  6830. /**
  6831. * Gets the auto rotation behavior of the camera if it has been enabled.
  6832. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  6833. */
  6834. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  6835. /**
  6836. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  6837. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  6838. */
  6839. useAutoRotationBehavior: boolean;
  6840. /**
  6841. * Observable triggered when the mesh target has been changed on the camera.
  6842. */
  6843. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  6844. /**
  6845. * Event raised when the camera is colliding with a mesh.
  6846. */
  6847. onCollide: (collidedMesh: AbstractMesh) => void;
  6848. /**
  6849. * Defines whether the camera should check collision with the objects oh the scene.
  6850. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  6851. */
  6852. checkCollisions: boolean;
  6853. /**
  6854. * Defines the collision radius of the camera.
  6855. * This simulates a sphere around the camera.
  6856. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  6857. */
  6858. collisionRadius: Vector3;
  6859. protected _collider: Collider;
  6860. protected _previousPosition: Vector3;
  6861. protected _collisionVelocity: Vector3;
  6862. protected _newPosition: Vector3;
  6863. protected _previousAlpha: number;
  6864. protected _previousBeta: number;
  6865. protected _previousRadius: number;
  6866. protected _collisionTriggered: boolean;
  6867. protected _targetBoundingCenter: Nullable<Vector3>;
  6868. private _computationVector;
  6869. /**
  6870. * Instantiates a new ArcRotateCamera in a given scene
  6871. * @param name Defines the name of the camera
  6872. * @param alpha Defines the camera rotation along the logitudinal axis
  6873. * @param beta Defines the camera rotation along the latitudinal axis
  6874. * @param radius Defines the camera distance from its target
  6875. * @param target Defines the camera target
  6876. * @param scene Defines the scene the camera belongs to
  6877. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  6878. */
  6879. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  6880. /** @hidden */
  6881. _initCache(): void;
  6882. /** @hidden */
  6883. _updateCache(ignoreParentClass?: boolean): void;
  6884. protected _getTargetPosition(): Vector3;
  6885. private _storedAlpha;
  6886. private _storedBeta;
  6887. private _storedRadius;
  6888. private _storedTarget;
  6889. /**
  6890. * Stores the current state of the camera (alpha, beta, radius and target)
  6891. * @returns the camera itself
  6892. */
  6893. storeState(): Camera;
  6894. /**
  6895. * @hidden
  6896. * Restored camera state. You must call storeState() first
  6897. */
  6898. _restoreStateValues(): boolean;
  6899. /** @hidden */
  6900. _isSynchronizedViewMatrix(): boolean;
  6901. /**
  6902. * Attached controls to the current camera.
  6903. * @param element Defines the element the controls should be listened from
  6904. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6905. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  6906. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  6907. */
  6908. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  6909. /**
  6910. * Detach the current controls from the camera.
  6911. * The camera will stop reacting to inputs.
  6912. * @param element Defines the element to stop listening the inputs from
  6913. */
  6914. detachControl(element: HTMLElement): void;
  6915. /** @hidden */
  6916. _checkInputs(): void;
  6917. protected _checkLimits(): void;
  6918. /**
  6919. * Rebuilds angles (alpha, beta) and radius from the give position and target.
  6920. */
  6921. rebuildAnglesAndRadius(): void;
  6922. /**
  6923. * Use a position to define the current camera related information like aplha, beta and radius
  6924. * @param position Defines the position to set the camera at
  6925. */
  6926. setPosition(position: Vector3): void;
  6927. /**
  6928. * Defines the target the camera should look at.
  6929. * This will automatically adapt alpha beta and radius to fit within the new target.
  6930. * @param target Defines the new target as a Vector or a mesh
  6931. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  6932. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  6933. */
  6934. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  6935. /** @hidden */
  6936. _getViewMatrix(): Matrix;
  6937. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  6938. /**
  6939. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  6940. * @param meshes Defines the mesh to zoom on
  6941. * @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)
  6942. */
  6943. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  6944. /**
  6945. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  6946. * The target will be changed but the radius
  6947. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  6948. * @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)
  6949. */
  6950. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  6951. min: Vector3;
  6952. max: Vector3;
  6953. distance: number;
  6954. }, doNotUpdateMaxZ?: boolean): void;
  6955. /**
  6956. * @override
  6957. * Override Camera.createRigCamera
  6958. */
  6959. createRigCamera(name: string, cameraIndex: number): Camera;
  6960. /**
  6961. * @hidden
  6962. * @override
  6963. * Override Camera._updateRigCameras
  6964. */
  6965. _updateRigCameras(): void;
  6966. /**
  6967. * Destroy the camera and release the current resources hold by it.
  6968. */
  6969. dispose(): void;
  6970. /**
  6971. * Gets the current object class name.
  6972. * @return the class name
  6973. */
  6974. getClassName(): string;
  6975. }
  6976. }
  6977. declare module BABYLON {
  6978. /**
  6979. * Default Inputs manager for the ArcRotateCamera.
  6980. * It groups all the default supported inputs for ease of use.
  6981. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6982. */
  6983. class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  6984. /**
  6985. * Instantiates a new ArcRotateCameraInputsManager.
  6986. * @param camera Defines the camera the inputs belong to
  6987. */
  6988. constructor(camera: ArcRotateCamera);
  6989. /**
  6990. * Add mouse wheel input support to the input manager.
  6991. * @returns the current input manager
  6992. */
  6993. addMouseWheel(): ArcRotateCameraInputsManager;
  6994. /**
  6995. * Add pointers input support to the input manager.
  6996. * @returns the current input manager
  6997. */
  6998. addPointers(): ArcRotateCameraInputsManager;
  6999. /**
  7000. * Add keyboard input support to the input manager.
  7001. * @returns the current input manager
  7002. */
  7003. addKeyboard(): ArcRotateCameraInputsManager;
  7004. /**
  7005. * Add orientation input support to the input manager.
  7006. * @returns the current input manager
  7007. */
  7008. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  7009. }
  7010. }
  7011. declare module BABYLON {
  7012. /**
  7013. * This is the base class of all the camera used in the application.
  7014. * @see http://doc.babylonjs.com/features/cameras
  7015. */
  7016. class Camera extends Node {
  7017. /**
  7018. * This is the default projection mode used by the cameras.
  7019. * It helps recreating a feeling of perspective and better appreciate depth.
  7020. * This is the best way to simulate real life cameras.
  7021. */
  7022. static readonly PERSPECTIVE_CAMERA: number;
  7023. /**
  7024. * This helps creating camera with an orthographic mode.
  7025. * 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.
  7026. */
  7027. static readonly ORTHOGRAPHIC_CAMERA: number;
  7028. /**
  7029. * This is the default FOV mode for perspective cameras.
  7030. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  7031. */
  7032. static readonly FOVMODE_VERTICAL_FIXED: number;
  7033. /**
  7034. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  7035. */
  7036. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  7037. /**
  7038. * This specifies ther is no need for a camera rig.
  7039. * Basically only one eye is rendered corresponding to the camera.
  7040. */
  7041. static readonly RIG_MODE_NONE: number;
  7042. /**
  7043. * Simulates a camera Rig with one blue eye and one red eye.
  7044. * This can be use with 3d blue and red glasses.
  7045. */
  7046. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  7047. /**
  7048. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  7049. */
  7050. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  7051. /**
  7052. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  7053. */
  7054. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  7055. /**
  7056. * Defines that both eyes of the camera will be rendered over under each other.
  7057. */
  7058. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  7059. /**
  7060. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  7061. */
  7062. static readonly RIG_MODE_VR: number;
  7063. /**
  7064. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  7065. */
  7066. static readonly RIG_MODE_WEBVR: number;
  7067. /**
  7068. * Defines if by default attaching controls should prevent the default javascript event to continue.
  7069. */
  7070. static ForceAttachControlToAlwaysPreventDefault: boolean;
  7071. /**
  7072. * @hidden
  7073. * Might be removed once multiview will be a thing
  7074. */
  7075. static UseAlternateWebVRRendering: boolean;
  7076. /**
  7077. * Define the input manager associated with the camera.
  7078. */
  7079. inputs: CameraInputsManager<Camera>;
  7080. /**
  7081. * Define the current local position of the camera in the scene
  7082. */
  7083. position: Vector3;
  7084. /**
  7085. * The vector the camera should consider as up.
  7086. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  7087. */
  7088. upVector: Vector3;
  7089. /**
  7090. * Define the current limit on the left side for an orthographic camera
  7091. * In scene unit
  7092. */
  7093. orthoLeft: Nullable<number>;
  7094. /**
  7095. * Define the current limit on the right side for an orthographic camera
  7096. * In scene unit
  7097. */
  7098. orthoRight: Nullable<number>;
  7099. /**
  7100. * Define the current limit on the bottom side for an orthographic camera
  7101. * In scene unit
  7102. */
  7103. orthoBottom: Nullable<number>;
  7104. /**
  7105. * Define the current limit on the top side for an orthographic camera
  7106. * In scene unit
  7107. */
  7108. orthoTop: Nullable<number>;
  7109. /**
  7110. * Field Of View is set in Radians. (default is 0.8)
  7111. */
  7112. fov: number;
  7113. /**
  7114. * Define the minimum distance the camera can see from.
  7115. * This is important to note that the depth buffer are not infinite and the closer it starts
  7116. * the more your scene might encounter depth fighting issue.
  7117. */
  7118. minZ: number;
  7119. /**
  7120. * Define the maximum distance the camera can see to.
  7121. * This is important to note that the depth buffer are not infinite and the further it end
  7122. * the more your scene might encounter depth fighting issue.
  7123. */
  7124. maxZ: number;
  7125. /**
  7126. * Define the default inertia of the camera.
  7127. * This helps giving a smooth feeling to the camera movement.
  7128. */
  7129. inertia: number;
  7130. /**
  7131. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  7132. */
  7133. mode: number;
  7134. /**
  7135. * Define wether the camera is intermediate.
  7136. * This is usefull to not present the output directly to the screen in case of rig without post process for instance
  7137. */
  7138. isIntermediate: boolean;
  7139. /**
  7140. * Define the viewport of the camera.
  7141. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  7142. */
  7143. viewport: Viewport;
  7144. /**
  7145. * Restricts the camera to viewing objects with the same layerMask.
  7146. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  7147. */
  7148. layerMask: number;
  7149. /**
  7150. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  7151. */
  7152. fovMode: number;
  7153. /**
  7154. * Rig mode of the camera.
  7155. * This is usefull to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  7156. * This is normally controlled byt the camera themselves as internal use.
  7157. */
  7158. cameraRigMode: number;
  7159. /**
  7160. * Defines the distance between both "eyes" in case of a RIG
  7161. */
  7162. interaxialDistance: number;
  7163. /**
  7164. * Defines if stereoscopic rendering is done side by side or over under.
  7165. */
  7166. isStereoscopicSideBySide: boolean;
  7167. /**
  7168. * Defines the list of custom render target the camera should render to.
  7169. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  7170. * else in the scene.
  7171. */
  7172. customRenderTargets: RenderTargetTexture[];
  7173. /**
  7174. * Observable triggered when the camera view matrix has changed.
  7175. */
  7176. onViewMatrixChangedObservable: Observable<Camera>;
  7177. /**
  7178. * Observable triggered when the camera Projection matrix has changed.
  7179. */
  7180. onProjectionMatrixChangedObservable: Observable<Camera>;
  7181. /**
  7182. * Observable triggered when the inputs have been processed.
  7183. */
  7184. onAfterCheckInputsObservable: Observable<Camera>;
  7185. /**
  7186. * Observable triggered when reset has been called and applied to the camera.
  7187. */
  7188. onRestoreStateObservable: Observable<Camera>;
  7189. /** @hidden */
  7190. _cameraRigParams: any;
  7191. /** @hidden */
  7192. _rigCameras: Camera[];
  7193. /** @hidden */
  7194. _rigPostProcess: Nullable<PostProcess>;
  7195. protected _webvrViewMatrix: Matrix;
  7196. /** @hidden */
  7197. _skipRendering: boolean;
  7198. /** @hidden */
  7199. _alternateCamera: Camera;
  7200. /** @hidden */
  7201. _projectionMatrix: Matrix;
  7202. /** @hidden */
  7203. _postProcesses: Nullable<PostProcess>[];
  7204. /** @hidden */
  7205. _activeMeshes: SmartArray<AbstractMesh>;
  7206. protected _globalPosition: Vector3;
  7207. private _computedViewMatrix;
  7208. private _doNotComputeProjectionMatrix;
  7209. private _transformMatrix;
  7210. private _frustumPlanes;
  7211. private _refreshFrustumPlanes;
  7212. private _storedFov;
  7213. private _stateStored;
  7214. /**
  7215. * Instantiates a new camera object.
  7216. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  7217. * @see http://doc.babylonjs.com/features/cameras
  7218. * @param name Defines the name of the camera in the scene
  7219. * @param position Defines the position of the camera
  7220. * @param scene Defines the scene the camera belongs too
  7221. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  7222. */
  7223. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  7224. /**
  7225. * Store current camera state (fov, position, etc..)
  7226. * @returns the camera
  7227. */
  7228. storeState(): Camera;
  7229. /**
  7230. * Restores the camera state values if it has been stored. You must call storeState() first
  7231. */
  7232. protected _restoreStateValues(): boolean;
  7233. /**
  7234. * Restored camera state. You must call storeState() first.
  7235. * @returns true if restored and false otherwise
  7236. */
  7237. restoreState(): boolean;
  7238. /**
  7239. * Gets the class name of the camera.
  7240. * @returns the class name
  7241. */
  7242. getClassName(): string;
  7243. /**
  7244. * Gets a string representation of the camera usefull for debug purpose.
  7245. * @param fullDetails Defines that a more verboe level of logging is required
  7246. * @returns the string representation
  7247. */
  7248. toString(fullDetails?: boolean): string;
  7249. /**
  7250. * Gets the current world space position of the camera.
  7251. */
  7252. readonly globalPosition: Vector3;
  7253. /**
  7254. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  7255. * @returns the active meshe list
  7256. */
  7257. getActiveMeshes(): SmartArray<AbstractMesh>;
  7258. /**
  7259. * Check wether a mesh is part of the current active mesh list of the camera
  7260. * @param mesh Defines the mesh to check
  7261. * @returns true if active, false otherwise
  7262. */
  7263. isActiveMesh(mesh: Mesh): boolean;
  7264. /**
  7265. * Is this camera ready to be used/rendered
  7266. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  7267. * @return true if the camera is ready
  7268. */
  7269. isReady(completeCheck?: boolean): boolean;
  7270. /** @hidden */
  7271. _initCache(): void;
  7272. /** @hidden */
  7273. _updateCache(ignoreParentClass?: boolean): void;
  7274. /** @hidden */
  7275. _isSynchronized(): boolean;
  7276. /** @hidden */
  7277. _isSynchronizedViewMatrix(): boolean;
  7278. /** @hidden */
  7279. _isSynchronizedProjectionMatrix(): boolean;
  7280. /**
  7281. * Attach the input controls to a specific dom element to get the input from.
  7282. * @param element Defines the element the controls should be listened from
  7283. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7284. */
  7285. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  7286. /**
  7287. * Detach the current controls from the specified dom element.
  7288. * @param element Defines the element to stop listening the inputs from
  7289. */
  7290. detachControl(element: HTMLElement): void;
  7291. /**
  7292. * Update the camera state according to the different inputs gathered during the frame.
  7293. */
  7294. update(): void;
  7295. /** @hidden */
  7296. _checkInputs(): void;
  7297. /** @hidden */
  7298. readonly rigCameras: Camera[];
  7299. /**
  7300. * Gets the post process used by the rig cameras
  7301. */
  7302. readonly rigPostProcess: Nullable<PostProcess>;
  7303. /**
  7304. * Internal, gets the first post proces.
  7305. * @returns the first post process to be run on this camera.
  7306. */
  7307. _getFirstPostProcess(): Nullable<PostProcess>;
  7308. private _cascadePostProcessesToRigCams;
  7309. /**
  7310. * Attach a post process to the camera.
  7311. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  7312. * @param postProcess The post process to attach to the camera
  7313. * @param insertAt The position of the post process in case several of them are in use in the scene
  7314. * @returns the position the post process has been inserted at
  7315. */
  7316. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  7317. /**
  7318. * Detach a post process to the camera.
  7319. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  7320. * @param postProcess The post process to detach from the camera
  7321. */
  7322. detachPostProcess(postProcess: PostProcess): void;
  7323. /**
  7324. * Gets the current world matrix of the camera
  7325. */
  7326. getWorldMatrix(): Matrix;
  7327. /** @hidden */
  7328. protected _getViewMatrix(): Matrix;
  7329. /**
  7330. * Gets the current view matrix of the camera.
  7331. * @param force forces the camera to recompute the matrix without looking at the cached state
  7332. * @returns the view matrix
  7333. */
  7334. getViewMatrix(force?: boolean): Matrix;
  7335. /**
  7336. * Freeze the projection matrix.
  7337. * It will prevent the cache check of the camera projection compute and can speed up perf
  7338. * if no parameter of the camera are meant to change
  7339. * @param projection Defines manually a projection if necessary
  7340. */
  7341. freezeProjectionMatrix(projection?: Matrix): void;
  7342. /**
  7343. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  7344. */
  7345. unfreezeProjectionMatrix(): void;
  7346. /**
  7347. * Gets the current projection matrix of the camera.
  7348. * @param force forces the camera to recompute the matrix without looking at the cached state
  7349. * @returns the projection matrix
  7350. */
  7351. getProjectionMatrix(force?: boolean): Matrix;
  7352. /**
  7353. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  7354. * @returns a Matrix
  7355. */
  7356. getTransformationMatrix(): Matrix;
  7357. private _updateFrustumPlanes;
  7358. /**
  7359. * Checks if a cullable object (mesh...) is in the camera frustum
  7360. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  7361. * @param target The object to check
  7362. * @returns true if the object is in frustum otherwise false
  7363. */
  7364. isInFrustum(target: ICullable): boolean;
  7365. /**
  7366. * Checks if a cullable object (mesh...) is in the camera frustum
  7367. * Unlike isInFrustum this cheks the full bounding box
  7368. * @param target The object to check
  7369. * @returns true if the object is in frustum otherwise false
  7370. */
  7371. isCompletelyInFrustum(target: ICullable): boolean;
  7372. /**
  7373. * Gets a ray in the forward direction from the camera.
  7374. * @param length Defines the length of the ray to create
  7375. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  7376. * @param origin Defines the start point of the ray which defaults to the camera position
  7377. * @returns the forward ray
  7378. */
  7379. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  7380. /**
  7381. * Releases resources associated with this node.
  7382. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  7383. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  7384. */
  7385. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7386. /**
  7387. * Gets the left camera of a rig setup in case of Rigged Camera
  7388. */
  7389. readonly leftCamera: Nullable<FreeCamera>;
  7390. /**
  7391. * Gets the right camera of a rig setup in case of Rigged Camera
  7392. */
  7393. readonly rightCamera: Nullable<FreeCamera>;
  7394. /**
  7395. * Gets the left camera target of a rig setup in case of Rigged Camera
  7396. * @returns the target position
  7397. */
  7398. getLeftTarget(): Nullable<Vector3>;
  7399. /**
  7400. * Gets the right camera target of a rig setup in case of Rigged Camera
  7401. * @returns the target position
  7402. */
  7403. getRightTarget(): Nullable<Vector3>;
  7404. /**
  7405. * @hidden
  7406. */
  7407. setCameraRigMode(mode: number, rigParams: any): void;
  7408. private _getVRProjectionMatrix;
  7409. protected _updateCameraRotationMatrix(): void;
  7410. protected _updateWebVRCameraRotationMatrix(): void;
  7411. /**
  7412. * This function MUST be overwritten by the different WebVR cameras available.
  7413. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  7414. */
  7415. protected _getWebVRProjectionMatrix(): Matrix;
  7416. /**
  7417. * This function MUST be overwritten by the different WebVR cameras available.
  7418. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  7419. */
  7420. protected _getWebVRViewMatrix(): Matrix;
  7421. /** @hidden */
  7422. setCameraRigParameter(name: string, value: any): void;
  7423. /**
  7424. * needs to be overridden by children so sub has required properties to be copied
  7425. * @hidden
  7426. */
  7427. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  7428. /**
  7429. * May need to be overridden by children
  7430. * @hidden
  7431. */
  7432. _updateRigCameras(): void;
  7433. /** @hidden */
  7434. _setupInputs(): void;
  7435. /**
  7436. * Serialiaze the camera setup to a json represention
  7437. * @returns the JSON representation
  7438. */
  7439. serialize(): any;
  7440. /**
  7441. * Clones the current camera.
  7442. * @param name The cloned camera name
  7443. * @returns the cloned camera
  7444. */
  7445. clone(name: string): Camera;
  7446. /**
  7447. * Gets the direction of the camera relative to a given local axis.
  7448. * @param localAxis Defines the reference axis to provide a relative direction.
  7449. * @return the direction
  7450. */
  7451. getDirection(localAxis: Vector3): Vector3;
  7452. /**
  7453. * Gets the direction of the camera relative to a given local axis into a passed vector.
  7454. * @param localAxis Defines the reference axis to provide a relative direction.
  7455. * @param result Defines the vector to store the result in
  7456. */
  7457. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  7458. /**
  7459. * Gets a camera constructor for a given camera type
  7460. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  7461. * @param name The name of the camera the result will be able to instantiate
  7462. * @param scene The scene the result will construct the camera in
  7463. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  7464. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  7465. * @returns a factory method to construc the camera
  7466. */
  7467. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  7468. /**
  7469. * Compute the world matrix of the camera.
  7470. * @returns the camera workd matrix
  7471. */
  7472. computeWorldMatrix(): Matrix;
  7473. /**
  7474. * Parse a JSON and creates the camera from the parsed information
  7475. * @param parsedCamera The JSON to parse
  7476. * @param scene The scene to instantiate the camera in
  7477. * @returns the newly constructed camera
  7478. */
  7479. static Parse(parsedCamera: any, scene: Scene): Camera;
  7480. }
  7481. }
  7482. declare module BABYLON {
  7483. /**
  7484. * @ignore
  7485. * This is a list of all the different input types that are available in the application.
  7486. * Fo instance: ArcRotateCameraGamepadInput...
  7487. */
  7488. var CameraInputTypes: {};
  7489. /**
  7490. * This is the contract to implement in order to create a new input class.
  7491. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  7492. */
  7493. interface ICameraInput<TCamera extends Camera> {
  7494. /**
  7495. * Defines the camera the input is attached to.
  7496. */
  7497. camera: Nullable<TCamera>;
  7498. /**
  7499. * Gets the class name of the current intput.
  7500. * @returns the class name
  7501. */
  7502. getClassName(): string;
  7503. /**
  7504. * Get the friendly name associated with the input class.
  7505. * @returns the input friendly name
  7506. */
  7507. getSimpleName(): string;
  7508. /**
  7509. * Attach the input controls to a specific dom element to get the input from.
  7510. * @param element Defines the element the controls should be listened from
  7511. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7512. */
  7513. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  7514. /**
  7515. * Detach the current controls from the specified dom element.
  7516. * @param element Defines the element to stop listening the inputs from
  7517. */
  7518. detachControl(element: Nullable<HTMLElement>): void;
  7519. /**
  7520. * Update the current camera state depending on the inputs that have been used this frame.
  7521. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  7522. */
  7523. checkInputs?: () => void;
  7524. }
  7525. /**
  7526. * Represents a map of input types to input instance or input index to input instance.
  7527. */
  7528. interface CameraInputsMap<TCamera extends Camera> {
  7529. /**
  7530. * Accessor to the input by input type.
  7531. */
  7532. [name: string]: ICameraInput<TCamera>;
  7533. /**
  7534. * Accessor to the input by input index.
  7535. */
  7536. [idx: number]: ICameraInput<TCamera>;
  7537. }
  7538. /**
  7539. * This represents the input manager used within a camera.
  7540. * It helps dealing with all the different kind of input attached to a camera.
  7541. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  7542. */
  7543. class CameraInputsManager<TCamera extends Camera> {
  7544. /**
  7545. * Defines the list of inputs attahed to the camera.
  7546. */
  7547. attached: CameraInputsMap<TCamera>;
  7548. /**
  7549. * Defines the dom element the camera is collecting inputs from.
  7550. * This is null if the controls have not been attached.
  7551. */
  7552. attachedElement: Nullable<HTMLElement>;
  7553. /**
  7554. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7555. */
  7556. noPreventDefault: boolean;
  7557. /**
  7558. * Defined the camera the input manager belongs to.
  7559. */
  7560. camera: TCamera;
  7561. /**
  7562. * Update the current camera state depending on the inputs that have been used this frame.
  7563. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  7564. */
  7565. checkInputs: () => void;
  7566. /**
  7567. * Instantiate a new Camera Input Manager.
  7568. * @param camera Defines the camera the input manager blongs to
  7569. */
  7570. constructor(camera: TCamera);
  7571. /**
  7572. * Add an input method to a camera
  7573. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  7574. * @param input camera input method
  7575. */
  7576. add(input: ICameraInput<TCamera>): void;
  7577. /**
  7578. * Remove a specific input method from a camera
  7579. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  7580. * @param inputToRemove camera input method
  7581. */
  7582. remove(inputToRemove: ICameraInput<TCamera>): void;
  7583. /**
  7584. * Remove a specific input type from a camera
  7585. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  7586. * @param inputType the type of the input to remove
  7587. */
  7588. removeByType(inputType: string): void;
  7589. private _addCheckInputs;
  7590. /**
  7591. * Attach the input controls to the currently attached dom element to listen the events from.
  7592. * @param input Defines the input to attach
  7593. */
  7594. attachInput(input: ICameraInput<TCamera>): void;
  7595. /**
  7596. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  7597. * @param element Defines the dom element to collect the events from
  7598. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7599. */
  7600. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  7601. /**
  7602. * Detach the current manager inputs controls from a specific dom element.
  7603. * @param element Defines the dom element to collect the events from
  7604. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  7605. */
  7606. detachElement(element: HTMLElement, disconnect?: boolean): void;
  7607. /**
  7608. * Rebuild the dynamic inputCheck function from the current list of
  7609. * defined inputs in the manager.
  7610. */
  7611. rebuildInputCheck(): void;
  7612. /**
  7613. * Remove all attached input methods from a camera
  7614. */
  7615. clear(): void;
  7616. /**
  7617. * Serialize the current input manager attached to a camera.
  7618. * This ensures than once parsed,
  7619. * the input associated to the camera will be identical to the current ones
  7620. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  7621. */
  7622. serialize(serializedCamera: any): void;
  7623. /**
  7624. * Parses an input manager serialized JSON to restore the previous list of inputs
  7625. * and states associated to a camera.
  7626. * @param parsedCamera Defines the JSON to parse
  7627. */
  7628. parse(parsedCamera: any): void;
  7629. }
  7630. }
  7631. declare module BABYLON {
  7632. /**
  7633. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  7634. * being tilted forward or back and left or right.
  7635. */
  7636. class DeviceOrientationCamera extends FreeCamera {
  7637. private _initialQuaternion;
  7638. private _quaternionCache;
  7639. /**
  7640. * Creates a new device orientation camera
  7641. * @param name The name of the camera
  7642. * @param position The start position camera
  7643. * @param scene The scene the camera belongs to
  7644. */
  7645. constructor(name: string, position: Vector3, scene: Scene);
  7646. /**
  7647. * Gets the current instance class name ("DeviceOrientationCamera").
  7648. * This helps avoiding instanceof at run time.
  7649. * @returns the class name
  7650. */
  7651. getClassName(): string;
  7652. /**
  7653. * @hidden
  7654. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  7655. */
  7656. _checkInputs(): void;
  7657. /**
  7658. * Reset the camera to its default orientation on the specified axis only.
  7659. * @param axis The axis to reset
  7660. */
  7661. resetToCurrentRotation(axis?: Axis): void;
  7662. }
  7663. }
  7664. declare module BABYLON {
  7665. /**
  7666. * This is a flying camera, designed for 3D movement and rotation in all directions,
  7667. * such as in a 3D Space Shooter or a Flight Simulator.
  7668. */
  7669. class FlyCamera extends TargetCamera {
  7670. /**
  7671. * Define the collision ellipsoid of the camera.
  7672. * This is helpful for simulating a camera body, like a player's body.
  7673. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  7674. */
  7675. ellipsoid: Vector3;
  7676. /**
  7677. * Define an offset for the position of the ellipsoid around the camera.
  7678. * This can be helpful if the camera is attached away from the player's body center,
  7679. * such as at its head.
  7680. */
  7681. ellipsoidOffset: Vector3;
  7682. /**
  7683. * Enable or disable collisions of the camera with the rest of the scene objects.
  7684. */
  7685. checkCollisions: boolean;
  7686. /**
  7687. * Enable or disable gravity on the camera.
  7688. */
  7689. applyGravity: boolean;
  7690. /**
  7691. * Define the current direction the camera is moving to.
  7692. */
  7693. cameraDirection: Vector3;
  7694. /**
  7695. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  7696. * This overrides and empties cameraRotation.
  7697. */
  7698. rotationQuaternion: BABYLON.Quaternion;
  7699. /**
  7700. * Track Roll to maintain the wanted Rolling when looking around.
  7701. */
  7702. _trackRoll: number;
  7703. /**
  7704. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  7705. */
  7706. rollCorrect: number;
  7707. /**
  7708. * Mimic a banked turn, Rolling the camera when Yawing.
  7709. * It's recommended to use rollCorrect = 10 for faster banking correction.
  7710. */
  7711. bankedTurn: boolean;
  7712. /**
  7713. * Limit in radians for how much Roll banking will add. (Default: 90°)
  7714. */
  7715. bankedTurnLimit: number;
  7716. /**
  7717. * Value of 0 disables the banked Roll.
  7718. * Value of 1 is equal to the Yaw angle in radians.
  7719. */
  7720. bankedTurnMultiplier: number;
  7721. /**
  7722. * The inputs manager loads all the input sources, such as keyboard and mouse.
  7723. */
  7724. inputs: FlyCameraInputsManager;
  7725. /**
  7726. * Gets the input sensibility for mouse input.
  7727. * Higher values reduce sensitivity.
  7728. */
  7729. /**
  7730. * Sets the input sensibility for a mouse input.
  7731. * Higher values reduce sensitivity.
  7732. */
  7733. angularSensibility: number;
  7734. /**
  7735. * Get the keys for camera movement forward.
  7736. */
  7737. /**
  7738. * Set the keys for camera movement forward.
  7739. */
  7740. keysForward: number[];
  7741. /**
  7742. * Get the keys for camera movement backward.
  7743. */
  7744. keysBackward: number[];
  7745. /**
  7746. * Get the keys for camera movement up.
  7747. */
  7748. /**
  7749. * Set the keys for camera movement up.
  7750. */
  7751. keysUp: number[];
  7752. /**
  7753. * Get the keys for camera movement down.
  7754. */
  7755. /**
  7756. * Set the keys for camera movement down.
  7757. */
  7758. keysDown: number[];
  7759. /**
  7760. * Get the keys for camera movement left.
  7761. */
  7762. /**
  7763. * Set the keys for camera movement left.
  7764. */
  7765. keysLeft: number[];
  7766. /**
  7767. * Set the keys for camera movement right.
  7768. */
  7769. /**
  7770. * Set the keys for camera movement right.
  7771. */
  7772. keysRight: number[];
  7773. /**
  7774. * Event raised when the camera collides with a mesh in the scene.
  7775. */
  7776. onCollide: (collidedMesh: AbstractMesh) => void;
  7777. private _collider;
  7778. private _needMoveForGravity;
  7779. private _oldPosition;
  7780. private _diffPosition;
  7781. private _newPosition;
  7782. /** @hidden */
  7783. _localDirection: Vector3;
  7784. /** @hidden */
  7785. _transformedDirection: Vector3;
  7786. /**
  7787. * Instantiates a FlyCamera.
  7788. * This is a flying camera, designed for 3D movement and rotation in all directions,
  7789. * such as in a 3D Space Shooter or a Flight Simulator.
  7790. * @param name Define the name of the camera in the scene.
  7791. * @param position Define the starting position of the camera in the scene.
  7792. * @param scene Define the scene the camera belongs to.
  7793. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  7794. */
  7795. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  7796. /**
  7797. * Attach a control to the HTML DOM element.
  7798. * @param element Defines the element that listens to the input events.
  7799. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  7800. */
  7801. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  7802. /**
  7803. * Detach a control from the HTML DOM element.
  7804. * The camera will stop reacting to that input.
  7805. * @param element Defines the element that listens to the input events.
  7806. */
  7807. detachControl(element: HTMLElement): void;
  7808. private _collisionMask;
  7809. /**
  7810. * Get the mask that the camera ignores in collision events.
  7811. */
  7812. /**
  7813. * Set the mask that the camera ignores in collision events.
  7814. */
  7815. collisionMask: number;
  7816. /** @hidden */
  7817. _collideWithWorld(displacement: Vector3): void;
  7818. /** @hidden */
  7819. private _onCollisionPositionChange;
  7820. /** @hidden */
  7821. _checkInputs(): void;
  7822. /** @hidden */
  7823. _decideIfNeedsToMove(): boolean;
  7824. /** @hidden */
  7825. _updatePosition(): void;
  7826. /**
  7827. * Restore the Roll to its target value at the rate specified.
  7828. * @param rate - Higher means slower restoring.
  7829. * @hidden
  7830. */
  7831. restoreRoll(rate: number): void;
  7832. /**
  7833. * Destroy the camera and release the current resources held by it.
  7834. */
  7835. dispose(): void;
  7836. /**
  7837. * Get the current object class name.
  7838. * @returns the class name.
  7839. */
  7840. getClassName(): string;
  7841. }
  7842. }
  7843. declare module BABYLON {
  7844. /**
  7845. * Default Inputs manager for the FlyCamera.
  7846. * It groups all the default supported inputs for ease of use.
  7847. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  7848. */
  7849. class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  7850. /**
  7851. * Instantiates a new FlyCameraInputsManager.
  7852. * @param camera Defines the camera the inputs belong to.
  7853. */
  7854. constructor(camera: FlyCamera);
  7855. /**
  7856. * Add keyboard input support to the input manager.
  7857. * @returns the new FlyCameraKeyboardMoveInput().
  7858. */
  7859. addKeyboard(): FlyCameraInputsManager;
  7860. /**
  7861. * Add mouse input support to the input manager.
  7862. * @param touchEnabled Enable touch screen support.
  7863. * @returns the new FlyCameraMouseInput().
  7864. */
  7865. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  7866. }
  7867. }
  7868. declare module BABYLON {
  7869. /**
  7870. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  7871. * an arc rotate version arcFollowCamera are available.
  7872. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  7873. */
  7874. class FollowCamera extends TargetCamera {
  7875. /**
  7876. * Distance the follow camera should follow an object at
  7877. */
  7878. radius: number;
  7879. /**
  7880. * Define a rotation offset between the camera and the object it follows
  7881. */
  7882. rotationOffset: number;
  7883. /**
  7884. * Define a height offset between the camera and the object it follows.
  7885. * It can help following an object from the top (like a car chaing a plane)
  7886. */
  7887. heightOffset: number;
  7888. /**
  7889. * Define how fast the camera can accelerate to follow it s target.
  7890. */
  7891. cameraAcceleration: number;
  7892. /**
  7893. * Define the speed limit of the camera following an object.
  7894. */
  7895. maxCameraSpeed: number;
  7896. /**
  7897. * Define the target of the camera.
  7898. */
  7899. lockedTarget: Nullable<AbstractMesh>;
  7900. /**
  7901. * Instantiates the follow camera.
  7902. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  7903. * @param name Define the name of the camera in the scene
  7904. * @param position Define the position of the camera
  7905. * @param scene Define the scene the camera belong to
  7906. * @param lockedTarget Define the target of the camera
  7907. */
  7908. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  7909. private _follow;
  7910. /** @hidden */
  7911. _checkInputs(): void;
  7912. /**
  7913. * Gets the camera class name.
  7914. * @returns the class name
  7915. */
  7916. getClassName(): string;
  7917. }
  7918. /**
  7919. * Arc Rotate version of the follow camera.
  7920. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  7921. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  7922. */
  7923. class ArcFollowCamera extends TargetCamera {
  7924. /** The longitudinal angle of the camera */
  7925. alpha: number;
  7926. /** The latitudinal angle of the camera */
  7927. beta: number;
  7928. /** The radius of the camera from its target */
  7929. radius: number;
  7930. /** Define the camera target (the messh it should follow) */
  7931. target: Nullable<AbstractMesh>;
  7932. private _cartesianCoordinates;
  7933. /**
  7934. * Instantiates a new ArcFollowCamera
  7935. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  7936. * @param name Define the name of the camera
  7937. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  7938. * @param beta Define the rotation angle of the camera around the elevation axis
  7939. * @param radius Define the radius of the camera from its target point
  7940. * @param target Define the target of the camera
  7941. * @param scene Define the scene the camera belongs to
  7942. */
  7943. constructor(name: string,
  7944. /** The longitudinal angle of the camera */
  7945. alpha: number,
  7946. /** The latitudinal angle of the camera */
  7947. beta: number,
  7948. /** The radius of the camera from its target */
  7949. radius: number,
  7950. /** Define the camera target (the messh it should follow) */
  7951. target: Nullable<AbstractMesh>, scene: Scene);
  7952. private _follow;
  7953. /** @hidden */
  7954. _checkInputs(): void;
  7955. /**
  7956. * Returns the class name of the object.
  7957. * It is mostly used internally for serialization purposes.
  7958. */
  7959. getClassName(): string;
  7960. }
  7961. }
  7962. declare module BABYLON {
  7963. /**
  7964. * This represents a free type of camera. It can be usefull in First Person Shooter game for instance.
  7965. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  7966. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  7967. */
  7968. class FreeCamera extends TargetCamera {
  7969. /**
  7970. * Define the collision ellipsoid of the camera.
  7971. * This is helpful to simulate a camera body like the player body around the camera
  7972. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  7973. */
  7974. ellipsoid: Vector3;
  7975. /**
  7976. * Define an offset for the position of the ellipsoid around the camera.
  7977. * This can be helpful to determine the center of the body near the gravity center of the body
  7978. * instead of its head.
  7979. */
  7980. ellipsoidOffset: Vector3;
  7981. /**
  7982. * Enable or disable collisions of the camera with the rest of the scene objects.
  7983. */
  7984. checkCollisions: boolean;
  7985. /**
  7986. * Enable or disable gravity on the camera.
  7987. */
  7988. applyGravity: boolean;
  7989. /**
  7990. * Define the input manager associated to the camera.
  7991. */
  7992. inputs: FreeCameraInputsManager;
  7993. /**
  7994. * Gets the input sensibility for a mouse input. (default is 2000.0)
  7995. * Higher values reduce sensitivity.
  7996. */
  7997. /**
  7998. * Sets the input sensibility for a mouse input. (default is 2000.0)
  7999. * Higher values reduce sensitivity.
  8000. */
  8001. angularSensibility: number;
  8002. /**
  8003. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8004. */
  8005. keysUp: number[];
  8006. /**
  8007. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8008. */
  8009. keysDown: number[];
  8010. /**
  8011. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8012. */
  8013. keysLeft: number[];
  8014. /**
  8015. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8016. */
  8017. keysRight: number[];
  8018. /**
  8019. * Event raised when the camera collide with a mesh in the scene.
  8020. */
  8021. onCollide: (collidedMesh: AbstractMesh) => void;
  8022. private _collider;
  8023. private _needMoveForGravity;
  8024. private _oldPosition;
  8025. private _diffPosition;
  8026. private _newPosition;
  8027. /** @hidden */
  8028. _localDirection: Vector3;
  8029. /** @hidden */
  8030. _transformedDirection: Vector3;
  8031. /**
  8032. * Instantiates a Free Camera.
  8033. * This represents a free type of camera. It can be usefull in First Person Shooter game for instance.
  8034. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  8035. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8036. * @param name Define the name of the camera in the scene
  8037. * @param position Define the start position of the camera in the scene
  8038. * @param scene Define the scene the camera belongs to
  8039. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8040. */
  8041. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8042. /**
  8043. * Attached controls to the current camera.
  8044. * @param element Defines the element the controls should be listened from
  8045. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8046. */
  8047. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8048. /**
  8049. * Detach the current controls from the camera.
  8050. * The camera will stop reacting to inputs.
  8051. * @param element Defines the element to stop listening the inputs from
  8052. */
  8053. detachControl(element: HTMLElement): void;
  8054. private _collisionMask;
  8055. /**
  8056. * Define a collision mask to limit the list of object the camera can collide with
  8057. */
  8058. collisionMask: number;
  8059. /** @hidden */
  8060. _collideWithWorld(displacement: Vector3): void;
  8061. private _onCollisionPositionChange;
  8062. /** @hidden */
  8063. _checkInputs(): void;
  8064. /** @hidden */
  8065. _decideIfNeedsToMove(): boolean;
  8066. /** @hidden */
  8067. _updatePosition(): void;
  8068. /**
  8069. * Destroy the camera and release the current resources hold by it.
  8070. */
  8071. dispose(): void;
  8072. /**
  8073. * Gets the current object class name.
  8074. * @return the class name
  8075. */
  8076. getClassName(): string;
  8077. }
  8078. }
  8079. declare module BABYLON {
  8080. /**
  8081. * Default Inputs manager for the FreeCamera.
  8082. * It groups all the default supported inputs for ease of use.
  8083. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8084. */
  8085. class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  8086. /**
  8087. * Instantiates a new FreeCameraInputsManager.
  8088. * @param camera Defines the camera the inputs belong to
  8089. */
  8090. constructor(camera: FreeCamera);
  8091. /**
  8092. * Add keyboard input support to the input manager.
  8093. * @returns the current input manager
  8094. */
  8095. addKeyboard(): FreeCameraInputsManager;
  8096. /**
  8097. * Add mouse input support to the input manager.
  8098. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  8099. * @returns the current input manager
  8100. */
  8101. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  8102. /**
  8103. * Add orientation input support to the input manager.
  8104. * @returns the current input manager
  8105. */
  8106. addDeviceOrientation(): FreeCameraInputsManager;
  8107. /**
  8108. * Add touch input support to the input manager.
  8109. * @returns the current input manager
  8110. */
  8111. addTouch(): FreeCameraInputsManager;
  8112. /**
  8113. * Add virtual joystick input support to the input manager.
  8114. * @returns the current input manager
  8115. */
  8116. addVirtualJoystick(): FreeCameraInputsManager;
  8117. }
  8118. }
  8119. declare module BABYLON {
  8120. /**
  8121. * This represents a FPS type of camera. This is only here for back compat purpose.
  8122. * Please use the UniversalCamera instead as both are identical.
  8123. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8124. */
  8125. class GamepadCamera extends UniversalCamera {
  8126. /**
  8127. * Instantiates a new Gamepad Camera
  8128. * This represents a FPS type of camera. This is only here for back compat purpose.
  8129. * Please use the UniversalCamera instead as both are identical.
  8130. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8131. * @param name Define the name of the camera in the scene
  8132. * @param position Define the start position of the camera in the scene
  8133. * @param scene Define the scene the camera belongs to
  8134. */
  8135. constructor(name: string, position: Vector3, scene: Scene);
  8136. /**
  8137. * Gets the current object class name.
  8138. * @return the class name
  8139. */
  8140. getClassName(): string;
  8141. }
  8142. }
  8143. declare module BABYLON {
  8144. /**
  8145. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8146. * This is the base of the follow, arc rotate cameras and Free camera
  8147. * @see http://doc.babylonjs.com/features/cameras
  8148. */
  8149. class TargetCamera extends Camera {
  8150. /**
  8151. * Define the current direction the camera is moving to
  8152. */
  8153. cameraDirection: Vector3;
  8154. /**
  8155. * Define the current rotation the camera is rotating to
  8156. */
  8157. cameraRotation: Vector2;
  8158. /**
  8159. * Define the current rotation of the camera
  8160. */
  8161. rotation: Vector3;
  8162. /**
  8163. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8164. */
  8165. rotationQuaternion: Quaternion;
  8166. /**
  8167. * Define the current speed of the camera
  8168. */
  8169. speed: number;
  8170. /**
  8171. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8172. * around all axis.
  8173. */
  8174. noRotationConstraint: boolean;
  8175. /**
  8176. * Define the current target of the camera as an object or a position.
  8177. */
  8178. lockedTarget: any;
  8179. /** @hidden */
  8180. _currentTarget: Vector3;
  8181. /** @hidden */
  8182. _viewMatrix: Matrix;
  8183. /** @hidden */
  8184. _camMatrix: Matrix;
  8185. /** @hidden */
  8186. _cameraTransformMatrix: Matrix;
  8187. /** @hidden */
  8188. _cameraRotationMatrix: Matrix;
  8189. private _rigCamTransformMatrix;
  8190. /** @hidden */
  8191. _referencePoint: Vector3;
  8192. /** @hidden */
  8193. _transformedReferencePoint: Vector3;
  8194. protected _globalCurrentTarget: Vector3;
  8195. protected _globalCurrentUpVector: Vector3;
  8196. /** @hidden */
  8197. _reset: () => void;
  8198. private _defaultUp;
  8199. /**
  8200. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8201. * This is the base of the follow, arc rotate cameras and Free camera
  8202. * @see http://doc.babylonjs.com/features/cameras
  8203. * @param name Defines the name of the camera in the scene
  8204. * @param position Defines the start position of the camera in the scene
  8205. * @param scene Defines the scene the camera belongs to
  8206. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8207. */
  8208. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8209. /**
  8210. * Gets the position in front of the camera at a given distance.
  8211. * @param distance The distance from the camera we want the position to be
  8212. * @returns the position
  8213. */
  8214. getFrontPosition(distance: number): Vector3;
  8215. /** @hidden */
  8216. _getLockedTargetPosition(): Nullable<Vector3>;
  8217. private _storedPosition;
  8218. private _storedRotation;
  8219. private _storedRotationQuaternion;
  8220. /**
  8221. * Store current camera state of the camera (fov, position, rotation, etc..)
  8222. * @returns the camera
  8223. */
  8224. storeState(): Camera;
  8225. /**
  8226. * Restored camera state. You must call storeState() first
  8227. * @returns whether it was successful or not
  8228. * @hidden
  8229. */
  8230. _restoreStateValues(): boolean;
  8231. /** @hidden */
  8232. _initCache(): void;
  8233. /** @hidden */
  8234. _updateCache(ignoreParentClass?: boolean): void;
  8235. /** @hidden */
  8236. _isSynchronizedViewMatrix(): boolean;
  8237. /** @hidden */
  8238. _computeLocalCameraSpeed(): number;
  8239. /** @hidden */
  8240. setTarget(target: Vector3): void;
  8241. /**
  8242. * Return the current target position of the camera. This value is expressed in local space.
  8243. * @returns the target position
  8244. */
  8245. getTarget(): Vector3;
  8246. /** @hidden */
  8247. _decideIfNeedsToMove(): boolean;
  8248. /** @hidden */
  8249. _updatePosition(): void;
  8250. /** @hidden */
  8251. _checkInputs(): void;
  8252. protected _updateCameraRotationMatrix(): void;
  8253. /**
  8254. * 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)
  8255. * @returns the current camera
  8256. */
  8257. private _rotateUpVectorWithCameraRotationMatrix;
  8258. private _cachedRotationZ;
  8259. private _cachedQuaternionRotationZ;
  8260. /** @hidden */
  8261. _getViewMatrix(): Matrix;
  8262. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8263. /**
  8264. * @hidden
  8265. */
  8266. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8267. /**
  8268. * @hidden
  8269. */
  8270. _updateRigCameras(): void;
  8271. private _getRigCamPosition;
  8272. /**
  8273. * Gets the current object class name.
  8274. * @return the class name
  8275. */
  8276. getClassName(): string;
  8277. }
  8278. }
  8279. declare module BABYLON {
  8280. /**
  8281. * This represents a FPS type of camera controlled by touch.
  8282. * This is like a universal camera minus the Gamepad controls.
  8283. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8284. */
  8285. class TouchCamera extends FreeCamera {
  8286. /**
  8287. * Defines the touch sensibility for rotation.
  8288. * The higher the faster.
  8289. */
  8290. touchAngularSensibility: number;
  8291. /**
  8292. * Defines the touch sensibility for move.
  8293. * The higher the faster.
  8294. */
  8295. touchMoveSensibility: number;
  8296. /**
  8297. * Instantiates a new touch camera.
  8298. * This represents a FPS type of camera controlled by touch.
  8299. * This is like a universal camera minus the Gamepad controls.
  8300. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8301. * @param name Define the name of the camera in the scene
  8302. * @param position Define the start position of the camera in the scene
  8303. * @param scene Define the scene the camera belongs to
  8304. */
  8305. constructor(name: string, position: Vector3, scene: Scene);
  8306. /**
  8307. * Gets the current object class name.
  8308. * @return the class name
  8309. */
  8310. getClassName(): string;
  8311. /** @hidden */
  8312. _setupInputs(): void;
  8313. }
  8314. }
  8315. declare module BABYLON {
  8316. /**
  8317. * 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,
  8318. * which still works and will still be found in many Playgrounds.
  8319. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8320. */
  8321. class UniversalCamera extends TouchCamera {
  8322. /**
  8323. * Defines the gamepad rotation sensiblity.
  8324. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  8325. */
  8326. gamepadAngularSensibility: number;
  8327. /**
  8328. * Defines the gamepad move sensiblity.
  8329. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  8330. */
  8331. gamepadMoveSensibility: number;
  8332. /**
  8333. * 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,
  8334. * which still works and will still be found in many Playgrounds.
  8335. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8336. * @param name Define the name of the camera in the scene
  8337. * @param position Define the start position of the camera in the scene
  8338. * @param scene Define the scene the camera belongs to
  8339. */
  8340. constructor(name: string, position: Vector3, scene: Scene);
  8341. /**
  8342. * Gets the current object class name.
  8343. * @return the class name
  8344. */
  8345. getClassName(): string;
  8346. }
  8347. }
  8348. declare module BABYLON {
  8349. /**
  8350. * This represents a free type of camera. It can be usefull in First Person Shooter game for instance.
  8351. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  8352. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  8353. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  8354. */
  8355. class VirtualJoysticksCamera extends FreeCamera {
  8356. /**
  8357. * Intantiates a VirtualJoysticksCamera. It can be usefull in First Person Shooter game for instance.
  8358. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  8359. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  8360. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  8361. * @param name Define the name of the camera in the scene
  8362. * @param position Define the start position of the camera in the scene
  8363. * @param scene Define the scene the camera belongs to
  8364. */
  8365. constructor(name: string, position: Vector3, scene: Scene);
  8366. /**
  8367. * Gets the current object class name.
  8368. * @return the class name
  8369. */
  8370. getClassName(): string;
  8371. }
  8372. }
  8373. interface VRDisplay extends EventTarget {
  8374. /**
  8375. * Dictionary of capabilities describing the VRDisplay.
  8376. */
  8377. readonly capabilities: VRDisplayCapabilities;
  8378. /**
  8379. * z-depth defining the far plane of the eye view frustum
  8380. * enables mapping of values in the render target depth
  8381. * attachment to scene coordinates. Initially set to 10000.0.
  8382. */
  8383. depthFar: number;
  8384. /**
  8385. * z-depth defining the near plane of the eye view frustum
  8386. * enables mapping of values in the render target depth
  8387. * attachment to scene coordinates. Initially set to 0.01.
  8388. */
  8389. depthNear: number;
  8390. /**
  8391. * An identifier for this distinct VRDisplay. Used as an
  8392. * association point in the Gamepad API.
  8393. */
  8394. readonly displayId: number;
  8395. /**
  8396. * A display name, a user-readable name identifying it.
  8397. */
  8398. readonly displayName: string;
  8399. readonly isConnected: boolean;
  8400. readonly isPresenting: boolean;
  8401. /**
  8402. * If this VRDisplay supports room-scale experiences, the optional
  8403. * stage attribute contains details on the room-scale parameters.
  8404. */
  8405. readonly stageParameters: VRStageParameters | null;
  8406. /**
  8407. * Passing the value returned by `requestAnimationFrame` to
  8408. * `cancelAnimationFrame` will unregister the callback.
  8409. * @param handle Define the hanle of the request to cancel
  8410. */
  8411. cancelAnimationFrame(handle: number): void;
  8412. /**
  8413. * Stops presenting to the VRDisplay.
  8414. * @returns a promise to know when it stopped
  8415. */
  8416. exitPresent(): Promise<void>;
  8417. /**
  8418. * Return the current VREyeParameters for the given eye.
  8419. * @param whichEye Define the eye we want the parameter for
  8420. * @returns the eye parameters
  8421. */
  8422. getEyeParameters(whichEye: string): VREyeParameters;
  8423. /**
  8424. * Populates the passed VRFrameData with the information required to render
  8425. * the current frame.
  8426. * @param frameData Define the data structure to populate
  8427. * @returns true if ok otherwise false
  8428. */
  8429. getFrameData(frameData: VRFrameData): boolean;
  8430. /**
  8431. * Get the layers currently being presented.
  8432. * @returns the list of VR layers
  8433. */
  8434. getLayers(): VRLayer[];
  8435. /**
  8436. * Return a VRPose containing the future predicted pose of the VRDisplay
  8437. * when the current frame will be presented. The value returned will not
  8438. * change until JavaScript has returned control to the browser.
  8439. *
  8440. * The VRPose will contain the position, orientation, velocity,
  8441. * and acceleration of each of these properties.
  8442. * @returns the pose object
  8443. */
  8444. getPose(): VRPose;
  8445. /**
  8446. * Return the current instantaneous pose of the VRDisplay, with no
  8447. * prediction applied.
  8448. * @returns the current instantaneous pose
  8449. */
  8450. getImmediatePose(): VRPose;
  8451. /**
  8452. * The callback passed to `requestAnimationFrame` will be called
  8453. * any time a new frame should be rendered. When the VRDisplay is
  8454. * presenting the callback will be called at the native refresh
  8455. * rate of the HMD. When not presenting this function acts
  8456. * identically to how window.requestAnimationFrame acts. Content should
  8457. * make no assumptions of frame rate or vsync behavior as the HMD runs
  8458. * asynchronously from other displays and at differing refresh rates.
  8459. * @param callback Define the eaction to run next frame
  8460. * @returns the request handle it
  8461. */
  8462. requestAnimationFrame(callback: FrameRequestCallback): number;
  8463. /**
  8464. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  8465. * Repeat calls while already presenting will update the VRLayers being displayed.
  8466. * @param layers Define the list of layer to present
  8467. * @returns a promise to know when the request has been fulfilled
  8468. */
  8469. requestPresent(layers: VRLayer[]): Promise<void>;
  8470. /**
  8471. * Reset the pose for this display, treating its current position and
  8472. * orientation as the "origin/zero" values. VRPose.position,
  8473. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  8474. * updated when calling resetPose(). This should be called in only
  8475. * sitting-space experiences.
  8476. */
  8477. resetPose(): void;
  8478. /**
  8479. * The VRLayer provided to the VRDisplay will be captured and presented
  8480. * in the HMD. Calling this function has the same effect on the source
  8481. * canvas as any other operation that uses its source image, and canvases
  8482. * created without preserveDrawingBuffer set to true will be cleared.
  8483. * @param pose Define the pose to submit
  8484. */
  8485. submitFrame(pose?: VRPose): void;
  8486. }
  8487. declare var VRDisplay: {
  8488. prototype: VRDisplay;
  8489. new (): VRDisplay;
  8490. };
  8491. interface VRLayer {
  8492. leftBounds?: number[] | Float32Array | null;
  8493. rightBounds?: number[] | Float32Array | null;
  8494. source?: HTMLCanvasElement | null;
  8495. }
  8496. interface VRDisplayCapabilities {
  8497. readonly canPresent: boolean;
  8498. readonly hasExternalDisplay: boolean;
  8499. readonly hasOrientation: boolean;
  8500. readonly hasPosition: boolean;
  8501. readonly maxLayers: number;
  8502. }
  8503. interface VREyeParameters {
  8504. /** @deprecated */
  8505. readonly fieldOfView: VRFieldOfView;
  8506. readonly offset: Float32Array;
  8507. readonly renderHeight: number;
  8508. readonly renderWidth: number;
  8509. }
  8510. interface VRFieldOfView {
  8511. readonly downDegrees: number;
  8512. readonly leftDegrees: number;
  8513. readonly rightDegrees: number;
  8514. readonly upDegrees: number;
  8515. }
  8516. interface VRFrameData {
  8517. readonly leftProjectionMatrix: Float32Array;
  8518. readonly leftViewMatrix: Float32Array;
  8519. readonly pose: VRPose;
  8520. readonly rightProjectionMatrix: Float32Array;
  8521. readonly rightViewMatrix: Float32Array;
  8522. readonly timestamp: number;
  8523. }
  8524. interface VRPose {
  8525. readonly angularAcceleration: Float32Array | null;
  8526. readonly angularVelocity: Float32Array | null;
  8527. readonly linearAcceleration: Float32Array | null;
  8528. readonly linearVelocity: Float32Array | null;
  8529. readonly orientation: Float32Array | null;
  8530. readonly position: Float32Array | null;
  8531. readonly timestamp: number;
  8532. }
  8533. interface VRStageParameters {
  8534. sittingToStandingTransform?: Float32Array;
  8535. sizeX?: number;
  8536. sizeY?: number;
  8537. }
  8538. interface Navigator {
  8539. getVRDisplays(): Promise<VRDisplay[]>;
  8540. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  8541. }
  8542. interface Window {
  8543. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  8544. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  8545. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  8546. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  8547. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  8548. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  8549. }
  8550. interface Gamepad {
  8551. readonly displayId: number;
  8552. }
  8553. declare module BABYLON {
  8554. /**
  8555. * Class used to store bounding box information
  8556. */
  8557. class BoundingBox implements ICullable {
  8558. /**
  8559. * Gets the 8 vectors representing the bounding box in local space
  8560. */
  8561. vectors: Vector3[];
  8562. /**
  8563. * Gets the center of the bounding box in local space
  8564. */
  8565. center: Vector3;
  8566. /**
  8567. * Gets the center of the bounding box in world space
  8568. */
  8569. centerWorld: Vector3;
  8570. /**
  8571. * Gets the extend size in local space
  8572. */
  8573. extendSize: Vector3;
  8574. /**
  8575. * Gets the extend size in world space
  8576. */
  8577. extendSizeWorld: Vector3;
  8578. /**
  8579. * Gets the OBB (object bounding box) directions
  8580. */
  8581. directions: Vector3[];
  8582. /**
  8583. * Gets the 8 vectors representing the bounding box in world space
  8584. */
  8585. vectorsWorld: Vector3[];
  8586. /**
  8587. * Gets the minimum vector in world space
  8588. */
  8589. minimumWorld: Vector3;
  8590. /**
  8591. * Gets the maximum vector in world space
  8592. */
  8593. maximumWorld: Vector3;
  8594. /**
  8595. * Gets the minimum vector in local space
  8596. */
  8597. minimum: Vector3;
  8598. /**
  8599. * Gets the maximum vector in local space
  8600. */
  8601. maximum: Vector3;
  8602. private _worldMatrix;
  8603. /**
  8604. * @hidden
  8605. */
  8606. _tag: number;
  8607. /**
  8608. * Creates a new bounding box
  8609. * @param min defines the minimum vector (in local space)
  8610. * @param max defines the maximum vector (in local space)
  8611. * @param worldMatrix defines the new world matrix
  8612. */
  8613. constructor(min: Vector3, max: Vector3, worldMatrix?: Matrix);
  8614. /**
  8615. * Recreates the entire bounding box from scratch
  8616. * @param min defines the new minimum vector (in local space)
  8617. * @param max defines the new maximum vector (in local space)
  8618. * @param worldMatrix defines the new world matrix
  8619. */
  8620. reConstruct(min: Vector3, max: Vector3, worldMatrix?: Matrix): void;
  8621. /**
  8622. * Scale the current bounding box by applying a scale factor
  8623. * @param factor defines the scale factor to apply
  8624. * @returns the current bounding box
  8625. */
  8626. scale(factor: number): BoundingBox;
  8627. /**
  8628. * Gets the world matrix of the bounding box
  8629. * @returns a matrix
  8630. */
  8631. getWorldMatrix(): Matrix;
  8632. /**
  8633. * Sets the world matrix stored in the bounding box
  8634. * @param matrix defines the matrix to store
  8635. * @returns current bounding box
  8636. */
  8637. setWorldMatrix(matrix: Matrix): BoundingBox;
  8638. /** @hidden */
  8639. _update(world: Matrix): void;
  8640. /**
  8641. * Tests if the bounding box is intersecting the frustum planes
  8642. * @param frustumPlanes defines the frustum planes to test
  8643. * @returns true if there is an intersection
  8644. */
  8645. isInFrustum(frustumPlanes: Plane[]): boolean;
  8646. /**
  8647. * Tests if the bounding box is entirely inside the frustum planes
  8648. * @param frustumPlanes defines the frustum planes to test
  8649. * @returns true if there is an inclusion
  8650. */
  8651. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  8652. /**
  8653. * Tests if a point is inside the bounding box
  8654. * @param point defines the point to test
  8655. * @returns true if the point is inside the bounding box
  8656. */
  8657. intersectsPoint(point: Vector3): boolean;
  8658. /**
  8659. * Tests if the bounding box intersects with a bounding sphere
  8660. * @param sphere defines the sphere to test
  8661. * @returns true if there is an intersection
  8662. */
  8663. intersectsSphere(sphere: BoundingSphere): boolean;
  8664. /**
  8665. * Tests if the bounding box intersects with a box defined by a min and max vectors
  8666. * @param min defines the min vector to use
  8667. * @param max defines the max vector to use
  8668. * @returns true if there is an intersection
  8669. */
  8670. intersectsMinMax(min: Vector3, max: Vector3): boolean;
  8671. /**
  8672. * Tests if two bounding boxes are intersections
  8673. * @param box0 defines the first box to test
  8674. * @param box1 defines the second box to test
  8675. * @returns true if there is an intersection
  8676. */
  8677. static Intersects(box0: BoundingBox, box1: BoundingBox): boolean;
  8678. /**
  8679. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  8680. * @param minPoint defines the minimum vector of the bounding box
  8681. * @param maxPoint defines the maximum vector of the bounding box
  8682. * @param sphereCenter defines the sphere center
  8683. * @param sphereRadius defines the sphere radius
  8684. * @returns true if there is an intersection
  8685. */
  8686. static IntersectsSphere(minPoint: Vector3, maxPoint: Vector3, sphereCenter: Vector3, sphereRadius: number): boolean;
  8687. /**
  8688. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  8689. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  8690. * @param frustumPlanes defines the frustum planes to test
  8691. * @return true if there is an inclusion
  8692. */
  8693. static IsCompletelyInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  8694. /**
  8695. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  8696. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  8697. * @param frustumPlanes defines the frustum planes to test
  8698. * @return true if there is an intersection
  8699. */
  8700. static IsInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  8701. }
  8702. }
  8703. declare module BABYLON {
  8704. /**
  8705. * Interface for cullable objects
  8706. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  8707. */
  8708. interface ICullable {
  8709. /**
  8710. * Checks if the object or part of the object is in the frustum
  8711. * @param frustumPlanes Camera near/planes
  8712. * @returns true if the object is in frustum otherwise false
  8713. */
  8714. isInFrustum(frustumPlanes: Plane[]): boolean;
  8715. /**
  8716. * Checks if a cullable object (mesh...) is in the camera frustum
  8717. * Unlike isInFrustum this cheks the full bounding box
  8718. * @param frustumPlanes Camera near/planes
  8719. * @returns true if the object is in frustum otherwise false
  8720. */
  8721. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  8722. }
  8723. /**
  8724. * Info for a bounding data of a mesh
  8725. */
  8726. class BoundingInfo implements ICullable {
  8727. /**
  8728. * Bounding box for the mesh
  8729. */
  8730. boundingBox: BoundingBox;
  8731. /**
  8732. * Bounding sphere for the mesh
  8733. */
  8734. boundingSphere: BoundingSphere;
  8735. private _isLocked;
  8736. /**
  8737. * Constructs bounding info
  8738. * @param minimum min vector of the bounding box/sphere
  8739. * @param maximum max vector of the bounding box/sphere
  8740. * @param worldMatrix defines the new world matrix
  8741. */
  8742. constructor(minimum: Vector3, maximum: Vector3, worldMatrix?: Matrix);
  8743. /**
  8744. * Recreates the entire bounding info from scratch
  8745. * @param min defines the new minimum vector (in local space)
  8746. * @param max defines the new maximum vector (in local space)
  8747. * @param worldMatrix defines the new world matrix
  8748. */
  8749. reConstruct(min: Vector3, max: Vector3, worldMatrix?: Matrix): void;
  8750. /**
  8751. * min vector of the bounding box/sphere
  8752. */
  8753. readonly minimum: Vector3;
  8754. /**
  8755. * max vector of the bounding box/sphere
  8756. */
  8757. readonly maximum: Vector3;
  8758. /**
  8759. * If the info is locked and won't be updated to avoid perf overhead
  8760. */
  8761. isLocked: boolean;
  8762. /**
  8763. * Updates the boudning sphere and box
  8764. * @param world world matrix to be used to update
  8765. */
  8766. update(world: Matrix): void;
  8767. /**
  8768. * Recreate the bounding info to be centered around a specific point given a specific extend.
  8769. * @param center New center of the bounding info
  8770. * @param extend New extend of the bounding info
  8771. * @returns the current bounding info
  8772. */
  8773. centerOn(center: Vector3, extend: Vector3): BoundingInfo;
  8774. /**
  8775. * Scale the current bounding info by applying a scale factor
  8776. * @param factor defines the scale factor to apply
  8777. * @returns the current bounding info
  8778. */
  8779. scale(factor: number): BoundingInfo;
  8780. /**
  8781. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  8782. * @param frustumPlanes defines the frustum to test
  8783. * @param strategy defines the strategy to use for the culling (default is BABYLON.Scene.CULLINGSTRATEGY_STANDARD)
  8784. * @returns true if the bounding info is in the frustum planes
  8785. */
  8786. isInFrustum(frustumPlanes: Plane[], strategy?: number): boolean;
  8787. /**
  8788. * Gets the world distance between the min and max points of the bounding box
  8789. */
  8790. readonly diagonalLength: number;
  8791. /**
  8792. * Checks if a cullable object (mesh...) is in the camera frustum
  8793. * Unlike isInFrustum this cheks the full bounding box
  8794. * @param frustumPlanes Camera near/planes
  8795. * @returns true if the object is in frustum otherwise false
  8796. */
  8797. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  8798. /** @hidden */
  8799. _checkCollision(collider: Collider): boolean;
  8800. /**
  8801. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  8802. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  8803. * @param point the point to check intersection with
  8804. * @returns if the point intersects
  8805. */
  8806. intersectsPoint(point: Vector3): boolean;
  8807. /**
  8808. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  8809. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  8810. * @param boundingInfo the bounding info to check intersection with
  8811. * @param precise if the intersection should be done using OBB
  8812. * @returns if the bounding info intersects
  8813. */
  8814. intersects(boundingInfo: BoundingInfo, precise: boolean): boolean;
  8815. }
  8816. }
  8817. declare module BABYLON {
  8818. /**
  8819. * Class used to store bounding sphere information
  8820. */
  8821. class BoundingSphere {
  8822. /**
  8823. * Gets the center of the bounding sphere in local space
  8824. */
  8825. center: Vector3;
  8826. /**
  8827. * Radius of the bounding sphere in local space
  8828. */
  8829. radius: number;
  8830. /**
  8831. * Gets the center of the bounding sphere in world space
  8832. */
  8833. centerWorld: Vector3;
  8834. /**
  8835. * Radius of the bounding sphere in world space
  8836. */
  8837. radiusWorld: number;
  8838. /**
  8839. * Gets the minimum vector in local space
  8840. */
  8841. minimum: Vector3;
  8842. /**
  8843. * Gets the maximum vector in local space
  8844. */
  8845. maximum: Vector3;
  8846. /**
  8847. * Creates a new bounding sphere
  8848. * @param min defines the minimum vector (in local space)
  8849. * @param max defines the maximum vector (in local space)
  8850. * @param worldMatrix defines the new world matrix
  8851. */
  8852. constructor(min: Vector3, max: Vector3, worldMatrix?: Matrix);
  8853. /**
  8854. * Recreates the entire bounding sphere from scratch
  8855. * @param min defines the new minimum vector (in local space)
  8856. * @param max defines the new maximum vector (in local space)
  8857. * @param worldMatrix defines the new world matrix
  8858. */
  8859. reConstruct(min: Vector3, max: Vector3, worldMatrix?: Matrix): void;
  8860. /**
  8861. * Scale the current bounding sphere by applying a scale factor
  8862. * @param factor defines the scale factor to apply
  8863. * @returns the current bounding box
  8864. */
  8865. scale(factor: number): BoundingSphere;
  8866. /** @hidden */
  8867. _update(world: Matrix): void;
  8868. /**
  8869. * Tests if the bounding sphere is intersecting the frustum planes
  8870. * @param frustumPlanes defines the frustum planes to test
  8871. * @returns true if there is an intersection
  8872. */
  8873. isInFrustum(frustumPlanes: Plane[]): boolean;
  8874. /**
  8875. * Tests if a point is inside the bounding sphere
  8876. * @param point defines the point to test
  8877. * @returns true if the point is inside the bounding sphere
  8878. */
  8879. intersectsPoint(point: Vector3): boolean;
  8880. /**
  8881. * Checks if two sphere intersct
  8882. * @param sphere0 sphere 0
  8883. * @param sphere1 sphere 1
  8884. * @returns true if the speres intersect
  8885. */
  8886. static Intersects(sphere0: BoundingSphere, sphere1: BoundingSphere): boolean;
  8887. }
  8888. }
  8889. declare module BABYLON {
  8890. /**
  8891. * Class representing a ray with position and direction
  8892. */
  8893. class Ray {
  8894. /** origin point */
  8895. origin: Vector3;
  8896. /** direction */
  8897. direction: Vector3;
  8898. /** length of the ray */
  8899. length: number;
  8900. private _edge1;
  8901. private _edge2;
  8902. private _pvec;
  8903. private _tvec;
  8904. private _qvec;
  8905. private _tmpRay;
  8906. /**
  8907. * Creates a new ray
  8908. * @param origin origin point
  8909. * @param direction direction
  8910. * @param length length of the ray
  8911. */
  8912. constructor(
  8913. /** origin point */
  8914. origin: Vector3,
  8915. /** direction */
  8916. direction: Vector3,
  8917. /** length of the ray */
  8918. length?: number);
  8919. /**
  8920. * Checks if the ray intersects a box
  8921. * @param minimum bound of the box
  8922. * @param maximum bound of the box
  8923. * @returns if the box was hit
  8924. */
  8925. intersectsBoxMinMax(minimum: Vector3, maximum: Vector3): boolean;
  8926. /**
  8927. * Checks if the ray intersects a box
  8928. * @param box the bounding box to check
  8929. * @returns if the box was hit
  8930. */
  8931. intersectsBox(box: BoundingBox): boolean;
  8932. /**
  8933. * If the ray hits a sphere
  8934. * @param sphere the bounding sphere to check
  8935. * @returns true if it hits the sphere
  8936. */
  8937. intersectsSphere(sphere: BoundingSphere): boolean;
  8938. /**
  8939. * If the ray hits a triange
  8940. * @param vertex0 triangle vertex
  8941. * @param vertex1 triangle vertex
  8942. * @param vertex2 triangle vertex
  8943. * @returns intersection information if hit
  8944. */
  8945. intersectsTriangle(vertex0: Vector3, vertex1: Vector3, vertex2: Vector3): Nullable<IntersectionInfo>;
  8946. /**
  8947. * Checks if ray intersects a plane
  8948. * @param plane the plane to check
  8949. * @returns the distance away it was hit
  8950. */
  8951. intersectsPlane(plane: Plane): Nullable<number>;
  8952. /**
  8953. * Checks if ray intersects a mesh
  8954. * @param mesh the mesh to check
  8955. * @param fastCheck if only the bounding box should checked
  8956. * @returns picking info of the intersecton
  8957. */
  8958. intersectsMesh(mesh: AbstractMesh, fastCheck?: boolean): PickingInfo;
  8959. /**
  8960. * Checks if ray intersects a mesh
  8961. * @param meshes the meshes to check
  8962. * @param fastCheck if only the bounding box should checked
  8963. * @param results array to store result in
  8964. * @returns Array of picking infos
  8965. */
  8966. intersectsMeshes(meshes: Array<AbstractMesh>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  8967. private _comparePickingInfo;
  8968. private static smallnum;
  8969. private static rayl;
  8970. /**
  8971. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  8972. * @param sega the first point of the segment to test the intersection against
  8973. * @param segb the second point of the segment to test the intersection against
  8974. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  8975. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  8976. */
  8977. intersectionSegment(sega: Vector3, segb: Vector3, threshold: number): number;
  8978. /**
  8979. * Update the ray from viewport position
  8980. * @param x position
  8981. * @param y y position
  8982. * @param viewportWidth viewport width
  8983. * @param viewportHeight viewport height
  8984. * @param world world matrix
  8985. * @param view view matrix
  8986. * @param projection projection matrix
  8987. * @returns this ray updated
  8988. */
  8989. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  8990. /**
  8991. * Creates a ray with origin and direction of 0,0,0
  8992. * @returns the new ray
  8993. */
  8994. static Zero(): Ray;
  8995. /**
  8996. * Creates a new ray from screen space and viewport
  8997. * @param x position
  8998. * @param y y position
  8999. * @param viewportWidth viewport width
  9000. * @param viewportHeight viewport height
  9001. * @param world world matrix
  9002. * @param view view matrix
  9003. * @param projection projection matrix
  9004. * @returns new ray
  9005. */
  9006. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  9007. /**
  9008. * 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
  9009. * transformed to the given world matrix.
  9010. * @param origin The origin point
  9011. * @param end The end point
  9012. * @param world a matrix to transform the ray to. Default is the identity matrix.
  9013. * @returns the new ray
  9014. */
  9015. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: Matrix): Ray;
  9016. /**
  9017. * Transforms a ray by a matrix
  9018. * @param ray ray to transform
  9019. * @param matrix matrix to apply
  9020. * @returns the resulting new ray
  9021. */
  9022. static Transform(ray: Ray, matrix: Matrix): Ray;
  9023. /**
  9024. * Transforms a ray by a matrix
  9025. * @param ray ray to transform
  9026. * @param matrix matrix to apply
  9027. * @param result ray to store result in
  9028. */
  9029. static TransformToRef(ray: Ray, matrix: Matrix, result: Ray): void;
  9030. }
  9031. }
  9032. declare module BABYLON {
  9033. /** @hidden */
  9034. class Collider {
  9035. /** Define if a collision was found */
  9036. collisionFound: boolean;
  9037. /**
  9038. * Define last intersection point in local space
  9039. */
  9040. intersectionPoint: Vector3;
  9041. /**
  9042. * Define last collided mesh
  9043. */
  9044. collidedMesh: Nullable<AbstractMesh>;
  9045. private _collisionPoint;
  9046. private _planeIntersectionPoint;
  9047. private _tempVector;
  9048. private _tempVector2;
  9049. private _tempVector3;
  9050. private _tempVector4;
  9051. private _edge;
  9052. private _baseToVertex;
  9053. private _destinationPoint;
  9054. private _slidePlaneNormal;
  9055. private _displacementVector;
  9056. /** @hidden */
  9057. _radius: Vector3;
  9058. /** @hidden */
  9059. _retry: number;
  9060. private _velocity;
  9061. private _basePoint;
  9062. private _epsilon;
  9063. /** @hidden */
  9064. _velocityWorldLength: number;
  9065. /** @hidden */
  9066. _basePointWorld: Vector3;
  9067. private _velocityWorld;
  9068. private _normalizedVelocity;
  9069. /** @hidden */
  9070. _initialVelocity: Vector3;
  9071. /** @hidden */
  9072. _initialPosition: Vector3;
  9073. private _nearestDistance;
  9074. private _collisionMask;
  9075. collisionMask: number;
  9076. /**
  9077. * Gets the plane normal used to compute the sliding response (in local space)
  9078. */
  9079. readonly slidePlaneNormal: Vector3;
  9080. /** @hidden */
  9081. _initialize(source: Vector3, dir: Vector3, e: number): void;
  9082. /** @hidden */
  9083. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  9084. /** @hidden */
  9085. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  9086. /** @hidden */
  9087. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  9088. /** @hidden */
  9089. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  9090. /** @hidden */
  9091. _getResponse(pos: Vector3, vel: Vector3): void;
  9092. }
  9093. }
  9094. declare module BABYLON {
  9095. /** @hidden */
  9096. var CollisionWorker: string;
  9097. /** @hidden */
  9098. interface ICollisionCoordinator {
  9099. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  9100. init(scene: Scene): void;
  9101. destroy(): void;
  9102. onMeshAdded(mesh: AbstractMesh): void;
  9103. onMeshUpdated(mesh: AbstractMesh): void;
  9104. onMeshRemoved(mesh: AbstractMesh): void;
  9105. onGeometryAdded(geometry: Geometry): void;
  9106. onGeometryUpdated(geometry: Geometry): void;
  9107. onGeometryDeleted(geometry: Geometry): void;
  9108. }
  9109. /** @hidden */
  9110. interface SerializedMesh {
  9111. id: string;
  9112. name: string;
  9113. uniqueId: number;
  9114. geometryId: Nullable<string>;
  9115. sphereCenter: Array<number>;
  9116. sphereRadius: number;
  9117. boxMinimum: Array<number>;
  9118. boxMaximum: Array<number>;
  9119. worldMatrixFromCache: any;
  9120. subMeshes: Array<SerializedSubMesh>;
  9121. checkCollisions: boolean;
  9122. }
  9123. /** @hidden */
  9124. interface SerializedSubMesh {
  9125. position: number;
  9126. verticesStart: number;
  9127. verticesCount: number;
  9128. indexStart: number;
  9129. indexCount: number;
  9130. hasMaterial: boolean;
  9131. sphereCenter: Array<number>;
  9132. sphereRadius: number;
  9133. boxMinimum: Array<number>;
  9134. boxMaximum: Array<number>;
  9135. }
  9136. /**
  9137. * Interface describing the value associated with a geometry.
  9138. * @hidden
  9139. */
  9140. interface SerializedGeometry {
  9141. /**
  9142. * Defines the unique ID of the geometry
  9143. */
  9144. id: string;
  9145. /**
  9146. * Defines the array containing the positions
  9147. */
  9148. positions: Float32Array;
  9149. /**
  9150. * Defines the array containing the indices
  9151. */
  9152. indices: Uint32Array;
  9153. /**
  9154. * Defines the array containing the normals
  9155. */
  9156. normals: Float32Array;
  9157. }
  9158. /** @hidden */
  9159. interface BabylonMessage {
  9160. taskType: WorkerTaskType;
  9161. payload: InitPayload | CollidePayload | UpdatePayload;
  9162. }
  9163. /** @hidden */
  9164. interface SerializedColliderToWorker {
  9165. position: Array<number>;
  9166. velocity: Array<number>;
  9167. radius: Array<number>;
  9168. }
  9169. /** Defines supported task for worker process */
  9170. enum WorkerTaskType {
  9171. /** Initialization */
  9172. INIT = 0,
  9173. /** Update of geometry */
  9174. UPDATE = 1,
  9175. /** Evaluate collision */
  9176. COLLIDE = 2
  9177. }
  9178. /** @hidden */
  9179. interface WorkerReply {
  9180. error: WorkerReplyType;
  9181. taskType: WorkerTaskType;
  9182. payload?: any;
  9183. }
  9184. /** @hidden */
  9185. interface CollisionReplyPayload {
  9186. newPosition: Array<number>;
  9187. collisionId: number;
  9188. collidedMeshUniqueId: number;
  9189. }
  9190. /** @hidden */
  9191. interface InitPayload {
  9192. }
  9193. /** @hidden */
  9194. interface CollidePayload {
  9195. collisionId: number;
  9196. collider: SerializedColliderToWorker;
  9197. maximumRetry: number;
  9198. excludedMeshUniqueId: Nullable<number>;
  9199. }
  9200. /** @hidden */
  9201. interface UpdatePayload {
  9202. updatedMeshes: {
  9203. [n: number]: SerializedMesh;
  9204. };
  9205. updatedGeometries: {
  9206. [s: string]: SerializedGeometry;
  9207. };
  9208. removedMeshes: Array<number>;
  9209. removedGeometries: Array<string>;
  9210. }
  9211. /** Defines kind of replies returned by worker */
  9212. enum WorkerReplyType {
  9213. /** Success */
  9214. SUCCESS = 0,
  9215. /** Unkown error */
  9216. UNKNOWN_ERROR = 1
  9217. }
  9218. /** @hidden */
  9219. class CollisionCoordinatorWorker implements ICollisionCoordinator {
  9220. private _scene;
  9221. private _scaledPosition;
  9222. private _scaledVelocity;
  9223. private _collisionsCallbackArray;
  9224. private _init;
  9225. private _runningUpdated;
  9226. private _worker;
  9227. private _addUpdateMeshesList;
  9228. private _addUpdateGeometriesList;
  9229. private _toRemoveMeshesArray;
  9230. private _toRemoveGeometryArray;
  9231. constructor();
  9232. static SerializeMesh: (mesh: AbstractMesh) => SerializedMesh;
  9233. static SerializeGeometry: (geometry: Geometry) => SerializedGeometry;
  9234. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  9235. init(scene: Scene): void;
  9236. destroy(): void;
  9237. onMeshAdded(mesh: AbstractMesh): void;
  9238. onMeshUpdated: (transformNode: TransformNode) => void;
  9239. onMeshRemoved(mesh: AbstractMesh): void;
  9240. onGeometryAdded(geometry: Geometry): void;
  9241. onGeometryUpdated: (geometry: Geometry) => void;
  9242. onGeometryDeleted(geometry: Geometry): void;
  9243. private _afterRender;
  9244. private _onMessageFromWorker;
  9245. }
  9246. /** @hidden */
  9247. class CollisionCoordinatorLegacy implements ICollisionCoordinator {
  9248. private _scene;
  9249. private _scaledPosition;
  9250. private _scaledVelocity;
  9251. private _finalPosition;
  9252. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  9253. init(scene: Scene): void;
  9254. destroy(): void;
  9255. onMeshAdded(mesh: AbstractMesh): void;
  9256. onMeshUpdated(mesh: AbstractMesh): void;
  9257. onMeshRemoved(mesh: AbstractMesh): void;
  9258. onGeometryAdded(geometry: Geometry): void;
  9259. onGeometryUpdated(geometry: Geometry): void;
  9260. onGeometryDeleted(geometry: Geometry): void;
  9261. private _collideWithWorld;
  9262. }
  9263. }
  9264. declare function importScripts(...urls: string[]): void;
  9265. declare const safePostMessage: any;
  9266. declare module BABYLON {
  9267. /** @hidden */
  9268. var WorkerIncluded: boolean;
  9269. /** @hidden */
  9270. class CollisionCache {
  9271. private _meshes;
  9272. private _geometries;
  9273. getMeshes(): {
  9274. [n: number]: SerializedMesh;
  9275. };
  9276. getGeometries(): {
  9277. [s: number]: SerializedGeometry;
  9278. };
  9279. getMesh(id: any): SerializedMesh;
  9280. addMesh(mesh: SerializedMesh): void;
  9281. removeMesh(uniqueId: number): void;
  9282. getGeometry(id: string): SerializedGeometry;
  9283. addGeometry(geometry: SerializedGeometry): void;
  9284. removeGeometry(id: string): void;
  9285. }
  9286. /** @hidden */
  9287. class CollideWorker {
  9288. collider: Collider;
  9289. private _collisionCache;
  9290. private finalPosition;
  9291. private collisionsScalingMatrix;
  9292. private collisionTranformationMatrix;
  9293. constructor(collider: Collider, _collisionCache: CollisionCache, finalPosition: Vector3);
  9294. collideWithWorld(position: Vector3, velocity: Vector3, maximumRetry: number, excludedMeshUniqueId: Nullable<number>): void;
  9295. private checkCollision;
  9296. private processCollisionsForSubMeshes;
  9297. private collideForSubMesh;
  9298. private checkSubmeshCollision;
  9299. }
  9300. /** @hidden */
  9301. interface ICollisionDetector {
  9302. onInit(payload: InitPayload): void;
  9303. onUpdate(payload: UpdatePayload): void;
  9304. onCollision(payload: CollidePayload): void;
  9305. }
  9306. /** @hidden */
  9307. class CollisionDetectorTransferable implements ICollisionDetector {
  9308. private _collisionCache;
  9309. onInit(payload: InitPayload): void;
  9310. onUpdate(payload: UpdatePayload): void;
  9311. onCollision(payload: CollidePayload): void;
  9312. }
  9313. }
  9314. declare module BABYLON {
  9315. /**
  9316. * @hidden
  9317. */
  9318. class IntersectionInfo {
  9319. bu: Nullable<number>;
  9320. bv: Nullable<number>;
  9321. distance: number;
  9322. faceId: number;
  9323. subMeshId: number;
  9324. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  9325. }
  9326. /**
  9327. * Information about the result of picking within a scene
  9328. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  9329. */
  9330. class PickingInfo {
  9331. /**
  9332. * If the pick collided with an object
  9333. */
  9334. hit: boolean;
  9335. /**
  9336. * Distance away where the pick collided
  9337. */
  9338. distance: number;
  9339. /**
  9340. * The location of pick collision
  9341. */
  9342. pickedPoint: Nullable<Vector3>;
  9343. /**
  9344. * The mesh corresponding the the pick collision
  9345. */
  9346. pickedMesh: Nullable<AbstractMesh>;
  9347. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  9348. bu: number;
  9349. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  9350. bv: number;
  9351. /** The id of the face on the mesh that was picked */
  9352. faceId: number;
  9353. /** Id of the the submesh that was picked */
  9354. subMeshId: number;
  9355. /** If a sprite was picked, this will be the sprite the pick collided with */
  9356. pickedSprite: Nullable<Sprite>;
  9357. /**
  9358. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  9359. */
  9360. originMesh: Nullable<AbstractMesh>;
  9361. /**
  9362. * The ray that was used to perform the picking.
  9363. */
  9364. ray: Nullable<Ray>;
  9365. /**
  9366. * Gets the normal correspodning to the face the pick collided with
  9367. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  9368. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  9369. * @returns The normal correspodning to the face the pick collided with
  9370. */
  9371. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  9372. /**
  9373. * Gets the texture coordinates of where the pick occured
  9374. * @returns the vector containing the coordnates of the texture
  9375. */
  9376. getTextureCoordinates(): Nullable<Vector2>;
  9377. }
  9378. }
  9379. /**
  9380. * Module Debug contains the (visual) components to debug a scene correctly
  9381. */
  9382. declare module BABYLON.Debug {
  9383. /**
  9384. * The Axes viewer will show 3 axes in a specific point in space
  9385. */
  9386. class AxesViewer {
  9387. private _xline;
  9388. private _yline;
  9389. private _zline;
  9390. private _xmesh;
  9391. private _ymesh;
  9392. private _zmesh;
  9393. /**
  9394. * Gets the hosting scene
  9395. */
  9396. scene: Nullable<Scene>;
  9397. /**
  9398. * Gets or sets a number used to scale line length
  9399. */
  9400. scaleLines: number;
  9401. /**
  9402. * Creates a new AxesViewer
  9403. * @param scene defines the hosting scene
  9404. * @param scaleLines defines a number used to scale line length (1 by default)
  9405. */
  9406. constructor(scene: Scene, scaleLines?: number);
  9407. /**
  9408. * Force the viewer to update
  9409. * @param position defines the position of the viewer
  9410. * @param xaxis defines the x axis of the viewer
  9411. * @param yaxis defines the y axis of the viewer
  9412. * @param zaxis defines the z axis of the viewer
  9413. */
  9414. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  9415. /** Releases resources */
  9416. dispose(): void;
  9417. }
  9418. }
  9419. declare module BABYLON.Debug {
  9420. /**
  9421. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  9422. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  9423. */
  9424. class BoneAxesViewer extends AxesViewer {
  9425. /**
  9426. * Gets or sets the target mesh where to display the axes viewer
  9427. */
  9428. mesh: Nullable<Mesh>;
  9429. /**
  9430. * Gets or sets the target bone where to display the axes viewer
  9431. */
  9432. bone: Nullable<Bone>;
  9433. /** Gets current position */
  9434. pos: Vector3;
  9435. /** Gets direction of X axis */
  9436. xaxis: Vector3;
  9437. /** Gets direction of Y axis */
  9438. yaxis: Vector3;
  9439. /** Gets direction of Z axis */
  9440. zaxis: Vector3;
  9441. /**
  9442. * Creates a new BoneAxesViewer
  9443. * @param scene defines the hosting scene
  9444. * @param bone defines the target bone
  9445. * @param mesh defines the target mesh
  9446. * @param scaleLines defines a scaling factor for line length (1 by default)
  9447. */
  9448. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  9449. /**
  9450. * Force the viewer to update
  9451. */
  9452. update(): void;
  9453. /** Releases resources */
  9454. dispose(): void;
  9455. }
  9456. }
  9457. declare module BABYLON {
  9458. interface Scene {
  9459. /**
  9460. * @hidden
  9461. * Backing field
  9462. */
  9463. _debugLayer: DebugLayer;
  9464. /**
  9465. * Gets the debug layer (aka Inspector) associated with the scene
  9466. * @see http://doc.babylonjs.com/features/playground_debuglayer
  9467. */
  9468. debugLayer: DebugLayer;
  9469. }
  9470. /**
  9471. * The debug layer (aka Inspector) is the go to tool in order to better understand
  9472. * what is happening in your scene
  9473. * @see http://doc.babylonjs.com/features/playground_debuglayer
  9474. */
  9475. class DebugLayer {
  9476. /**
  9477. * Define the url to get the inspector script from.
  9478. * By default it uses the babylonjs CDN.
  9479. * @ignoreNaming
  9480. */
  9481. static InspectorURL: string;
  9482. private _scene;
  9483. private _inspector;
  9484. private BJSINSPECTOR;
  9485. /**
  9486. * Observable triggered when a property is changed through the inspector.
  9487. */
  9488. onPropertyChangedObservable: Observable<{
  9489. object: any;
  9490. property: string;
  9491. value: any;
  9492. initialValue: any;
  9493. }>;
  9494. /**
  9495. * Instantiates a new debug layer.
  9496. * The debug layer (aka Inspector) is the go to tool in order to better understand
  9497. * what is happening in your scene
  9498. * @see http://doc.babylonjs.com/features/playground_debuglayer
  9499. * @param scene Defines the scene to inspect
  9500. */
  9501. constructor(scene: Scene);
  9502. /** Creates the inspector window. */
  9503. private _createInspector;
  9504. /**
  9505. * Get if the inspector is visible or not.
  9506. * @returns true if visible otherwise, false
  9507. */
  9508. isVisible(): boolean;
  9509. /**
  9510. * Hide the inspector and close its window.
  9511. */
  9512. hide(): void;
  9513. /**
  9514. *
  9515. * Launch the debugLayer.
  9516. *
  9517. * initialTab:
  9518. * | Value | Tab Name |
  9519. * | --- | --- |
  9520. * | 0 | Scene |
  9521. * | 1 | Console |
  9522. * | 2 | Stats |
  9523. * | 3 | Textures |
  9524. * | 4 | Mesh |
  9525. * | 5 | Light |
  9526. * | 6 | Material |
  9527. * | 7 | GLTF |
  9528. * | 8 | GUI |
  9529. * | 9 | Physics |
  9530. * | 10 | Camera |
  9531. * | 11 | Audio |
  9532. *
  9533. * @param config Define the configuration of the inspector
  9534. */
  9535. show(config?: {
  9536. popup?: boolean;
  9537. initialTab?: number | string;
  9538. parentElement?: HTMLElement;
  9539. newColors?: {
  9540. backgroundColor?: string;
  9541. backgroundColorLighter?: string;
  9542. backgroundColorLighter2?: string;
  9543. backgroundColorLighter3?: string;
  9544. color?: string;
  9545. colorTop?: string;
  9546. colorBot?: string;
  9547. };
  9548. }): void;
  9549. /**
  9550. * Gets the active tab
  9551. * @return the index of the active tab or -1 if the inspector is hidden
  9552. */
  9553. getActiveTab(): number;
  9554. }
  9555. }
  9556. declare module BABYLON.Debug {
  9557. /**
  9558. * Used to show the physics impostor around the specific mesh
  9559. */
  9560. class PhysicsViewer {
  9561. /** @hidden */
  9562. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  9563. /** @hidden */
  9564. protected _meshes: Array<Nullable<AbstractMesh>>;
  9565. /** @hidden */
  9566. protected _scene: Nullable<Scene>;
  9567. /** @hidden */
  9568. protected _numMeshes: number;
  9569. /** @hidden */
  9570. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  9571. private _renderFunction;
  9572. private _debugBoxMesh;
  9573. private _debugSphereMesh;
  9574. private _debugMaterial;
  9575. /**
  9576. * Creates a new PhysicsViewer
  9577. * @param scene defines the hosting scene
  9578. */
  9579. constructor(scene: Scene);
  9580. /** @hidden */
  9581. protected _updateDebugMeshes(): void;
  9582. /**
  9583. * Renders a specified physic impostor
  9584. * @param impostor defines the impostor to render
  9585. */
  9586. showImpostor(impostor: PhysicsImpostor): void;
  9587. /**
  9588. * Hides a specified physic impostor
  9589. * @param impostor defines the impostor to hide
  9590. */
  9591. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  9592. private _getDebugMaterial;
  9593. private _getDebugBoxMesh;
  9594. private _getDebugSphereMesh;
  9595. private _getDebugMesh;
  9596. /** Releases all resources */
  9597. dispose(): void;
  9598. }
  9599. }
  9600. declare module BABYLON {
  9601. /**
  9602. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  9603. * in order to better appreciate the issue one might have.
  9604. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  9605. */
  9606. class RayHelper {
  9607. /**
  9608. * Defines the ray we are currently tryin to visualize.
  9609. */
  9610. ray: Nullable<Ray>;
  9611. private _renderPoints;
  9612. private _renderLine;
  9613. private _renderFunction;
  9614. private _scene;
  9615. private _updateToMeshFunction;
  9616. private _attachedToMesh;
  9617. private _meshSpaceDirection;
  9618. private _meshSpaceOrigin;
  9619. /**
  9620. * Helper function to create a colored helper in a scene in one line.
  9621. * @param ray Defines the ray we are currently tryin to visualize
  9622. * @param scene Defines the scene the ray is used in
  9623. * @param color Defines the color we want to see the ray in
  9624. * @returns The newly created ray helper.
  9625. */
  9626. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  9627. /**
  9628. * Instantiate a new ray helper.
  9629. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  9630. * in order to better appreciate the issue one might have.
  9631. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  9632. * @param ray Defines the ray we are currently tryin to visualize
  9633. */
  9634. constructor(ray: Ray);
  9635. /**
  9636. * Shows the ray we are willing to debug.
  9637. * @param scene Defines the scene the ray needs to be rendered in
  9638. * @param color Defines the color the ray needs to be rendered in
  9639. */
  9640. show(scene: Scene, color?: Color3): void;
  9641. /**
  9642. * Hides the ray we are debugging.
  9643. */
  9644. hide(): void;
  9645. private _render;
  9646. /**
  9647. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  9648. * @param mesh Defines the mesh we want the helper attached to
  9649. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  9650. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  9651. * @param length Defines the length of the ray
  9652. */
  9653. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  9654. /**
  9655. * Detach the ray helper from the mesh it has previously been attached to.
  9656. */
  9657. detachFromMesh(): void;
  9658. private _updateToMesh;
  9659. /**
  9660. * Dispose the helper and release its associated resources.
  9661. */
  9662. dispose(): void;
  9663. }
  9664. }
  9665. declare module BABYLON.Debug {
  9666. /**
  9667. * Class used to render a debug view of a given skeleton
  9668. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  9669. */
  9670. class SkeletonViewer {
  9671. /** defines the skeleton to render */
  9672. skeleton: Skeleton;
  9673. /** defines the mesh attached to the skeleton */
  9674. mesh: AbstractMesh;
  9675. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  9676. autoUpdateBonesMatrices: boolean;
  9677. /** defines the rendering group id to use with the viewer */
  9678. renderingGroupId: number;
  9679. /** Gets or sets the color used to render the skeleton */
  9680. color: Color3;
  9681. private _scene;
  9682. private _debugLines;
  9683. private _debugMesh;
  9684. private _isEnabled;
  9685. private _renderFunction;
  9686. /**
  9687. * Creates a new SkeletonViewer
  9688. * @param skeleton defines the skeleton to render
  9689. * @param mesh defines the mesh attached to the skeleton
  9690. * @param scene defines the hosting scene
  9691. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  9692. * @param renderingGroupId defines the rendering group id to use with the viewer
  9693. */
  9694. constructor(
  9695. /** defines the skeleton to render */
  9696. skeleton: Skeleton,
  9697. /** defines the mesh attached to the skeleton */
  9698. mesh: AbstractMesh, scene: Scene,
  9699. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  9700. autoUpdateBonesMatrices?: boolean,
  9701. /** defines the rendering group id to use with the viewer */
  9702. renderingGroupId?: number);
  9703. /** Gets or sets a boolean indicating if the viewer is enabled */
  9704. isEnabled: boolean;
  9705. private _getBonePosition;
  9706. private _getLinesForBonesWithLength;
  9707. private _getLinesForBonesNoLength;
  9708. /** Update the viewer to sync with current skeleton state */
  9709. update(): void;
  9710. /** Release associated resources */
  9711. dispose(): void;
  9712. }
  9713. }
  9714. declare module BABYLON {
  9715. /**
  9716. * Interface for attribute information associated with buffer instanciation
  9717. */
  9718. class InstancingAttributeInfo {
  9719. /**
  9720. * Index/offset of the attribute in the vertex shader
  9721. */
  9722. index: number;
  9723. /**
  9724. * size of the attribute, 1, 2, 3 or 4
  9725. */
  9726. attributeSize: number;
  9727. /**
  9728. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  9729. * default is FLOAT
  9730. */
  9731. attribyteType: number;
  9732. /**
  9733. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  9734. */
  9735. normalized: boolean;
  9736. /**
  9737. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  9738. */
  9739. offset: number;
  9740. /**
  9741. * Name of the GLSL attribute, for debugging purpose only
  9742. */
  9743. attributeName: string;
  9744. }
  9745. /**
  9746. * Define options used to create a render target texture
  9747. */
  9748. class RenderTargetCreationOptions {
  9749. /**
  9750. * Specifies is mipmaps must be generated
  9751. */
  9752. generateMipMaps?: boolean;
  9753. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  9754. generateDepthBuffer?: boolean;
  9755. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  9756. generateStencilBuffer?: boolean;
  9757. /** Defines texture type (int by default) */
  9758. type?: number;
  9759. /** Defines sampling mode (trilinear by default) */
  9760. samplingMode?: number;
  9761. /** Defines format (RGBA by default) */
  9762. format?: number;
  9763. }
  9764. /**
  9765. * Define options used to create a depth texture
  9766. */
  9767. class DepthTextureCreationOptions {
  9768. /** Specifies whether or not a stencil should be allocated in the texture */
  9769. generateStencil?: boolean;
  9770. /** Specifies whether or not bilinear filtering is enable on the texture */
  9771. bilinearFiltering?: boolean;
  9772. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  9773. comparisonFunction?: number;
  9774. /** Specifies if the created texture is a cube texture */
  9775. isCube?: boolean;
  9776. }
  9777. /**
  9778. * Class used to describe the capabilities of the engine relatively to the current browser
  9779. */
  9780. class EngineCapabilities {
  9781. /** Maximum textures units per fragment shader */
  9782. maxTexturesImageUnits: number;
  9783. /** Maximum texture units per vertex shader */
  9784. maxVertexTextureImageUnits: number;
  9785. /** Maximum textures units in the entire pipeline */
  9786. maxCombinedTexturesImageUnits: number;
  9787. /** Maximum texture size */
  9788. maxTextureSize: number;
  9789. /** Maximum cube texture size */
  9790. maxCubemapTextureSize: number;
  9791. /** Maximum render texture size */
  9792. maxRenderTextureSize: number;
  9793. /** Maximum number of vertex attributes */
  9794. maxVertexAttribs: number;
  9795. /** Maximum number of varyings */
  9796. maxVaryingVectors: number;
  9797. /** Maximum number of uniforms per vertex shader */
  9798. maxVertexUniformVectors: number;
  9799. /** Maximum number of uniforms per fragment shader */
  9800. maxFragmentUniformVectors: number;
  9801. /** Defines if standard derivates (dx/dy) are supported */
  9802. standardDerivatives: boolean;
  9803. /** Defines if s3tc texture compression is supported */
  9804. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  9805. /** Defines if pvrtc texture compression is supported */
  9806. pvrtc: any;
  9807. /** Defines if etc1 texture compression is supported */
  9808. etc1: any;
  9809. /** Defines if etc2 texture compression is supported */
  9810. etc2: any;
  9811. /** Defines if astc texture compression is supported */
  9812. astc: any;
  9813. /** Defines if float textures are supported */
  9814. textureFloat: boolean;
  9815. /** Defines if vertex array objects are supported */
  9816. vertexArrayObject: boolean;
  9817. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  9818. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  9819. /** Gets the maximum level of anisotropy supported */
  9820. maxAnisotropy: number;
  9821. /** Defines if instancing is supported */
  9822. instancedArrays: boolean;
  9823. /** Defines if 32 bits indices are supported */
  9824. uintIndices: boolean;
  9825. /** Defines if high precision shaders are supported */
  9826. highPrecisionShaderSupported: boolean;
  9827. /** Defines if depth reading in the fragment shader is supported */
  9828. fragmentDepthSupported: boolean;
  9829. /** Defines if float texture linear filtering is supported*/
  9830. textureFloatLinearFiltering: boolean;
  9831. /** Defines if rendering to float textures is supported */
  9832. textureFloatRender: boolean;
  9833. /** Defines if half float textures are supported*/
  9834. textureHalfFloat: boolean;
  9835. /** Defines if half float texture linear filtering is supported*/
  9836. textureHalfFloatLinearFiltering: boolean;
  9837. /** Defines if rendering to half float textures is supported */
  9838. textureHalfFloatRender: boolean;
  9839. /** Defines if textureLOD shader command is supported */
  9840. textureLOD: boolean;
  9841. /** Defines if draw buffers extension is supported */
  9842. drawBuffersExtension: boolean;
  9843. /** Defines if depth textures are supported */
  9844. depthTextureExtension: boolean;
  9845. /** Defines if float color buffer are supported */
  9846. colorBufferFloat: boolean;
  9847. /** Gets disjoint timer query extension (null if not supported) */
  9848. timerQuery: EXT_disjoint_timer_query;
  9849. /** Defines if timestamp can be used with timer query */
  9850. canUseTimestampForTimerQuery: boolean;
  9851. /** Function used to let the system compiles shaders in background */
  9852. parallelShaderCompile: {
  9853. MAX_SHADER_COMPILER_THREADS_KHR: number;
  9854. maxShaderCompilerThreadsKHR: (thread: number) => void;
  9855. COMPLETION_STATUS_KHR: number;
  9856. };
  9857. }
  9858. /** Interface defining initialization parameters for Engine class */
  9859. interface EngineOptions extends WebGLContextAttributes {
  9860. /**
  9861. * Defines if the engine should no exceed a specified device ratio
  9862. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  9863. */
  9864. limitDeviceRatio?: number;
  9865. /**
  9866. * Defines if webvr should be enabled automatically
  9867. * @see http://doc.babylonjs.com/how_to/webvr_camera
  9868. */
  9869. autoEnableWebVR?: boolean;
  9870. /**
  9871. * Defines if webgl2 should be turned off even if supported
  9872. * @see http://doc.babylonjs.com/features/webgl2
  9873. */
  9874. disableWebGL2Support?: boolean;
  9875. /**
  9876. * Defines if webaudio should be initialized as well
  9877. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  9878. */
  9879. audioEngine?: boolean;
  9880. /**
  9881. * Defines if animations should run using a deterministic lock step
  9882. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  9883. */
  9884. deterministicLockstep?: boolean;
  9885. /** Defines the maximum steps to use with deterministic lock step mode */
  9886. lockstepMaxSteps?: number;
  9887. /**
  9888. * Defines that engine should ignore context lost events
  9889. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  9890. */
  9891. doNotHandleContextLost?: boolean;
  9892. }
  9893. /**
  9894. * Defines the interface used by display changed events
  9895. */
  9896. interface IDisplayChangedEventArgs {
  9897. /** Gets the vrDisplay object (if any) */
  9898. vrDisplay: Nullable<any>;
  9899. /** Gets a boolean indicating if webVR is supported */
  9900. vrSupported: boolean;
  9901. }
  9902. /**
  9903. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  9904. */
  9905. class Engine {
  9906. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  9907. static ExceptionList: ({
  9908. key: string;
  9909. capture: string;
  9910. captureConstraint: number;
  9911. targets: string[];
  9912. } | {
  9913. key: string;
  9914. capture: null;
  9915. captureConstraint: null;
  9916. targets: string[];
  9917. })[];
  9918. /** Gets the list of created engines */
  9919. static Instances: Engine[];
  9920. /**
  9921. * Gets the latest created engine
  9922. */
  9923. static readonly LastCreatedEngine: Nullable<Engine>;
  9924. /**
  9925. * Gets the latest created scene
  9926. */
  9927. static readonly LastCreatedScene: Nullable<Scene>;
  9928. /**
  9929. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  9930. * @param flag defines which part of the materials must be marked as dirty
  9931. * @param predicate defines a predicate used to filter which materials should be affected
  9932. */
  9933. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  9934. /**
  9935. * Hidden
  9936. */
  9937. static _TextureLoaders: IInternalTextureLoader[];
  9938. /** Defines that alpha blending is disabled */
  9939. static readonly ALPHA_DISABLE: number;
  9940. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  9941. static readonly ALPHA_ADD: number;
  9942. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  9943. static readonly ALPHA_COMBINE: number;
  9944. /** Defines that alpha blending to DEST - SRC * DEST */
  9945. static readonly ALPHA_SUBTRACT: number;
  9946. /** Defines that alpha blending to SRC * DEST */
  9947. static readonly ALPHA_MULTIPLY: number;
  9948. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  9949. static readonly ALPHA_MAXIMIZED: number;
  9950. /** Defines that alpha blending to SRC + DEST */
  9951. static readonly ALPHA_ONEONE: number;
  9952. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  9953. static readonly ALPHA_PREMULTIPLIED: number;
  9954. /**
  9955. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  9956. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  9957. */
  9958. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  9959. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  9960. static readonly ALPHA_INTERPOLATE: number;
  9961. /**
  9962. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  9963. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  9964. */
  9965. static readonly ALPHA_SCREENMODE: number;
  9966. /** Defines that the ressource is not delayed*/
  9967. static readonly DELAYLOADSTATE_NONE: number;
  9968. /** Defines that the ressource was successfully delay loaded */
  9969. static readonly DELAYLOADSTATE_LOADED: number;
  9970. /** Defines that the ressource is currently delay loading */
  9971. static readonly DELAYLOADSTATE_LOADING: number;
  9972. /** Defines that the ressource is delayed and has not started loading */
  9973. static readonly DELAYLOADSTATE_NOTLOADED: number;
  9974. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  9975. static readonly NEVER: number;
  9976. /** 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 */
  9977. static readonly ALWAYS: number;
  9978. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  9979. static readonly LESS: number;
  9980. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  9981. static readonly EQUAL: number;
  9982. /** 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 */
  9983. static readonly LEQUAL: number;
  9984. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  9985. static readonly GREATER: number;
  9986. /** 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 */
  9987. static readonly GEQUAL: number;
  9988. /** 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 */
  9989. static readonly NOTEQUAL: number;
  9990. /** Passed to stencilOperation to specify that stencil value must be kept */
  9991. static readonly KEEP: number;
  9992. /** Passed to stencilOperation to specify that stencil value must be replaced */
  9993. static readonly REPLACE: number;
  9994. /** Passed to stencilOperation to specify that stencil value must be incremented */
  9995. static readonly INCR: number;
  9996. /** Passed to stencilOperation to specify that stencil value must be decremented */
  9997. static readonly DECR: number;
  9998. /** Passed to stencilOperation to specify that stencil value must be inverted */
  9999. static readonly INVERT: number;
  10000. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  10001. static readonly INCR_WRAP: number;
  10002. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  10003. static readonly DECR_WRAP: number;
  10004. /** Texture is not repeating outside of 0..1 UVs */
  10005. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  10006. /** Texture is repeating outside of 0..1 UVs */
  10007. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  10008. /** Texture is repeating and mirrored */
  10009. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  10010. /** ALPHA */
  10011. static readonly TEXTUREFORMAT_ALPHA: number;
  10012. /** LUMINANCE */
  10013. static readonly TEXTUREFORMAT_LUMINANCE: number;
  10014. /** LUMINANCE_ALPHA */
  10015. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  10016. /** RGB */
  10017. static readonly TEXTUREFORMAT_RGB: number;
  10018. /** RGBA */
  10019. static readonly TEXTUREFORMAT_RGBA: number;
  10020. /** RED */
  10021. static readonly TEXTUREFORMAT_RED: number;
  10022. /** RED (2nd reference) */
  10023. static readonly TEXTUREFORMAT_R: number;
  10024. /** RG */
  10025. static readonly TEXTUREFORMAT_RG: number;
  10026. /** RED_INTEGER */
  10027. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  10028. /** RED_INTEGER (2nd reference) */
  10029. static readonly TEXTUREFORMAT_R_INTEGER: number;
  10030. /** RG_INTEGER */
  10031. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  10032. /** RGB_INTEGER */
  10033. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  10034. /** RGBA_INTEGER */
  10035. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  10036. /** UNSIGNED_BYTE */
  10037. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  10038. /** UNSIGNED_BYTE (2nd reference) */
  10039. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  10040. /** FLOAT */
  10041. static readonly TEXTURETYPE_FLOAT: number;
  10042. /** HALF_FLOAT */
  10043. static readonly TEXTURETYPE_HALF_FLOAT: number;
  10044. /** BYTE */
  10045. static readonly TEXTURETYPE_BYTE: number;
  10046. /** SHORT */
  10047. static readonly TEXTURETYPE_SHORT: number;
  10048. /** UNSIGNED_SHORT */
  10049. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  10050. /** INT */
  10051. static readonly TEXTURETYPE_INT: number;
  10052. /** UNSIGNED_INT */
  10053. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  10054. /** UNSIGNED_SHORT_4_4_4_4 */
  10055. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  10056. /** UNSIGNED_SHORT_5_5_5_1 */
  10057. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  10058. /** UNSIGNED_SHORT_5_6_5 */
  10059. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  10060. /** UNSIGNED_INT_2_10_10_10_REV */
  10061. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  10062. /** UNSIGNED_INT_24_8 */
  10063. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  10064. /** UNSIGNED_INT_10F_11F_11F_REV */
  10065. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  10066. /** UNSIGNED_INT_5_9_9_9_REV */
  10067. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  10068. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  10069. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  10070. /** nearest is mag = nearest and min = nearest and mip = linear */
  10071. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  10072. /** Bilinear is mag = linear and min = linear and mip = nearest */
  10073. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  10074. /** Trilinear is mag = linear and min = linear and mip = linear */
  10075. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  10076. /** nearest is mag = nearest and min = nearest and mip = linear */
  10077. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  10078. /** Bilinear is mag = linear and min = linear and mip = nearest */
  10079. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  10080. /** Trilinear is mag = linear and min = linear and mip = linear */
  10081. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  10082. /** mag = nearest and min = nearest and mip = nearest */
  10083. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  10084. /** mag = nearest and min = linear and mip = nearest */
  10085. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  10086. /** mag = nearest and min = linear and mip = linear */
  10087. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  10088. /** mag = nearest and min = linear and mip = none */
  10089. static readonly TEXTURE_NEAREST_LINEAR: number;
  10090. /** mag = nearest and min = nearest and mip = none */
  10091. static readonly TEXTURE_NEAREST_NEAREST: number;
  10092. /** mag = linear and min = nearest and mip = nearest */
  10093. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  10094. /** mag = linear and min = nearest and mip = linear */
  10095. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  10096. /** mag = linear and min = linear and mip = none */
  10097. static readonly TEXTURE_LINEAR_LINEAR: number;
  10098. /** mag = linear and min = nearest and mip = none */
  10099. static readonly TEXTURE_LINEAR_NEAREST: number;
  10100. /** Explicit coordinates mode */
  10101. static readonly TEXTURE_EXPLICIT_MODE: number;
  10102. /** Spherical coordinates mode */
  10103. static readonly TEXTURE_SPHERICAL_MODE: number;
  10104. /** Planar coordinates mode */
  10105. static readonly TEXTURE_PLANAR_MODE: number;
  10106. /** Cubic coordinates mode */
  10107. static readonly TEXTURE_CUBIC_MODE: number;
  10108. /** Projection coordinates mode */
  10109. static readonly TEXTURE_PROJECTION_MODE: number;
  10110. /** Skybox coordinates mode */
  10111. static readonly TEXTURE_SKYBOX_MODE: number;
  10112. /** Inverse Cubic coordinates mode */
  10113. static readonly TEXTURE_INVCUBIC_MODE: number;
  10114. /** Equirectangular coordinates mode */
  10115. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  10116. /** Equirectangular Fixed coordinates mode */
  10117. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  10118. /** Equirectangular Fixed Mirrored coordinates mode */
  10119. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  10120. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  10121. static readonly SCALEMODE_FLOOR: number;
  10122. /** Defines that texture rescaling will look for the nearest power of 2 size */
  10123. static readonly SCALEMODE_NEAREST: number;
  10124. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  10125. static readonly SCALEMODE_CEILING: number;
  10126. /**
  10127. * Returns the current version of the framework
  10128. */
  10129. static readonly Version: string;
  10130. /**
  10131. * Gets or sets the epsilon value used by collision engine
  10132. */
  10133. static CollisionsEpsilon: number;
  10134. /**
  10135. * Gets or sets the relative url used to load code if using the engine in non-minified mode
  10136. */
  10137. static CodeRepository: string;
  10138. /**
  10139. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  10140. */
  10141. static ShadersRepository: string;
  10142. /**
  10143. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  10144. */
  10145. forcePOTTextures: boolean;
  10146. /**
  10147. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  10148. */
  10149. isFullscreen: boolean;
  10150. /**
  10151. * Gets a boolean indicating if the pointer is currently locked
  10152. */
  10153. isPointerLock: boolean;
  10154. /**
  10155. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  10156. */
  10157. cullBackFaces: boolean;
  10158. /**
  10159. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  10160. */
  10161. renderEvenInBackground: boolean;
  10162. /**
  10163. * Gets or sets a boolean indicating that cache can be kept between frames
  10164. */
  10165. preventCacheWipeBetweenFrames: boolean;
  10166. /**
  10167. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  10168. **/
  10169. enableOfflineSupport: boolean;
  10170. /**
  10171. * 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)
  10172. **/
  10173. disableManifestCheck: boolean;
  10174. /**
  10175. * Gets the list of created scenes
  10176. */
  10177. scenes: Scene[];
  10178. /**
  10179. * Gets the list of created postprocesses
  10180. */
  10181. postProcesses: PostProcess[];
  10182. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  10183. validateShaderPrograms: boolean;
  10184. /**
  10185. * Observable event triggered each time the rendering canvas is resized
  10186. */
  10187. onResizeObservable: Observable<Engine>;
  10188. /**
  10189. * Observable event triggered each time the canvas loses focus
  10190. */
  10191. onCanvasBlurObservable: Observable<Engine>;
  10192. /**
  10193. * Observable event triggered each time the canvas gains focus
  10194. */
  10195. onCanvasFocusObservable: Observable<Engine>;
  10196. /**
  10197. * Observable event triggered each time the canvas receives pointerout event
  10198. */
  10199. onCanvasPointerOutObservable: Observable<PointerEvent>;
  10200. /**
  10201. * Observable event triggered before each texture is initialized
  10202. */
  10203. onBeforeTextureInitObservable: Observable<Texture>;
  10204. private _vrDisplay;
  10205. private _vrSupported;
  10206. private _oldSize;
  10207. private _oldHardwareScaleFactor;
  10208. private _vrExclusivePointerMode;
  10209. private _webVRInitPromise;
  10210. /**
  10211. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  10212. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  10213. */
  10214. readonly isInVRExclusivePointerMode: boolean;
  10215. /**
  10216. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  10217. */
  10218. disableUniformBuffers: boolean;
  10219. /** @hidden */
  10220. _uniformBuffers: UniformBuffer[];
  10221. /**
  10222. * Gets a boolean indicating that the engine supports uniform buffers
  10223. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  10224. */
  10225. readonly supportsUniformBuffers: boolean;
  10226. /**
  10227. * Observable raised when the engine begins a new frame
  10228. */
  10229. onBeginFrameObservable: Observable<Engine>;
  10230. /**
  10231. * Observable raised when the engine ends the current frame
  10232. */
  10233. onEndFrameObservable: Observable<Engine>;
  10234. /**
  10235. * Observable raised when the engine is about to compile a shader
  10236. */
  10237. onBeforeShaderCompilationObservable: Observable<Engine>;
  10238. /**
  10239. * Observable raised when the engine has jsut compiled a shader
  10240. */
  10241. onAfterShaderCompilationObservable: Observable<Engine>;
  10242. /** @hidden */
  10243. _gl: WebGLRenderingContext;
  10244. private _renderingCanvas;
  10245. private _windowIsBackground;
  10246. private _webGLVersion;
  10247. /**
  10248. * Gets a boolean indicating that only power of 2 textures are supported
  10249. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  10250. */
  10251. readonly needPOTTextures: boolean;
  10252. /** @hidden */
  10253. _badOS: boolean;
  10254. /** @hidden */
  10255. _badDesktopOS: boolean;
  10256. /**
  10257. * Gets or sets a value indicating if we want to disable texture binding optmization.
  10258. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  10259. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  10260. */
  10261. disableTextureBindingOptimization: boolean;
  10262. /**
  10263. * Gets the audio engine
  10264. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  10265. * @ignorenaming
  10266. */
  10267. static audioEngine: IAudioEngine;
  10268. /**
  10269. * Default AudioEngine Factory responsible of creating the Audio Engine.
  10270. * By default, this will create a BabylonJS Audio Engine if the workload
  10271. * has been embedded.
  10272. */
  10273. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  10274. private _onFocus;
  10275. private _onBlur;
  10276. private _onCanvasPointerOut;
  10277. private _onCanvasBlur;
  10278. private _onCanvasFocus;
  10279. private _onFullscreenChange;
  10280. private _onPointerLockChange;
  10281. private _onVRDisplayPointerRestricted;
  10282. private _onVRDisplayPointerUnrestricted;
  10283. private _onVrDisplayConnect;
  10284. private _onVrDisplayDisconnect;
  10285. private _onVrDisplayPresentChange;
  10286. /**
  10287. * Observable signaled when VR display mode changes
  10288. */
  10289. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  10290. /**
  10291. * Observable signaled when VR request present is complete
  10292. */
  10293. onVRRequestPresentComplete: Observable<boolean>;
  10294. /**
  10295. * Observable signaled when VR request present starts
  10296. */
  10297. onVRRequestPresentStart: Observable<Engine>;
  10298. private _hardwareScalingLevel;
  10299. /** @hidden */
  10300. protected _caps: EngineCapabilities;
  10301. private _pointerLockRequested;
  10302. private _isStencilEnable;
  10303. private _colorWrite;
  10304. private _loadingScreen;
  10305. /** @hidden */
  10306. _drawCalls: PerfCounter;
  10307. /** @hidden */
  10308. _textureCollisions: PerfCounter;
  10309. private _glVersion;
  10310. private _glRenderer;
  10311. private _glVendor;
  10312. private _videoTextureSupported;
  10313. private _renderingQueueLaunched;
  10314. private _activeRenderLoops;
  10315. private _deterministicLockstep;
  10316. private _lockstepMaxSteps;
  10317. /**
  10318. * Observable signaled when a context lost event is raised
  10319. */
  10320. onContextLostObservable: Observable<Engine>;
  10321. /**
  10322. * Observable signaled when a context restored event is raised
  10323. */
  10324. onContextRestoredObservable: Observable<Engine>;
  10325. private _onContextLost;
  10326. private _onContextRestored;
  10327. private _contextWasLost;
  10328. private _doNotHandleContextLost;
  10329. /**
  10330. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  10331. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  10332. */
  10333. doNotHandleContextLost: boolean;
  10334. private _performanceMonitor;
  10335. private _fps;
  10336. private _deltaTime;
  10337. /**
  10338. * Turn this value on if you want to pause FPS computation when in background
  10339. */
  10340. disablePerformanceMonitorInBackground: boolean;
  10341. /**
  10342. * Gets the performance monitor attached to this engine
  10343. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  10344. */
  10345. readonly performanceMonitor: PerformanceMonitor;
  10346. /** @hidden */
  10347. protected _depthCullingState: _DepthCullingState;
  10348. /** @hidden */
  10349. protected _stencilState: _StencilState;
  10350. /** @hidden */
  10351. protected _alphaState: _AlphaState;
  10352. /** @hidden */
  10353. protected _alphaMode: number;
  10354. protected _internalTexturesCache: InternalTexture[];
  10355. /** @hidden */
  10356. protected _activeChannel: number;
  10357. private _currentTextureChannel;
  10358. /** @hidden */
  10359. protected _boundTexturesCache: {
  10360. [key: string]: Nullable<InternalTexture>;
  10361. };
  10362. /** @hidden */
  10363. protected _currentEffect: Nullable<Effect>;
  10364. /** @hidden */
  10365. protected _currentProgram: Nullable<WebGLProgram>;
  10366. private _compiledEffects;
  10367. private _vertexAttribArraysEnabled;
  10368. /** @hidden */
  10369. protected _cachedViewport: Nullable<Viewport>;
  10370. private _cachedVertexArrayObject;
  10371. /** @hidden */
  10372. protected _cachedVertexBuffers: any;
  10373. /** @hidden */
  10374. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  10375. /** @hidden */
  10376. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  10377. /** @hidden */
  10378. protected _currentRenderTarget: Nullable<InternalTexture>;
  10379. private _uintIndicesCurrentlySet;
  10380. private _currentBoundBuffer;
  10381. /** @hidden */
  10382. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  10383. private _currentBufferPointers;
  10384. private _currentInstanceLocations;
  10385. private _currentInstanceBuffers;
  10386. private _textureUnits;
  10387. private _firstBoundInternalTextureTracker;
  10388. private _lastBoundInternalTextureTracker;
  10389. private _workingCanvas;
  10390. private _workingContext;
  10391. private _rescalePostProcess;
  10392. private _dummyFramebuffer;
  10393. private _externalData;
  10394. private _bindedRenderFunction;
  10395. private _vaoRecordInProgress;
  10396. private _mustWipeVertexAttributes;
  10397. private _emptyTexture;
  10398. private _emptyCubeTexture;
  10399. private _emptyTexture3D;
  10400. private _frameHandler;
  10401. private _nextFreeTextureSlots;
  10402. private _maxSimultaneousTextures;
  10403. private _activeRequests;
  10404. private _texturesSupported;
  10405. private _textureFormatInUse;
  10406. /**
  10407. * Gets the list of texture formats supported
  10408. */
  10409. readonly texturesSupported: Array<string>;
  10410. /**
  10411. * Gets the list of texture formats in use
  10412. */
  10413. readonly textureFormatInUse: Nullable<string>;
  10414. /**
  10415. * Gets the current viewport
  10416. */
  10417. readonly currentViewport: Nullable<Viewport>;
  10418. /**
  10419. * Gets the default empty texture
  10420. */
  10421. readonly emptyTexture: InternalTexture;
  10422. /**
  10423. * Gets the default empty 3D texture
  10424. */
  10425. readonly emptyTexture3D: InternalTexture;
  10426. /**
  10427. * Gets the default empty cube texture
  10428. */
  10429. readonly emptyCubeTexture: InternalTexture;
  10430. /**
  10431. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  10432. */
  10433. readonly premultipliedAlpha: boolean;
  10434. /**
  10435. * Creates a new engine
  10436. * @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
  10437. * @param antialias defines enable antialiasing (default: false)
  10438. * @param options defines further options to be sent to the getContext() function
  10439. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  10440. */
  10441. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  10442. private _rebuildInternalTextures;
  10443. private _rebuildEffects;
  10444. /**
  10445. * Gets a boolean indicating if all created effects are ready
  10446. * @returns true if all effects are ready
  10447. */
  10448. areAllEffectsReady(): boolean;
  10449. private _rebuildBuffers;
  10450. private _initGLContext;
  10451. /**
  10452. * Gets version of the current webGL context
  10453. */
  10454. readonly webGLVersion: number;
  10455. /**
  10456. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  10457. */
  10458. readonly isStencilEnable: boolean;
  10459. private _prepareWorkingCanvas;
  10460. /**
  10461. * Reset the texture cache to empty state
  10462. */
  10463. resetTextureCache(): void;
  10464. /**
  10465. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  10466. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  10467. * @returns true if engine is in deterministic lock step mode
  10468. */
  10469. isDeterministicLockStep(): boolean;
  10470. /**
  10471. * Gets the max steps when engine is running in deterministic lock step
  10472. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  10473. * @returns the max steps
  10474. */
  10475. getLockstepMaxSteps(): number;
  10476. /**
  10477. * Gets an object containing information about the current webGL context
  10478. * @returns an object containing the vender, the renderer and the version of the current webGL context
  10479. */
  10480. getGlInfo(): {
  10481. vendor: string;
  10482. renderer: string;
  10483. version: string;
  10484. };
  10485. /**
  10486. * Gets current aspect ratio
  10487. * @param camera defines the camera to use to get the aspect ratio
  10488. * @param useScreen defines if screen size must be used (or the current render target if any)
  10489. * @returns a number defining the aspect ratio
  10490. */
  10491. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  10492. /**
  10493. * Gets current screen aspect ratio
  10494. * @returns a number defining the aspect ratio
  10495. */
  10496. getScreenAspectRatio(): number;
  10497. /**
  10498. * Gets the current render width
  10499. * @param useScreen defines if screen size must be used (or the current render target if any)
  10500. * @returns a number defining the current render width
  10501. */
  10502. getRenderWidth(useScreen?: boolean): number;
  10503. /**
  10504. * Gets the current render height
  10505. * @param useScreen defines if screen size must be used (or the current render target if any)
  10506. * @returns a number defining the current render height
  10507. */
  10508. getRenderHeight(useScreen?: boolean): number;
  10509. /**
  10510. * Gets the HTML canvas attached with the current webGL context
  10511. * @returns a HTML canvas
  10512. */
  10513. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  10514. /**
  10515. * Gets the client rect of the HTML canvas attached with the current webGL context
  10516. * @returns a client rectanglee
  10517. */
  10518. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  10519. /**
  10520. * Defines the hardware scaling level.
  10521. * By default the hardware scaling level is computed from the window device ratio.
  10522. * 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.
  10523. * @param level defines the level to use
  10524. */
  10525. setHardwareScalingLevel(level: number): void;
  10526. /**
  10527. * Gets the current hardware scaling level.
  10528. * By default the hardware scaling level is computed from the window device ratio.
  10529. * 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.
  10530. * @returns a number indicating the current hardware scaling level
  10531. */
  10532. getHardwareScalingLevel(): number;
  10533. /**
  10534. * Gets the list of loaded textures
  10535. * @returns an array containing all loaded textures
  10536. */
  10537. getLoadedTexturesCache(): InternalTexture[];
  10538. /**
  10539. * Gets the object containing all engine capabilities
  10540. * @returns the EngineCapabilities object
  10541. */
  10542. getCaps(): EngineCapabilities;
  10543. /** @hidden */
  10544. readonly drawCalls: number;
  10545. /** @hidden */
  10546. readonly drawCallsPerfCounter: Nullable<PerfCounter>;
  10547. /**
  10548. * Gets the current depth function
  10549. * @returns a number defining the depth function
  10550. */
  10551. getDepthFunction(): Nullable<number>;
  10552. /**
  10553. * Sets the current depth function
  10554. * @param depthFunc defines the function to use
  10555. */
  10556. setDepthFunction(depthFunc: number): void;
  10557. /**
  10558. * Sets the current depth function to GREATER
  10559. */
  10560. setDepthFunctionToGreater(): void;
  10561. /**
  10562. * Sets the current depth function to GEQUAL
  10563. */
  10564. setDepthFunctionToGreaterOrEqual(): void;
  10565. /**
  10566. * Sets the current depth function to LESS
  10567. */
  10568. setDepthFunctionToLess(): void;
  10569. /**
  10570. * Sets the current depth function to LEQUAL
  10571. */
  10572. setDepthFunctionToLessOrEqual(): void;
  10573. /**
  10574. * Gets a boolean indicating if stencil buffer is enabled
  10575. * @returns the current stencil buffer state
  10576. */
  10577. getStencilBuffer(): boolean;
  10578. /**
  10579. * Enable or disable the stencil buffer
  10580. * @param enable defines if the stencil buffer must be enabled or disabled
  10581. */
  10582. setStencilBuffer(enable: boolean): void;
  10583. /**
  10584. * Gets the current stencil mask
  10585. * @returns a number defining the new stencil mask to use
  10586. */
  10587. getStencilMask(): number;
  10588. /**
  10589. * Sets the current stencil mask
  10590. * @param mask defines the new stencil mask to use
  10591. */
  10592. setStencilMask(mask: number): void;
  10593. /**
  10594. * Gets the current stencil function
  10595. * @returns a number defining the stencil function to use
  10596. */
  10597. getStencilFunction(): number;
  10598. /**
  10599. * Gets the current stencil reference value
  10600. * @returns a number defining the stencil reference value to use
  10601. */
  10602. getStencilFunctionReference(): number;
  10603. /**
  10604. * Gets the current stencil mask
  10605. * @returns a number defining the stencil mask to use
  10606. */
  10607. getStencilFunctionMask(): number;
  10608. /**
  10609. * Sets the current stencil function
  10610. * @param stencilFunc defines the new stencil function to use
  10611. */
  10612. setStencilFunction(stencilFunc: number): void;
  10613. /**
  10614. * Sets the current stencil reference
  10615. * @param reference defines the new stencil reference to use
  10616. */
  10617. setStencilFunctionReference(reference: number): void;
  10618. /**
  10619. * Sets the current stencil mask
  10620. * @param mask defines the new stencil mask to use
  10621. */
  10622. setStencilFunctionMask(mask: number): void;
  10623. /**
  10624. * Gets the current stencil operation when stencil fails
  10625. * @returns a number defining stencil operation to use when stencil fails
  10626. */
  10627. getStencilOperationFail(): number;
  10628. /**
  10629. * Gets the current stencil operation when depth fails
  10630. * @returns a number defining stencil operation to use when depth fails
  10631. */
  10632. getStencilOperationDepthFail(): number;
  10633. /**
  10634. * Gets the current stencil operation when stencil passes
  10635. * @returns a number defining stencil operation to use when stencil passes
  10636. */
  10637. getStencilOperationPass(): number;
  10638. /**
  10639. * Sets the stencil operation to use when stencil fails
  10640. * @param operation defines the stencil operation to use when stencil fails
  10641. */
  10642. setStencilOperationFail(operation: number): void;
  10643. /**
  10644. * Sets the stencil operation to use when depth fails
  10645. * @param operation defines the stencil operation to use when depth fails
  10646. */
  10647. setStencilOperationDepthFail(operation: number): void;
  10648. /**
  10649. * Sets the stencil operation to use when stencil passes
  10650. * @param operation defines the stencil operation to use when stencil passes
  10651. */
  10652. setStencilOperationPass(operation: number): void;
  10653. /**
  10654. * Sets a boolean indicating if the dithering state is enabled or disabled
  10655. * @param value defines the dithering state
  10656. */
  10657. setDitheringState(value: boolean): void;
  10658. /**
  10659. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  10660. * @param value defines the rasterizer state
  10661. */
  10662. setRasterizerState(value: boolean): void;
  10663. /**
  10664. * stop executing a render loop function and remove it from the execution array
  10665. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  10666. */
  10667. stopRenderLoop(renderFunction?: () => void): void;
  10668. /** @hidden */
  10669. _renderLoop(): void;
  10670. /**
  10671. * Register and execute a render loop. The engine can have more than one render function
  10672. * @param renderFunction defines the function to continuously execute
  10673. */
  10674. runRenderLoop(renderFunction: () => void): void;
  10675. /**
  10676. * Toggle full screen mode
  10677. * @param requestPointerLock defines if a pointer lock should be requested from the user
  10678. */
  10679. switchFullscreen(requestPointerLock: boolean): void;
  10680. /**
  10681. * Clear the current render buffer or the current render target (if any is set up)
  10682. * @param color defines the color to use
  10683. * @param backBuffer defines if the back buffer must be cleared
  10684. * @param depth defines if the depth buffer must be cleared
  10685. * @param stencil defines if the stencil buffer must be cleared
  10686. */
  10687. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  10688. /**
  10689. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  10690. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  10691. * @param y defines the y-coordinate of the corner of the clear rectangle
  10692. * @param width defines the width of the clear rectangle
  10693. * @param height defines the height of the clear rectangle
  10694. * @param clearColor defines the clear color
  10695. */
  10696. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  10697. private _viewportCached;
  10698. /** @hidden */
  10699. _viewport(x: number, y: number, width: number, height: number): void;
  10700. /**
  10701. * Set the WebGL's viewport
  10702. * @param viewport defines the viewport element to be used
  10703. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  10704. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  10705. */
  10706. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  10707. /**
  10708. * Directly set the WebGL Viewport
  10709. * @param x defines the x coordinate of the viewport (in screen space)
  10710. * @param y defines the y coordinate of the viewport (in screen space)
  10711. * @param width defines the width of the viewport (in screen space)
  10712. * @param height defines the height of the viewport (in screen space)
  10713. * @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
  10714. */
  10715. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  10716. /**
  10717. * Begin a new frame
  10718. */
  10719. beginFrame(): void;
  10720. /**
  10721. * Enf the current frame
  10722. */
  10723. endFrame(): void;
  10724. /**
  10725. * Resize the view according to the canvas' size
  10726. */
  10727. resize(): void;
  10728. /**
  10729. * Force a specific size of the canvas
  10730. * @param width defines the new canvas' width
  10731. * @param height defines the new canvas' height
  10732. */
  10733. setSize(width: number, height: number): void;
  10734. /**
  10735. * Gets a boolean indicating if a webVR device was detected
  10736. * @returns true if a webVR device was detected
  10737. */
  10738. isVRDevicePresent(): boolean;
  10739. /**
  10740. * Gets the current webVR device
  10741. * @returns the current webVR device (or null)
  10742. */
  10743. getVRDevice(): any;
  10744. /**
  10745. * Initializes a webVR display and starts listening to display change events
  10746. * The onVRDisplayChangedObservable will be notified upon these changes
  10747. * @returns The onVRDisplayChangedObservable
  10748. */
  10749. initWebVR(): Observable<IDisplayChangedEventArgs>;
  10750. /**
  10751. * Initializes a webVR display and starts listening to display change events
  10752. * The onVRDisplayChangedObservable will be notified upon these changes
  10753. * @returns A promise containing a VRDisplay and if vr is supported
  10754. */
  10755. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  10756. /**
  10757. * Call this function to switch to webVR mode
  10758. * Will do nothing if webVR is not supported or if there is no webVR device
  10759. * @see http://doc.babylonjs.com/how_to/webvr_camera
  10760. */
  10761. enableVR(): void;
  10762. /**
  10763. * Call this function to leave webVR mode
  10764. * Will do nothing if webVR is not supported or if there is no webVR device
  10765. * @see http://doc.babylonjs.com/how_to/webvr_camera
  10766. */
  10767. disableVR(): void;
  10768. private _onVRFullScreenTriggered;
  10769. private _getVRDisplaysAsync;
  10770. /**
  10771. * Binds the frame buffer to the specified texture.
  10772. * @param texture The texture to render to or null for the default canvas
  10773. * @param faceIndex The face of the texture to render to in case of cube texture
  10774. * @param requiredWidth The width of the target to render to
  10775. * @param requiredHeight The height of the target to render to
  10776. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  10777. * @param depthStencilTexture The depth stencil texture to use to render
  10778. * @param lodLevel defines le lod level to bind to the frame buffer
  10779. */
  10780. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  10781. private bindUnboundFramebuffer;
  10782. /**
  10783. * Unbind the current render target texture from the webGL context
  10784. * @param texture defines the render target texture to unbind
  10785. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  10786. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  10787. */
  10788. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  10789. /**
  10790. * Unbind a list of render target textures from the webGL context
  10791. * This is used only when drawBuffer extension or webGL2 are active
  10792. * @param textures defines the render target textures to unbind
  10793. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  10794. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  10795. */
  10796. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  10797. /**
  10798. * Force the mipmap generation for the given render target texture
  10799. * @param texture defines the render target texture to use
  10800. */
  10801. generateMipMapsForCubemap(texture: InternalTexture): void;
  10802. /**
  10803. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  10804. */
  10805. flushFramebuffer(): void;
  10806. /**
  10807. * Unbind the current render target and bind the default framebuffer
  10808. */
  10809. restoreDefaultFramebuffer(): void;
  10810. /**
  10811. * Create an uniform buffer
  10812. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  10813. * @param elements defines the content of the uniform buffer
  10814. * @returns the webGL uniform buffer
  10815. */
  10816. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  10817. /**
  10818. * Create a dynamic uniform buffer
  10819. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  10820. * @param elements defines the content of the uniform buffer
  10821. * @returns the webGL uniform buffer
  10822. */
  10823. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  10824. /**
  10825. * Update an existing uniform buffer
  10826. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  10827. * @param uniformBuffer defines the target uniform buffer
  10828. * @param elements defines the content to update
  10829. * @param offset defines the offset in the uniform buffer where update should start
  10830. * @param count defines the size of the data to update
  10831. */
  10832. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  10833. private _resetVertexBufferBinding;
  10834. /**
  10835. * Creates a vertex buffer
  10836. * @param data the data for the vertex buffer
  10837. * @returns the new WebGL static buffer
  10838. */
  10839. createVertexBuffer(data: DataArray): WebGLBuffer;
  10840. /**
  10841. * Creates a dynamic vertex buffer
  10842. * @param data the data for the dynamic vertex buffer
  10843. * @returns the new WebGL dynamic buffer
  10844. */
  10845. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  10846. /**
  10847. * Update a dynamic index buffer
  10848. * @param indexBuffer defines the target index buffer
  10849. * @param indices defines the data to update
  10850. * @param offset defines the offset in the target index buffer where update should start
  10851. */
  10852. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  10853. /**
  10854. * Updates a dynamic vertex buffer.
  10855. * @param vertexBuffer the vertex buffer to update
  10856. * @param data the data used to update the vertex buffer
  10857. * @param byteOffset the byte offset of the data
  10858. * @param byteLength the byte length of the data
  10859. */
  10860. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  10861. private _resetIndexBufferBinding;
  10862. /**
  10863. * Creates a new index buffer
  10864. * @param indices defines the content of the index buffer
  10865. * @param updatable defines if the index buffer must be updatable
  10866. * @returns a new webGL buffer
  10867. */
  10868. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  10869. /**
  10870. * Bind a webGL buffer to the webGL context
  10871. * @param buffer defines the buffer to bind
  10872. */
  10873. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  10874. /**
  10875. * Bind an uniform buffer to the current webGL context
  10876. * @param buffer defines the buffer to bind
  10877. */
  10878. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  10879. /**
  10880. * Bind a buffer to the current webGL context at a given location
  10881. * @param buffer defines the buffer to bind
  10882. * @param location defines the index where to bind the buffer
  10883. */
  10884. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  10885. /**
  10886. * Bind a specific block at a given index in a specific shader program
  10887. * @param shaderProgram defines the shader program
  10888. * @param blockName defines the block name
  10889. * @param index defines the index where to bind the block
  10890. */
  10891. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  10892. private bindIndexBuffer;
  10893. private bindBuffer;
  10894. /**
  10895. * update the bound buffer with the given data
  10896. * @param data defines the data to update
  10897. */
  10898. updateArrayBuffer(data: Float32Array): void;
  10899. private _vertexAttribPointer;
  10900. private _bindIndexBufferWithCache;
  10901. private _bindVertexBuffersAttributes;
  10902. /**
  10903. * Records a vertex array object
  10904. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  10905. * @param vertexBuffers defines the list of vertex buffers to store
  10906. * @param indexBuffer defines the index buffer to store
  10907. * @param effect defines the effect to store
  10908. * @returns the new vertex array object
  10909. */
  10910. recordVertexArrayObject(vertexBuffers: {
  10911. [key: string]: VertexBuffer;
  10912. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  10913. /**
  10914. * Bind a specific vertex array object
  10915. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  10916. * @param vertexArrayObject defines the vertex array object to bind
  10917. * @param indexBuffer defines the index buffer to bind
  10918. */
  10919. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  10920. /**
  10921. * Bind webGl buffers directly to the webGL context
  10922. * @param vertexBuffer defines the vertex buffer to bind
  10923. * @param indexBuffer defines the index buffer to bind
  10924. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  10925. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  10926. * @param effect defines the effect associated with the vertex buffer
  10927. */
  10928. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  10929. private _unbindVertexArrayObject;
  10930. /**
  10931. * Bind a list of vertex buffers to the webGL context
  10932. * @param vertexBuffers defines the list of vertex buffers to bind
  10933. * @param indexBuffer defines the index buffer to bind
  10934. * @param effect defines the effect associated with the vertex buffers
  10935. */
  10936. bindBuffers(vertexBuffers: {
  10937. [key: string]: Nullable<VertexBuffer>;
  10938. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  10939. /**
  10940. * Unbind all instance attributes
  10941. */
  10942. unbindInstanceAttributes(): void;
  10943. /**
  10944. * Release and free the memory of a vertex array object
  10945. * @param vao defines the vertex array object to delete
  10946. */
  10947. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  10948. /** @hidden */
  10949. _releaseBuffer(buffer: WebGLBuffer): boolean;
  10950. /**
  10951. * Creates a webGL buffer to use with instanciation
  10952. * @param capacity defines the size of the buffer
  10953. * @returns the webGL buffer
  10954. */
  10955. createInstancesBuffer(capacity: number): WebGLBuffer;
  10956. /**
  10957. * Delete a webGL buffer used with instanciation
  10958. * @param buffer defines the webGL buffer to delete
  10959. */
  10960. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  10961. /**
  10962. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  10963. * @param instancesBuffer defines the webGL buffer to update and bind
  10964. * @param data defines the data to store in the buffer
  10965. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  10966. */
  10967. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  10968. /**
  10969. * Apply all cached states (depth, culling, stencil and alpha)
  10970. */
  10971. applyStates(): void;
  10972. /**
  10973. * Send a draw order
  10974. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  10975. * @param indexStart defines the starting index
  10976. * @param indexCount defines the number of index to draw
  10977. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  10978. */
  10979. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  10980. /**
  10981. * Draw a list of points
  10982. * @param verticesStart defines the index of first vertex to draw
  10983. * @param verticesCount defines the count of vertices to draw
  10984. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  10985. */
  10986. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  10987. /**
  10988. * Draw a list of unindexed primitives
  10989. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  10990. * @param verticesStart defines the index of first vertex to draw
  10991. * @param verticesCount defines the count of vertices to draw
  10992. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  10993. */
  10994. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  10995. /**
  10996. * Draw a list of indexed primitives
  10997. * @param fillMode defines the primitive to use
  10998. * @param indexStart defines the starting index
  10999. * @param indexCount defines the number of index to draw
  11000. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11001. */
  11002. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  11003. /**
  11004. * Draw a list of unindexed primitives
  11005. * @param fillMode defines the primitive to use
  11006. * @param verticesStart defines the index of first vertex to draw
  11007. * @param verticesCount defines the count of vertices to draw
  11008. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11009. */
  11010. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  11011. private _drawMode;
  11012. /** @hidden */
  11013. _releaseEffect(effect: Effect): void;
  11014. /** @hidden */
  11015. _deleteProgram(program: WebGLProgram): void;
  11016. /**
  11017. * Create a new effect (used to store vertex/fragment shaders)
  11018. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  11019. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  11020. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  11021. * @param samplers defines an array of string used to represent textures
  11022. * @param defines defines the string containing the defines to use to compile the shaders
  11023. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  11024. * @param onCompiled defines a function to call when the effect creation is successful
  11025. * @param onError defines a function to call when the effect creation has failed
  11026. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  11027. * @returns the new Effect
  11028. */
  11029. 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;
  11030. private _compileShader;
  11031. private _compileRawShader;
  11032. /**
  11033. * Directly creates a webGL program
  11034. * @param vertexCode defines the vertex shader code to use
  11035. * @param fragmentCode defines the fragment shader code to use
  11036. * @param context defines the webGL context to use (if not set, the current one will be used)
  11037. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  11038. * @returns the new webGL program
  11039. */
  11040. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  11041. /**
  11042. * Creates a webGL program
  11043. * @param vertexCode defines the vertex shader code to use
  11044. * @param fragmentCode defines the fragment shader code to use
  11045. * @param defines defines the string containing the defines to use to compile the shaders
  11046. * @param context defines the webGL context to use (if not set, the current one will be used)
  11047. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  11048. * @returns the new webGL program
  11049. */
  11050. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  11051. private _createShaderProgram;
  11052. private _finalizeProgram;
  11053. /** @hidden */
  11054. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  11055. /** @hidden */
  11056. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  11057. /**
  11058. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  11059. * @param shaderProgram defines the webGL program to use
  11060. * @param uniformsNames defines the list of uniform names
  11061. * @returns an array of webGL uniform locations
  11062. */
  11063. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  11064. /**
  11065. * Gets the lsit of active attributes for a given webGL program
  11066. * @param shaderProgram defines the webGL program to use
  11067. * @param attributesNames defines the list of attribute names to get
  11068. * @returns an array of indices indicating the offset of each attribute
  11069. */
  11070. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  11071. /**
  11072. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  11073. * @param effect defines the effect to activate
  11074. */
  11075. enableEffect(effect: Nullable<Effect>): void;
  11076. /**
  11077. * Set the value of an uniform to an array of int32
  11078. * @param uniform defines the webGL uniform location where to store the value
  11079. * @param array defines the array of int32 to store
  11080. */
  11081. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  11082. /**
  11083. * Set the value of an uniform to an array of int32 (stored as vec2)
  11084. * @param uniform defines the webGL uniform location where to store the value
  11085. * @param array defines the array of int32 to store
  11086. */
  11087. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  11088. /**
  11089. * Set the value of an uniform to an array of int32 (stored as vec3)
  11090. * @param uniform defines the webGL uniform location where to store the value
  11091. * @param array defines the array of int32 to store
  11092. */
  11093. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  11094. /**
  11095. * Set the value of an uniform to an array of int32 (stored as vec4)
  11096. * @param uniform defines the webGL uniform location where to store the value
  11097. * @param array defines the array of int32 to store
  11098. */
  11099. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  11100. /**
  11101. * Set the value of an uniform to an array of float32
  11102. * @param uniform defines the webGL uniform location where to store the value
  11103. * @param array defines the array of float32 to store
  11104. */
  11105. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  11106. /**
  11107. * Set the value of an uniform to an array of float32 (stored as vec2)
  11108. * @param uniform defines the webGL uniform location where to store the value
  11109. * @param array defines the array of float32 to store
  11110. */
  11111. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  11112. /**
  11113. * Set the value of an uniform to an array of float32 (stored as vec3)
  11114. * @param uniform defines the webGL uniform location where to store the value
  11115. * @param array defines the array of float32 to store
  11116. */
  11117. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  11118. /**
  11119. * Set the value of an uniform to an array of float32 (stored as vec4)
  11120. * @param uniform defines the webGL uniform location where to store the value
  11121. * @param array defines the array of float32 to store
  11122. */
  11123. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  11124. /**
  11125. * Set the value of an uniform to an array of number
  11126. * @param uniform defines the webGL uniform location where to store the value
  11127. * @param array defines the array of number to store
  11128. */
  11129. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  11130. /**
  11131. * Set the value of an uniform to an array of number (stored as vec2)
  11132. * @param uniform defines the webGL uniform location where to store the value
  11133. * @param array defines the array of number to store
  11134. */
  11135. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  11136. /**
  11137. * Set the value of an uniform to an array of number (stored as vec3)
  11138. * @param uniform defines the webGL uniform location where to store the value
  11139. * @param array defines the array of number to store
  11140. */
  11141. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  11142. /**
  11143. * Set the value of an uniform to an array of number (stored as vec4)
  11144. * @param uniform defines the webGL uniform location where to store the value
  11145. * @param array defines the array of number to store
  11146. */
  11147. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  11148. /**
  11149. * Set the value of an uniform to an array of float32 (stored as matrices)
  11150. * @param uniform defines the webGL uniform location where to store the value
  11151. * @param matrices defines the array of float32 to store
  11152. */
  11153. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  11154. /**
  11155. * Set the value of an uniform to a matrix
  11156. * @param uniform defines the webGL uniform location where to store the value
  11157. * @param matrix defines the matrix to store
  11158. */
  11159. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  11160. /**
  11161. * Set the value of an uniform to a matrix (3x3)
  11162. * @param uniform defines the webGL uniform location where to store the value
  11163. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  11164. */
  11165. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  11166. /**
  11167. * Set the value of an uniform to a matrix (2x2)
  11168. * @param uniform defines the webGL uniform location where to store the value
  11169. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  11170. */
  11171. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  11172. /**
  11173. * Set the value of an uniform to a number (int)
  11174. * @param uniform defines the webGL uniform location where to store the value
  11175. * @param value defines the int number to store
  11176. */
  11177. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  11178. /**
  11179. * Set the value of an uniform to a number (float)
  11180. * @param uniform defines the webGL uniform location where to store the value
  11181. * @param value defines the float number to store
  11182. */
  11183. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  11184. /**
  11185. * Set the value of an uniform to a vec2
  11186. * @param uniform defines the webGL uniform location where to store the value
  11187. * @param x defines the 1st component of the value
  11188. * @param y defines the 2nd component of the value
  11189. */
  11190. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  11191. /**
  11192. * Set the value of an uniform to a vec3
  11193. * @param uniform defines the webGL uniform location where to store the value
  11194. * @param x defines the 1st component of the value
  11195. * @param y defines the 2nd component of the value
  11196. * @param z defines the 3rd component of the value
  11197. */
  11198. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  11199. /**
  11200. * Set the value of an uniform to a boolean
  11201. * @param uniform defines the webGL uniform location where to store the value
  11202. * @param bool defines the boolean to store
  11203. */
  11204. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  11205. /**
  11206. * Set the value of an uniform to a vec4
  11207. * @param uniform defines the webGL uniform location where to store the value
  11208. * @param x defines the 1st component of the value
  11209. * @param y defines the 2nd component of the value
  11210. * @param z defines the 3rd component of the value
  11211. * @param w defines the 4th component of the value
  11212. */
  11213. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  11214. /**
  11215. * Set the value of an uniform to a Color3
  11216. * @param uniform defines the webGL uniform location where to store the value
  11217. * @param color3 defines the color to store
  11218. */
  11219. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  11220. /**
  11221. * Set the value of an uniform to a Color3 and an alpha value
  11222. * @param uniform defines the webGL uniform location where to store the value
  11223. * @param color3 defines the color to store
  11224. * @param alpha defines the alpha component to store
  11225. */
  11226. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  11227. /**
  11228. * Sets a Color4 on a uniform variable
  11229. * @param uniform defines the uniform location
  11230. * @param color4 defines the value to be set
  11231. */
  11232. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  11233. /**
  11234. * Set various states to the webGL context
  11235. * @param culling defines backface culling state
  11236. * @param zOffset defines the value to apply to zOffset (0 by default)
  11237. * @param force defines if states must be applied even if cache is up to date
  11238. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  11239. */
  11240. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  11241. /**
  11242. * Set the z offset to apply to current rendering
  11243. * @param value defines the offset to apply
  11244. */
  11245. setZOffset(value: number): void;
  11246. /**
  11247. * Gets the current value of the zOffset
  11248. * @returns the current zOffset state
  11249. */
  11250. getZOffset(): number;
  11251. /**
  11252. * Enable or disable depth buffering
  11253. * @param enable defines the state to set
  11254. */
  11255. setDepthBuffer(enable: boolean): void;
  11256. /**
  11257. * Gets a boolean indicating if depth writing is enabled
  11258. * @returns the current depth writing state
  11259. */
  11260. getDepthWrite(): boolean;
  11261. /**
  11262. * Enable or disable depth writing
  11263. * @param enable defines the state to set
  11264. */
  11265. setDepthWrite(enable: boolean): void;
  11266. /**
  11267. * Enable or disable color writing
  11268. * @param enable defines the state to set
  11269. */
  11270. setColorWrite(enable: boolean): void;
  11271. /**
  11272. * Gets a boolean indicating if color writing is enabled
  11273. * @returns the current color writing state
  11274. */
  11275. getColorWrite(): boolean;
  11276. /**
  11277. * Sets alpha constants used by some alpha blending modes
  11278. * @param r defines the red component
  11279. * @param g defines the green component
  11280. * @param b defines the blue component
  11281. * @param a defines the alpha component
  11282. */
  11283. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  11284. /**
  11285. * Sets the current alpha mode
  11286. * @param mode defines the mode to use (one of the BABYLON.Engine.ALPHA_XXX)
  11287. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  11288. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  11289. */
  11290. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  11291. /**
  11292. * Gets the current alpha mode
  11293. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  11294. * @returns the current alpha mode
  11295. */
  11296. getAlphaMode(): number;
  11297. /**
  11298. * Clears the list of texture accessible through engine.
  11299. * This can help preventing texture load conflict due to name collision.
  11300. */
  11301. clearInternalTexturesCache(): void;
  11302. /**
  11303. * Force the entire cache to be cleared
  11304. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  11305. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  11306. */
  11307. wipeCaches(bruteForce?: boolean): void;
  11308. /**
  11309. * Set the compressed texture format to use, based on the formats you have, and the formats
  11310. * supported by the hardware / browser.
  11311. *
  11312. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  11313. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  11314. * to API arguments needed to compressed textures. This puts the burden on the container
  11315. * generator to house the arcane code for determining these for current & future formats.
  11316. *
  11317. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  11318. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  11319. *
  11320. * Note: The result of this call is not taken into account when a texture is base64.
  11321. *
  11322. * @param formatsAvailable defines the list of those format families you have created
  11323. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  11324. *
  11325. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  11326. * @returns The extension selected.
  11327. */
  11328. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  11329. private _getSamplingParameters;
  11330. private _partialLoadImg;
  11331. private _cascadeLoadImgs;
  11332. /** @hidden */
  11333. _createTexture(): WebGLTexture;
  11334. /**
  11335. * Usually called from BABYLON.Texture.ts.
  11336. * Passed information to create a WebGLTexture
  11337. * @param urlArg defines a value which contains one of the following:
  11338. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  11339. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  11340. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  11341. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  11342. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  11343. * @param scene needed for loading to the correct scene
  11344. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  11345. * @param onLoad optional callback to be called upon successful completion
  11346. * @param onError optional callback to be called upon failure
  11347. * @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
  11348. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  11349. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  11350. * @param forcedExtension defines the extension to use to pick the right loader
  11351. * @returns a InternalTexture for assignment back into BABYLON.Texture
  11352. */
  11353. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>): InternalTexture;
  11354. private _rescaleTexture;
  11355. /**
  11356. * Update a raw texture
  11357. * @param texture defines the texture to update
  11358. * @param data defines the data to store in the texture
  11359. * @param format defines the format of the data
  11360. * @param invertY defines if data must be stored with Y axis inverted
  11361. * @param compression defines the compression used (null by default)
  11362. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11363. */
  11364. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  11365. /**
  11366. * Creates a raw texture
  11367. * @param data defines the data to store in the texture
  11368. * @param width defines the width of the texture
  11369. * @param height defines the height of the texture
  11370. * @param format defines the format of the data
  11371. * @param generateMipMaps defines if the engine should generate the mip levels
  11372. * @param invertY defines if data must be stored with Y axis inverted
  11373. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  11374. * @param compression defines the compression used (null by default)
  11375. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11376. * @returns the raw texture inside an InternalTexture
  11377. */
  11378. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  11379. private _unpackFlipYCached;
  11380. /**
  11381. * In case you are sharing the context with other applications, it might
  11382. * be interested to not cache the unpack flip y state to ensure a consistent
  11383. * value would be set.
  11384. */
  11385. enableUnpackFlipYCached: boolean;
  11386. /** @hidden */
  11387. _unpackFlipY(value: boolean): void;
  11388. /** @hidden */
  11389. _getUnpackAlignement(): number;
  11390. /**
  11391. * Creates a dynamic texture
  11392. * @param width defines the width of the texture
  11393. * @param height defines the height of the texture
  11394. * @param generateMipMaps defines if the engine should generate the mip levels
  11395. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  11396. * @returns the dynamic texture inside an InternalTexture
  11397. */
  11398. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  11399. /**
  11400. * Update the sampling mode of a given texture
  11401. * @param samplingMode defines the required sampling mode
  11402. * @param texture defines the texture to update
  11403. */
  11404. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  11405. /**
  11406. * Update the content of a dynamic texture
  11407. * @param texture defines the texture to update
  11408. * @param canvas defines the canvas containing the source
  11409. * @param invertY defines if data must be stored with Y axis inverted
  11410. * @param premulAlpha defines if alpha is stored as premultiplied
  11411. * @param format defines the format of the data
  11412. */
  11413. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  11414. /**
  11415. * Update a video texture
  11416. * @param texture defines the texture to update
  11417. * @param video defines the video element to use
  11418. * @param invertY defines if data must be stored with Y axis inverted
  11419. */
  11420. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  11421. /**
  11422. * Updates a depth texture Comparison Mode and Function.
  11423. * If the comparison Function is equal to 0, the mode will be set to none.
  11424. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  11425. * @param texture The texture to set the comparison function for
  11426. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  11427. */
  11428. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  11429. private _setupDepthStencilTexture;
  11430. /**
  11431. * Creates a depth stencil texture.
  11432. * This is only available in WebGL 2 or with the depth texture extension available.
  11433. * @param size The size of face edge in the texture.
  11434. * @param options The options defining the texture.
  11435. * @returns The texture
  11436. */
  11437. createDepthStencilTexture(size: number | {
  11438. width: number;
  11439. height: number;
  11440. }, options: DepthTextureCreationOptions): InternalTexture;
  11441. /**
  11442. * Creates a depth stencil texture.
  11443. * This is only available in WebGL 2 or with the depth texture extension available.
  11444. * @param size The size of face edge in the texture.
  11445. * @param options The options defining the texture.
  11446. * @returns The texture
  11447. */
  11448. private _createDepthStencilTexture;
  11449. /**
  11450. * Creates a depth stencil cube texture.
  11451. * This is only available in WebGL 2.
  11452. * @param size The size of face edge in the cube texture.
  11453. * @param options The options defining the cube texture.
  11454. * @returns The cube texture
  11455. */
  11456. private _createDepthStencilCubeTexture;
  11457. /**
  11458. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  11459. * @param renderTarget The render target to set the frame buffer for
  11460. */
  11461. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  11462. /**
  11463. * Creates a new render target texture
  11464. * @param size defines the size of the texture
  11465. * @param options defines the options used to create the texture
  11466. * @returns a new render target texture stored in an InternalTexture
  11467. */
  11468. createRenderTargetTexture(size: number | {
  11469. width: number;
  11470. height: number;
  11471. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  11472. /**
  11473. * Create a multi render target texture
  11474. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  11475. * @param size defines the size of the texture
  11476. * @param options defines the creation options
  11477. * @returns the cube texture as an InternalTexture
  11478. */
  11479. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  11480. private _setupFramebufferDepthAttachments;
  11481. /**
  11482. * Updates the sample count of a render target texture
  11483. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  11484. * @param texture defines the texture to update
  11485. * @param samples defines the sample count to set
  11486. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  11487. */
  11488. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  11489. /**
  11490. * Update the sample count for a given multiple render target texture
  11491. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  11492. * @param textures defines the textures to update
  11493. * @param samples defines the sample count to set
  11494. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  11495. */
  11496. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  11497. /** @hidden */
  11498. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  11499. /** @hidden */
  11500. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  11501. /** @hidden */
  11502. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  11503. /** @hidden */
  11504. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  11505. /**
  11506. * Creates a new render target cube texture
  11507. * @param size defines the size of the texture
  11508. * @param options defines the options used to create the texture
  11509. * @returns a new render target cube texture stored in an InternalTexture
  11510. */
  11511. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11512. /**
  11513. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  11514. * @param rootUrl defines the url where the file to load is located
  11515. * @param scene defines the current scene
  11516. * @param lodScale defines scale to apply to the mip map selection
  11517. * @param lodOffset defines offset to apply to the mip map selection
  11518. * @param onLoad defines an optional callback raised when the texture is loaded
  11519. * @param onError defines an optional callback raised if there is an issue to load the texture
  11520. * @param format defines the format of the data
  11521. * @param forcedExtension defines the extension to use to pick the right loader
  11522. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  11523. * @returns the cube texture as an InternalTexture
  11524. */
  11525. 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;
  11526. /**
  11527. * Creates a cube texture
  11528. * @param rootUrl defines the url where the files to load is located
  11529. * @param scene defines the current scene
  11530. * @param files defines the list of files to load (1 per face)
  11531. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  11532. * @param onLoad defines an optional callback raised when the texture is loaded
  11533. * @param onError defines an optional callback raised if there is an issue to load the texture
  11534. * @param format defines the format of the data
  11535. * @param forcedExtension defines the extension to use to pick the right loader
  11536. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  11537. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  11538. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  11539. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  11540. * @returns the cube texture as an InternalTexture
  11541. */
  11542. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad?: Nullable<(data?: any) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, fallback?: Nullable<InternalTexture>): InternalTexture;
  11543. /**
  11544. * @hidden
  11545. */
  11546. _setCubeMapTextureParams(loadMipmap: boolean): void;
  11547. /**
  11548. * Update a raw cube texture
  11549. * @param texture defines the texture to udpdate
  11550. * @param data defines the data to store
  11551. * @param format defines the data format
  11552. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11553. * @param invertY defines if data must be stored with Y axis inverted
  11554. * @param compression defines the compression used (null by default)
  11555. * @param level defines which level of the texture to update
  11556. */
  11557. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  11558. /**
  11559. * Creates a new raw cube texture
  11560. * @param data defines the array of data to use to create each face
  11561. * @param size defines the size of the textures
  11562. * @param format defines the format of the data
  11563. * @param type defines the type of the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  11564. * @param generateMipMaps defines if the engine should generate the mip levels
  11565. * @param invertY defines if data must be stored with Y axis inverted
  11566. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  11567. * @param compression defines the compression used (null by default)
  11568. * @returns the cube texture as an InternalTexture
  11569. */
  11570. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  11571. /**
  11572. * Creates a new raw cube texture from a specified url
  11573. * @param url defines the url where the data is located
  11574. * @param scene defines the current scene
  11575. * @param size defines the size of the textures
  11576. * @param format defines the format of the data
  11577. * @param type defines the type fo the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  11578. * @param noMipmap defines if the engine should avoid generating the mip levels
  11579. * @param callback defines a callback used to extract texture data from loaded data
  11580. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11581. * @param onLoad defines a callback called when texture is loaded
  11582. * @param onError defines a callback called if there is an error
  11583. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  11584. * @param invertY defines if data must be stored with Y axis inverted
  11585. * @returns the cube texture as an InternalTexture
  11586. */
  11587. 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;
  11588. /**
  11589. * Update a raw 3D texture
  11590. * @param texture defines the texture to update
  11591. * @param data defines the data to store
  11592. * @param format defines the data format
  11593. * @param invertY defines if data must be stored with Y axis inverted
  11594. * @param compression defines the used compression (can be null)
  11595. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11596. */
  11597. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  11598. /**
  11599. * Creates a new raw 3D texture
  11600. * @param data defines the data used to create the texture
  11601. * @param width defines the width of the texture
  11602. * @param height defines the height of the texture
  11603. * @param depth defines the depth of the texture
  11604. * @param format defines the format of the texture
  11605. * @param generateMipMaps defines if the engine must generate mip levels
  11606. * @param invertY defines if data must be stored with Y axis inverted
  11607. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  11608. * @param compression defines the compressed used (can be null)
  11609. * @param textureType defines the compressed used (can be null)
  11610. * @returns a new raw 3D texture (stored in an InternalTexture)
  11611. */
  11612. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  11613. private _prepareWebGLTextureContinuation;
  11614. private _prepareWebGLTexture;
  11615. private _convertRGBtoRGBATextureData;
  11616. /** @hidden */
  11617. _releaseFramebufferObjects(texture: InternalTexture): void;
  11618. /** @hidden */
  11619. _releaseTexture(texture: InternalTexture): void;
  11620. private setProgram;
  11621. private _boundUniforms;
  11622. /**
  11623. * Binds an effect to the webGL context
  11624. * @param effect defines the effect to bind
  11625. */
  11626. bindSamplers(effect: Effect): void;
  11627. private _moveBoundTextureOnTop;
  11628. private _getCorrectTextureChannel;
  11629. private _linkTrackers;
  11630. private _removeDesignatedSlot;
  11631. private _activateCurrentTexture;
  11632. /** @hidden */
  11633. protected _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  11634. /** @hidden */
  11635. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  11636. /**
  11637. * Sets a texture to the webGL context from a postprocess
  11638. * @param channel defines the channel to use
  11639. * @param postProcess defines the source postprocess
  11640. */
  11641. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  11642. /**
  11643. * Binds the output of the passed in post process to the texture channel specified
  11644. * @param channel The channel the texture should be bound to
  11645. * @param postProcess The post process which's output should be bound
  11646. */
  11647. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  11648. /**
  11649. * Unbind all textures from the webGL context
  11650. */
  11651. unbindAllTextures(): void;
  11652. /**
  11653. * Sets a texture to the according uniform.
  11654. * @param channel The texture channel
  11655. * @param uniform The uniform to set
  11656. * @param texture The texture to apply
  11657. */
  11658. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  11659. /**
  11660. * Sets a depth stencil texture from a render target to the according uniform.
  11661. * @param channel The texture channel
  11662. * @param uniform The uniform to set
  11663. * @param texture The render target texture containing the depth stencil texture to apply
  11664. */
  11665. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  11666. private _bindSamplerUniformToChannel;
  11667. private _getTextureWrapMode;
  11668. private _setTexture;
  11669. /**
  11670. * Sets an array of texture to the webGL context
  11671. * @param channel defines the channel where the texture array must be set
  11672. * @param uniform defines the associated uniform location
  11673. * @param textures defines the array of textures to bind
  11674. */
  11675. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  11676. /** @hidden */
  11677. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  11678. private _setTextureParameterFloat;
  11679. private _setTextureParameterInteger;
  11680. /**
  11681. * Reads pixels from the current frame buffer. Please note that this function can be slow
  11682. * @param x defines the x coordinate of the rectangle where pixels must be read
  11683. * @param y defines the y coordinate of the rectangle where pixels must be read
  11684. * @param width defines the width of the rectangle where pixels must be read
  11685. * @param height defines the height of the rectangle where pixels must be read
  11686. * @returns a Uint8Array containing RGBA colors
  11687. */
  11688. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  11689. /**
  11690. * Add an externaly attached data from its key.
  11691. * This method call will fail and return false, if such key already exists.
  11692. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  11693. * @param key the unique key that identifies the data
  11694. * @param data the data object to associate to the key for this Engine instance
  11695. * @return true if no such key were already present and the data was added successfully, false otherwise
  11696. */
  11697. addExternalData<T>(key: string, data: T): boolean;
  11698. /**
  11699. * Get an externaly attached data from its key
  11700. * @param key the unique key that identifies the data
  11701. * @return the associated data, if present (can be null), or undefined if not present
  11702. */
  11703. getExternalData<T>(key: string): T;
  11704. /**
  11705. * Get an externaly attached data from its key, create it using a factory if it's not already present
  11706. * @param key the unique key that identifies the data
  11707. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  11708. * @return the associated data, can be null if the factory returned null.
  11709. */
  11710. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  11711. /**
  11712. * Remove an externaly attached data from the Engine instance
  11713. * @param key the unique key that identifies the data
  11714. * @return true if the data was successfully removed, false if it doesn't exist
  11715. */
  11716. removeExternalData(key: string): boolean;
  11717. /**
  11718. * Unbind all vertex attributes from the webGL context
  11719. */
  11720. unbindAllAttributes(): void;
  11721. /**
  11722. * 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
  11723. */
  11724. releaseEffects(): void;
  11725. /**
  11726. * Dispose and release all associated resources
  11727. */
  11728. dispose(): void;
  11729. /**
  11730. * Display the loading screen
  11731. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11732. */
  11733. displayLoadingUI(): void;
  11734. /**
  11735. * Hide the loading screen
  11736. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11737. */
  11738. hideLoadingUI(): void;
  11739. /**
  11740. * Gets the current loading screen object
  11741. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11742. */
  11743. /**
  11744. * Sets the current loading screen object
  11745. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11746. */
  11747. loadingScreen: ILoadingScreen;
  11748. /**
  11749. * Sets the current loading screen text
  11750. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11751. */
  11752. loadingUIText: string;
  11753. /**
  11754. * Sets the current loading screen background color
  11755. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11756. */
  11757. loadingUIBackgroundColor: string;
  11758. /**
  11759. * Attach a new callback raised when context lost event is fired
  11760. * @param callback defines the callback to call
  11761. */
  11762. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  11763. /**
  11764. * Attach a new callback raised when context restored event is fired
  11765. * @param callback defines the callback to call
  11766. */
  11767. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  11768. /**
  11769. * Gets the source code of the vertex shader associated with a specific webGL program
  11770. * @param program defines the program to use
  11771. * @returns a string containing the source code of the vertex shader associated with the program
  11772. */
  11773. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  11774. /**
  11775. * Gets the source code of the fragment shader associated with a specific webGL program
  11776. * @param program defines the program to use
  11777. * @returns a string containing the source code of the fragment shader associated with the program
  11778. */
  11779. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  11780. /**
  11781. * Get the current error code of the webGL context
  11782. * @returns the error code
  11783. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  11784. */
  11785. getError(): number;
  11786. /**
  11787. * Gets the current framerate
  11788. * @returns a number representing the framerate
  11789. */
  11790. getFps(): number;
  11791. /**
  11792. * Gets the time spent between current and previous frame
  11793. * @returns a number representing the delta time in ms
  11794. */
  11795. getDeltaTime(): number;
  11796. private _measureFps;
  11797. /** @hidden */
  11798. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  11799. private _canRenderToFloatFramebuffer;
  11800. private _canRenderToHalfFloatFramebuffer;
  11801. private _canRenderToFramebuffer;
  11802. /** @hidden */
  11803. _getWebGLTextureType(type: number): number;
  11804. private _getInternalFormat;
  11805. /** @hidden */
  11806. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  11807. /** @hidden */
  11808. _getRGBAMultiSampleBufferFormat(type: number): number;
  11809. /** @hidden */
  11810. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, database?: Database, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  11811. /** @hidden */
  11812. _loadFileAsync(url: string, database?: Database, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  11813. private _partialLoadFile;
  11814. private _cascadeLoadFiles;
  11815. /**
  11816. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  11817. * @returns true if the engine can be created
  11818. * @ignorenaming
  11819. */
  11820. static isSupported(): boolean;
  11821. }
  11822. }
  11823. declare module BABYLON {
  11824. /**
  11825. * Options to create the null engine
  11826. */
  11827. class NullEngineOptions {
  11828. /**
  11829. * Render width (Default: 512)
  11830. */
  11831. renderWidth: number;
  11832. /**
  11833. * Render height (Default: 256)
  11834. */
  11835. renderHeight: number;
  11836. /**
  11837. * Texture size (Default: 512)
  11838. */
  11839. textureSize: number;
  11840. /**
  11841. * If delta time between frames should be constant
  11842. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  11843. */
  11844. deterministicLockstep: boolean;
  11845. /**
  11846. * Maximum about of steps between frames (Default: 4)
  11847. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  11848. */
  11849. lockstepMaxSteps: number;
  11850. }
  11851. /**
  11852. * The null engine class provides support for headless version of babylon.js.
  11853. * This can be used in server side scenario or for testing purposes
  11854. */
  11855. class NullEngine extends Engine {
  11856. private _options;
  11857. /**
  11858. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  11859. */
  11860. isDeterministicLockStep(): boolean;
  11861. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  11862. getLockstepMaxSteps(): number;
  11863. /**
  11864. * Sets hardware scaling, used to save performance if needed
  11865. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  11866. */
  11867. getHardwareScalingLevel(): number;
  11868. constructor(options?: NullEngineOptions);
  11869. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  11870. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  11871. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  11872. getRenderWidth(useScreen?: boolean): number;
  11873. getRenderHeight(useScreen?: boolean): number;
  11874. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  11875. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  11876. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  11877. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  11878. bindSamplers(effect: Effect): void;
  11879. enableEffect(effect: Effect): void;
  11880. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  11881. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  11882. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  11883. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  11884. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  11885. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  11886. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  11887. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  11888. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  11889. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  11890. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  11891. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  11892. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  11893. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  11894. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  11895. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  11896. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  11897. setFloat(uniform: WebGLUniformLocation, value: number): void;
  11898. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  11899. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  11900. setBool(uniform: WebGLUniformLocation, bool: number): void;
  11901. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  11902. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  11903. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  11904. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  11905. bindBuffers(vertexBuffers: {
  11906. [key: string]: VertexBuffer;
  11907. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  11908. wipeCaches(bruteForce?: boolean): void;
  11909. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  11910. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  11911. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  11912. /** @hidden */
  11913. _createTexture(): WebGLTexture;
  11914. /** @hidden */
  11915. _releaseTexture(texture: InternalTexture): void;
  11916. 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;
  11917. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  11918. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  11919. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  11920. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  11921. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  11922. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  11923. areAllEffectsReady(): boolean;
  11924. /**
  11925. * @hidden
  11926. * Get the current error code of the webGL context
  11927. * @returns the error code
  11928. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  11929. */
  11930. getError(): number;
  11931. /** @hidden */
  11932. _getUnpackAlignement(): number;
  11933. /** @hidden */
  11934. _unpackFlipY(value: boolean): void;
  11935. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  11936. /**
  11937. * Updates a dynamic vertex buffer.
  11938. * @param vertexBuffer the vertex buffer to update
  11939. * @param data the data used to update the vertex buffer
  11940. * @param byteOffset the byte offset of the data (optional)
  11941. * @param byteLength the byte length of the data (optional)
  11942. */
  11943. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  11944. protected _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  11945. /** @hidden */
  11946. _bindTexture(channel: number, texture: InternalTexture): void;
  11947. /** @hidden */
  11948. _releaseBuffer(buffer: WebGLBuffer): boolean;
  11949. releaseEffects(): void;
  11950. displayLoadingUI(): void;
  11951. hideLoadingUI(): void;
  11952. /** @hidden */
  11953. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  11954. /** @hidden */
  11955. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  11956. /** @hidden */
  11957. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  11958. /** @hidden */
  11959. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  11960. }
  11961. }
  11962. interface WebGLRenderingContext {
  11963. readonly RASTERIZER_DISCARD: number;
  11964. readonly DEPTH_COMPONENT24: number;
  11965. readonly TEXTURE_3D: number;
  11966. readonly TEXTURE_2D_ARRAY: number;
  11967. readonly TEXTURE_COMPARE_FUNC: number;
  11968. readonly TEXTURE_COMPARE_MODE: number;
  11969. readonly COMPARE_REF_TO_TEXTURE: number;
  11970. readonly TEXTURE_WRAP_R: number;
  11971. readonly HALF_FLOAT: number;
  11972. readonly RGB8: number;
  11973. readonly RED_INTEGER: number;
  11974. readonly RG_INTEGER: number;
  11975. readonly RGB_INTEGER: number;
  11976. readonly RGBA_INTEGER: number;
  11977. readonly R8_SNORM: number;
  11978. readonly RG8_SNORM: number;
  11979. readonly RGB8_SNORM: number;
  11980. readonly RGBA8_SNORM: number;
  11981. readonly R8I: number;
  11982. readonly RG8I: number;
  11983. readonly RGB8I: number;
  11984. readonly RGBA8I: number;
  11985. readonly R8UI: number;
  11986. readonly RG8UI: number;
  11987. readonly RGB8UI: number;
  11988. readonly RGBA8UI: number;
  11989. readonly R16I: number;
  11990. readonly RG16I: number;
  11991. readonly RGB16I: number;
  11992. readonly RGBA16I: number;
  11993. readonly R16UI: number;
  11994. readonly RG16UI: number;
  11995. readonly RGB16UI: number;
  11996. readonly RGBA16UI: number;
  11997. readonly R32I: number;
  11998. readonly RG32I: number;
  11999. readonly RGB32I: number;
  12000. readonly RGBA32I: number;
  12001. readonly R32UI: number;
  12002. readonly RG32UI: number;
  12003. readonly RGB32UI: number;
  12004. readonly RGBA32UI: number;
  12005. readonly RGB10_A2UI: number;
  12006. readonly R11F_G11F_B10F: number;
  12007. readonly RGB9_E5: number;
  12008. readonly RGB10_A2: number;
  12009. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  12010. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  12011. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  12012. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  12013. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  12014. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  12015. 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;
  12016. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  12017. readonly TRANSFORM_FEEDBACK: number;
  12018. readonly INTERLEAVED_ATTRIBS: number;
  12019. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  12020. createTransformFeedback(): WebGLTransformFeedback;
  12021. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  12022. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  12023. beginTransformFeedback(primitiveMode: number): void;
  12024. endTransformFeedback(): void;
  12025. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  12026. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  12027. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  12028. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  12029. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  12030. }
  12031. interface ImageBitmap {
  12032. readonly width: number;
  12033. readonly height: number;
  12034. close(): void;
  12035. }
  12036. interface WebGLQuery extends WebGLObject {
  12037. }
  12038. declare var WebGLQuery: {
  12039. prototype: WebGLQuery;
  12040. new (): WebGLQuery;
  12041. };
  12042. interface WebGLSampler extends WebGLObject {
  12043. }
  12044. declare var WebGLSampler: {
  12045. prototype: WebGLSampler;
  12046. new (): WebGLSampler;
  12047. };
  12048. interface WebGLSync extends WebGLObject {
  12049. }
  12050. declare var WebGLSync: {
  12051. prototype: WebGLSync;
  12052. new (): WebGLSync;
  12053. };
  12054. interface WebGLTransformFeedback extends WebGLObject {
  12055. }
  12056. declare var WebGLTransformFeedback: {
  12057. prototype: WebGLTransformFeedback;
  12058. new (): WebGLTransformFeedback;
  12059. };
  12060. interface WebGLVertexArrayObject extends WebGLObject {
  12061. }
  12062. declare var WebGLVertexArrayObject: {
  12063. prototype: WebGLVertexArrayObject;
  12064. new (): WebGLVertexArrayObject;
  12065. };
  12066. declare module BABYLON {
  12067. /**
  12068. * Gather the list of keyboard event types as constants.
  12069. */
  12070. class KeyboardEventTypes {
  12071. /**
  12072. * The keydown event is fired when a key becomes active (pressed).
  12073. */
  12074. static readonly KEYDOWN: number;
  12075. /**
  12076. * The keyup event is fired when a key has been released.
  12077. */
  12078. static readonly KEYUP: number;
  12079. }
  12080. /**
  12081. * This class is used to store keyboard related info for the onKeyboardObservable event.
  12082. */
  12083. class KeyboardInfo {
  12084. /**
  12085. * Defines the type of event (BABYLON.KeyboardEventTypes)
  12086. */
  12087. type: number;
  12088. /**
  12089. * Defines the related dom event
  12090. */
  12091. event: KeyboardEvent;
  12092. /**
  12093. * Instantiates a new keyboard info.
  12094. * This class is used to store keyboard related info for the onKeyboardObservable event.
  12095. * @param type Defines the type of event (BABYLON.KeyboardEventTypes)
  12096. * @param event Defines the related dom event
  12097. */
  12098. constructor(
  12099. /**
  12100. * Defines the type of event (BABYLON.KeyboardEventTypes)
  12101. */
  12102. type: number,
  12103. /**
  12104. * Defines the related dom event
  12105. */
  12106. event: KeyboardEvent);
  12107. }
  12108. /**
  12109. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  12110. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  12111. */
  12112. class KeyboardInfoPre extends KeyboardInfo {
  12113. /**
  12114. * Defines the type of event (BABYLON.KeyboardEventTypes)
  12115. */
  12116. type: number;
  12117. /**
  12118. * Defines the related dom event
  12119. */
  12120. event: KeyboardEvent;
  12121. /**
  12122. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  12123. */
  12124. skipOnPointerObservable: boolean;
  12125. /**
  12126. * Instantiates a new keyboard pre info.
  12127. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  12128. * @param type Defines the type of event (BABYLON.KeyboardEventTypes)
  12129. * @param event Defines the related dom event
  12130. */
  12131. constructor(
  12132. /**
  12133. * Defines the type of event (BABYLON.KeyboardEventTypes)
  12134. */
  12135. type: number,
  12136. /**
  12137. * Defines the related dom event
  12138. */
  12139. event: KeyboardEvent);
  12140. }
  12141. }
  12142. declare module BABYLON {
  12143. /**
  12144. * Gather the list of pointer event types as constants.
  12145. */
  12146. class PointerEventTypes {
  12147. /**
  12148. * 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.
  12149. */
  12150. static readonly POINTERDOWN: number;
  12151. /**
  12152. * The pointerup event is fired when a pointer is no longer active.
  12153. */
  12154. static readonly POINTERUP: number;
  12155. /**
  12156. * The pointermove event is fired when a pointer changes coordinates.
  12157. */
  12158. static readonly POINTERMOVE: number;
  12159. /**
  12160. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12161. */
  12162. static readonly POINTERWHEEL: number;
  12163. /**
  12164. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12165. */
  12166. static readonly POINTERPICK: number;
  12167. /**
  12168. * The pointertap event is fired when a the object has been touched and released without drag.
  12169. */
  12170. static readonly POINTERTAP: number;
  12171. /**
  12172. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12173. */
  12174. static readonly POINTERDOUBLETAP: number;
  12175. }
  12176. /**
  12177. * Base class of pointer info types.
  12178. */
  12179. class PointerInfoBase {
  12180. /**
  12181. * Defines the type of event (BABYLON.PointerEventTypes)
  12182. */
  12183. type: number;
  12184. /**
  12185. * Defines the related dom event
  12186. */
  12187. event: PointerEvent | MouseWheelEvent;
  12188. /**
  12189. * Instantiates the base class of pointers info.
  12190. * @param type Defines the type of event (BABYLON.PointerEventTypes)
  12191. * @param event Defines the related dom event
  12192. */
  12193. constructor(
  12194. /**
  12195. * Defines the type of event (BABYLON.PointerEventTypes)
  12196. */
  12197. type: number,
  12198. /**
  12199. * Defines the related dom event
  12200. */
  12201. event: PointerEvent | MouseWheelEvent);
  12202. }
  12203. /**
  12204. * This class is used to store pointer related info for the onPrePointerObservable event.
  12205. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12206. */
  12207. class PointerInfoPre extends PointerInfoBase {
  12208. /**
  12209. * Ray from a pointer if availible (eg. 6dof controller)
  12210. */
  12211. ray: Nullable<Ray>;
  12212. /**
  12213. * Defines the local position of the pointer on the canvas.
  12214. */
  12215. localPosition: Vector2;
  12216. /**
  12217. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12218. */
  12219. skipOnPointerObservable: boolean;
  12220. /**
  12221. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12222. * @param type Defines the type of event (BABYLON.PointerEventTypes)
  12223. * @param event Defines the related dom event
  12224. * @param localX Defines the local x coordinates of the pointer when the event occured
  12225. * @param localY Defines the local y coordinates of the pointer when the event occured
  12226. */
  12227. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12228. }
  12229. /**
  12230. * This type contains all the data related to a pointer event in Babylon.js.
  12231. * 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.
  12232. */
  12233. class PointerInfo extends PointerInfoBase {
  12234. /**
  12235. * Defines the picking info associated to the info (if any)\
  12236. */
  12237. pickInfo: Nullable<PickingInfo>;
  12238. /**
  12239. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12240. * @param type Defines the type of event (BABYLON.PointerEventTypes)
  12241. * @param event Defines the related dom event
  12242. * @param pickInfo Defines the picking info associated to the info (if any)\
  12243. */
  12244. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12245. /**
  12246. * Defines the picking info associated to the info (if any)\
  12247. */
  12248. pickInfo: Nullable<PickingInfo>);
  12249. }
  12250. }
  12251. declare module BABYLON {
  12252. /**
  12253. * Represents a gamepad control stick position
  12254. */
  12255. class StickValues {
  12256. /**
  12257. * The x component of the control stick
  12258. */
  12259. x: number;
  12260. /**
  12261. * The y component of the control stick
  12262. */
  12263. y: number;
  12264. /**
  12265. * Initializes the gamepad x and y control stick values
  12266. * @param x The x component of the gamepad control stick value
  12267. * @param y The y component of the gamepad control stick value
  12268. */
  12269. constructor(
  12270. /**
  12271. * The x component of the control stick
  12272. */
  12273. x: number,
  12274. /**
  12275. * The y component of the control stick
  12276. */
  12277. y: number);
  12278. }
  12279. /**
  12280. * An interface which manages callbacks for gamepad button changes
  12281. */
  12282. interface GamepadButtonChanges {
  12283. /**
  12284. * Called when a gamepad has been changed
  12285. */
  12286. changed: boolean;
  12287. /**
  12288. * Called when a gamepad press event has been triggered
  12289. */
  12290. pressChanged: boolean;
  12291. /**
  12292. * Called when a touch event has been triggered
  12293. */
  12294. touchChanged: boolean;
  12295. /**
  12296. * Called when a value has changed
  12297. */
  12298. valueChanged: boolean;
  12299. }
  12300. /**
  12301. * Represents a gamepad
  12302. */
  12303. class Gamepad {
  12304. /**
  12305. * The id of the gamepad
  12306. */
  12307. id: string;
  12308. /**
  12309. * The index of the gamepad
  12310. */
  12311. index: number;
  12312. /**
  12313. * The browser gamepad
  12314. */
  12315. browserGamepad: any;
  12316. /**
  12317. * Specifies what type of gamepad this represents
  12318. */
  12319. type: number;
  12320. private _leftStick;
  12321. private _rightStick;
  12322. /** @hidden */
  12323. _isConnected: boolean;
  12324. private _leftStickAxisX;
  12325. private _leftStickAxisY;
  12326. private _rightStickAxisX;
  12327. private _rightStickAxisY;
  12328. /**
  12329. * Triggered when the left control stick has been changed
  12330. */
  12331. private _onleftstickchanged;
  12332. /**
  12333. * Triggered when the right control stick has been changed
  12334. */
  12335. private _onrightstickchanged;
  12336. /**
  12337. * Represents a gamepad controller
  12338. */
  12339. static GAMEPAD: number;
  12340. /**
  12341. * Represents a generic controller
  12342. */
  12343. static GENERIC: number;
  12344. /**
  12345. * Represents an XBox controller
  12346. */
  12347. static XBOX: number;
  12348. /**
  12349. * Represents a pose-enabled controller
  12350. */
  12351. static POSE_ENABLED: number;
  12352. /**
  12353. * Specifies whether the left control stick should be Y-inverted
  12354. */
  12355. protected _invertLeftStickY: boolean;
  12356. /**
  12357. * Specifies if the gamepad has been connected
  12358. */
  12359. readonly isConnected: boolean;
  12360. /**
  12361. * Initializes the gamepad
  12362. * @param id The id of the gamepad
  12363. * @param index The index of the gamepad
  12364. * @param browserGamepad The browser gamepad
  12365. * @param leftStickX The x component of the left joystick
  12366. * @param leftStickY The y component of the left joystick
  12367. * @param rightStickX The x component of the right joystick
  12368. * @param rightStickY The y component of the right joystick
  12369. */
  12370. constructor(
  12371. /**
  12372. * The id of the gamepad
  12373. */
  12374. id: string,
  12375. /**
  12376. * The index of the gamepad
  12377. */
  12378. index: number,
  12379. /**
  12380. * The browser gamepad
  12381. */
  12382. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12383. /**
  12384. * Callback triggered when the left joystick has changed
  12385. * @param callback
  12386. */
  12387. onleftstickchanged(callback: (values: StickValues) => void): void;
  12388. /**
  12389. * Callback triggered when the right joystick has changed
  12390. * @param callback
  12391. */
  12392. onrightstickchanged(callback: (values: StickValues) => void): void;
  12393. /**
  12394. * Gets the left joystick
  12395. */
  12396. /**
  12397. * Sets the left joystick values
  12398. */
  12399. leftStick: StickValues;
  12400. /**
  12401. * Gets the right joystick
  12402. */
  12403. /**
  12404. * Sets the right joystick value
  12405. */
  12406. rightStick: StickValues;
  12407. /**
  12408. * Updates the gamepad joystick positions
  12409. */
  12410. update(): void;
  12411. /**
  12412. * Disposes the gamepad
  12413. */
  12414. dispose(): void;
  12415. }
  12416. /**
  12417. * Represents a generic gamepad
  12418. */
  12419. class GenericPad extends Gamepad {
  12420. private _buttons;
  12421. private _onbuttondown;
  12422. private _onbuttonup;
  12423. /**
  12424. * Observable triggered when a button has been pressed
  12425. */
  12426. onButtonDownObservable: Observable<number>;
  12427. /**
  12428. * Observable triggered when a button has been released
  12429. */
  12430. onButtonUpObservable: Observable<number>;
  12431. /**
  12432. * Callback triggered when a button has been pressed
  12433. * @param callback Called when a button has been pressed
  12434. */
  12435. onbuttondown(callback: (buttonPressed: number) => void): void;
  12436. /**
  12437. * Callback triggered when a button has been released
  12438. * @param callback Called when a button has been released
  12439. */
  12440. onbuttonup(callback: (buttonReleased: number) => void): void;
  12441. /**
  12442. * Initializes the generic gamepad
  12443. * @param id The id of the generic gamepad
  12444. * @param index The index of the generic gamepad
  12445. * @param browserGamepad The browser gamepad
  12446. */
  12447. constructor(id: string, index: number, browserGamepad: any);
  12448. private _setButtonValue;
  12449. /**
  12450. * Updates the generic gamepad
  12451. */
  12452. update(): void;
  12453. /**
  12454. * Disposes the generic gamepad
  12455. */
  12456. dispose(): void;
  12457. }
  12458. }
  12459. declare module BABYLON {
  12460. /**
  12461. * Manager for handling gamepads
  12462. */
  12463. class GamepadManager {
  12464. private _scene?;
  12465. private _babylonGamepads;
  12466. private _oneGamepadConnected;
  12467. /** @hidden */
  12468. _isMonitoring: boolean;
  12469. private _gamepadEventSupported;
  12470. private _gamepadSupport;
  12471. /**
  12472. * observable to be triggered when the gamepad controller has been connected
  12473. */
  12474. onGamepadConnectedObservable: Observable<Gamepad>;
  12475. /**
  12476. * observable to be triggered when the gamepad controller has been disconnected
  12477. */
  12478. onGamepadDisconnectedObservable: Observable<Gamepad>;
  12479. private _onGamepadConnectedEvent;
  12480. private _onGamepadDisconnectedEvent;
  12481. /**
  12482. * Initializes the gamepad manager
  12483. * @param _scene BabylonJS scene
  12484. */
  12485. constructor(_scene?: Scene | undefined);
  12486. /**
  12487. * The gamepads in the game pad manager
  12488. */
  12489. readonly gamepads: Gamepad[];
  12490. /**
  12491. * Get the gamepad controllers based on type
  12492. * @param type The type of gamepad controller
  12493. * @returns Nullable gamepad
  12494. */
  12495. getGamepadByType(type?: number): Nullable<Gamepad>;
  12496. /**
  12497. * Disposes the gamepad manager
  12498. */
  12499. dispose(): void;
  12500. private _addNewGamepad;
  12501. private _startMonitoringGamepads;
  12502. private _stopMonitoringGamepads;
  12503. /** @hidden */
  12504. _checkGamepadsStatus(): void;
  12505. private _updateGamepadObjects;
  12506. }
  12507. }
  12508. declare module BABYLON {
  12509. interface Scene {
  12510. /** @hidden */
  12511. _gamepadManager: Nullable<GamepadManager>;
  12512. /**
  12513. * Gets the gamepad manager associated with the scene
  12514. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  12515. */
  12516. gamepadManager: GamepadManager;
  12517. }
  12518. /**
  12519. * Interface representing a free camera inputs manager
  12520. */
  12521. interface FreeCameraInputsManager {
  12522. /**
  12523. * Adds gamepad input support to the FreeCameraInputsManager.
  12524. * @returns the FreeCameraInputsManager
  12525. */
  12526. addGamepad(): FreeCameraInputsManager;
  12527. }
  12528. /**
  12529. * Interface representing an arc rotate camera inputs manager
  12530. */
  12531. interface ArcRotateCameraInputsManager {
  12532. /**
  12533. * Adds gamepad input support to the ArcRotateCamera InputManager.
  12534. * @returns the camera inputs manager
  12535. */
  12536. addGamepad(): ArcRotateCameraInputsManager;
  12537. }
  12538. /**
  12539. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  12540. */
  12541. class GamepadSystemSceneComponent implements ISceneComponent {
  12542. /**
  12543. * The component name helpfull to identify the component in the list of scene components.
  12544. */
  12545. readonly name: string;
  12546. /**
  12547. * The scene the component belongs to.
  12548. */
  12549. scene: Scene;
  12550. /**
  12551. * Creates a new instance of the component for the given scene
  12552. * @param scene Defines the scene to register the component in
  12553. */
  12554. constructor(scene: Scene);
  12555. /**
  12556. * Registers the component in a given scene
  12557. */
  12558. register(): void;
  12559. /**
  12560. * Rebuilds the elements related to this component in case of
  12561. * context lost for instance.
  12562. */
  12563. rebuild(): void;
  12564. /**
  12565. * Disposes the component and the associated ressources
  12566. */
  12567. dispose(): void;
  12568. private _beforeCameraUpdate;
  12569. }
  12570. }
  12571. declare module BABYLON {
  12572. /**
  12573. * Defines supported buttons for XBox360 compatible gamepads
  12574. */
  12575. enum Xbox360Button {
  12576. /** A */
  12577. A = 0,
  12578. /** B */
  12579. B = 1,
  12580. /** X */
  12581. X = 2,
  12582. /** Y */
  12583. Y = 3,
  12584. /** Start */
  12585. Start = 4,
  12586. /** Back */
  12587. Back = 5,
  12588. /** Left button */
  12589. LB = 6,
  12590. /** Right button */
  12591. RB = 7,
  12592. /** Left stick */
  12593. LeftStick = 8,
  12594. /** Right stick */
  12595. RightStick = 9
  12596. }
  12597. /** Defines values for XBox360 DPad */
  12598. enum Xbox360Dpad {
  12599. /** Up */
  12600. Up = 0,
  12601. /** Down */
  12602. Down = 1,
  12603. /** Left */
  12604. Left = 2,
  12605. /** Right */
  12606. Right = 3
  12607. }
  12608. /**
  12609. * Defines a XBox360 gamepad
  12610. */
  12611. class Xbox360Pad extends Gamepad {
  12612. private _leftTrigger;
  12613. private _rightTrigger;
  12614. private _onlefttriggerchanged;
  12615. private _onrighttriggerchanged;
  12616. private _onbuttondown;
  12617. private _onbuttonup;
  12618. private _ondpaddown;
  12619. private _ondpadup;
  12620. /** Observable raised when a button is pressed */
  12621. onButtonDownObservable: Observable<Xbox360Button>;
  12622. /** Observable raised when a button is released */
  12623. onButtonUpObservable: Observable<Xbox360Button>;
  12624. /** Observable raised when a pad is pressed */
  12625. onPadDownObservable: Observable<Xbox360Dpad>;
  12626. /** Observable raised when a pad is released */
  12627. onPadUpObservable: Observable<Xbox360Dpad>;
  12628. private _buttonA;
  12629. private _buttonB;
  12630. private _buttonX;
  12631. private _buttonY;
  12632. private _buttonBack;
  12633. private _buttonStart;
  12634. private _buttonLB;
  12635. private _buttonRB;
  12636. private _buttonLeftStick;
  12637. private _buttonRightStick;
  12638. private _dPadUp;
  12639. private _dPadDown;
  12640. private _dPadLeft;
  12641. private _dPadRight;
  12642. private _isXboxOnePad;
  12643. /**
  12644. * Creates a new XBox360 gamepad object
  12645. * @param id defines the id of this gamepad
  12646. * @param index defines its index
  12647. * @param gamepad defines the internal HTML gamepad object
  12648. * @param xboxOne defines if it is a XBox One gamepad
  12649. */
  12650. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  12651. /**
  12652. * Defines the callback to call when left trigger is pressed
  12653. * @param callback defines the callback to use
  12654. */
  12655. onlefttriggerchanged(callback: (value: number) => void): void;
  12656. /**
  12657. * Defines the callback to call when right trigger is pressed
  12658. * @param callback defines the callback to use
  12659. */
  12660. onrighttriggerchanged(callback: (value: number) => void): void;
  12661. /**
  12662. * Gets the left trigger value
  12663. */
  12664. /**
  12665. * Sets the left trigger value
  12666. */
  12667. leftTrigger: number;
  12668. /**
  12669. * Gets the right trigger value
  12670. */
  12671. /**
  12672. * Sets the right trigger value
  12673. */
  12674. rightTrigger: number;
  12675. /**
  12676. * Defines the callback to call when a button is pressed
  12677. * @param callback defines the callback to use
  12678. */
  12679. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  12680. /**
  12681. * Defines the callback to call when a button is released
  12682. * @param callback defines the callback to use
  12683. */
  12684. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  12685. /**
  12686. * Defines the callback to call when a pad is pressed
  12687. * @param callback defines the callback to use
  12688. */
  12689. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  12690. /**
  12691. * Defines the callback to call when a pad is released
  12692. * @param callback defines the callback to use
  12693. */
  12694. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  12695. private _setButtonValue;
  12696. private _setDPadValue;
  12697. /**
  12698. * Gets the value of the `A` button
  12699. */
  12700. /**
  12701. * Sets the value of the `A` button
  12702. */
  12703. buttonA: number;
  12704. /**
  12705. * Gets the value of the `B` button
  12706. */
  12707. /**
  12708. * Sets the value of the `B` button
  12709. */
  12710. buttonB: number;
  12711. /**
  12712. * Gets the value of the `X` button
  12713. */
  12714. /**
  12715. * Sets the value of the `X` button
  12716. */
  12717. buttonX: number;
  12718. /**
  12719. * Gets the value of the `Y` button
  12720. */
  12721. /**
  12722. * Sets the value of the `Y` button
  12723. */
  12724. buttonY: number;
  12725. /**
  12726. * Gets the value of the `Start` button
  12727. */
  12728. /**
  12729. * Sets the value of the `Start` button
  12730. */
  12731. buttonStart: number;
  12732. /**
  12733. * Gets the value of the `Back` button
  12734. */
  12735. /**
  12736. * Sets the value of the `Back` button
  12737. */
  12738. buttonBack: number;
  12739. /**
  12740. * Gets the value of the `Left` button
  12741. */
  12742. /**
  12743. * Sets the value of the `Left` button
  12744. */
  12745. buttonLB: number;
  12746. /**
  12747. * Gets the value of the `Right` button
  12748. */
  12749. /**
  12750. * Sets the value of the `Right` button
  12751. */
  12752. buttonRB: number;
  12753. /**
  12754. * Gets the value of the Left joystick
  12755. */
  12756. /**
  12757. * Sets the value of the Left joystick
  12758. */
  12759. buttonLeftStick: number;
  12760. /**
  12761. * Gets the value of the Right joystick
  12762. */
  12763. /**
  12764. * Sets the value of the Right joystick
  12765. */
  12766. buttonRightStick: number;
  12767. /**
  12768. * Gets the value of D-pad up
  12769. */
  12770. /**
  12771. * Sets the value of D-pad up
  12772. */
  12773. dPadUp: number;
  12774. /**
  12775. * Gets the value of D-pad down
  12776. */
  12777. /**
  12778. * Sets the value of D-pad down
  12779. */
  12780. dPadDown: number;
  12781. /**
  12782. * Gets the value of D-pad left
  12783. */
  12784. /**
  12785. * Sets the value of D-pad left
  12786. */
  12787. dPadLeft: number;
  12788. /**
  12789. * Gets the value of D-pad right
  12790. */
  12791. /**
  12792. * Sets the value of D-pad right
  12793. */
  12794. dPadRight: number;
  12795. /**
  12796. * Force the gamepad to synchronize with device values
  12797. */
  12798. update(): void;
  12799. /**
  12800. * Disposes the gamepad
  12801. */
  12802. dispose(): void;
  12803. }
  12804. }
  12805. declare module BABYLON {
  12806. /**
  12807. * Single axis drag gizmo
  12808. */
  12809. class AxisDragGizmo extends Gizmo {
  12810. /**
  12811. * Drag behavior responsible for the gizmos dragging interactions
  12812. */
  12813. dragBehavior: PointerDragBehavior;
  12814. private _pointerObserver;
  12815. /**
  12816. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  12817. */
  12818. snapDistance: number;
  12819. /**
  12820. * Event that fires each time the gizmo snaps to a new location.
  12821. * * snapDistance is the the change in distance
  12822. */
  12823. onSnapObservable: Observable<{
  12824. snapDistance: number;
  12825. }>;
  12826. /**
  12827. * Creates an AxisDragGizmo
  12828. * @param gizmoLayer The utility layer the gizmo will be added to
  12829. * @param dragAxis The axis which the gizmo will be able to drag on
  12830. * @param color The color of the gizmo
  12831. */
  12832. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  12833. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  12834. /**
  12835. * Disposes of the gizmo
  12836. */
  12837. dispose(): void;
  12838. }
  12839. }
  12840. declare module BABYLON {
  12841. /**
  12842. * Single axis scale gizmo
  12843. */
  12844. class AxisScaleGizmo extends Gizmo {
  12845. private _coloredMaterial;
  12846. /**
  12847. * Drag behavior responsible for the gizmos dragging interactions
  12848. */
  12849. dragBehavior: PointerDragBehavior;
  12850. private _pointerObserver;
  12851. /**
  12852. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  12853. */
  12854. snapDistance: number;
  12855. /**
  12856. * Event that fires each time the gizmo snaps to a new location.
  12857. * * snapDistance is the the change in distance
  12858. */
  12859. onSnapObservable: Observable<{
  12860. snapDistance: number;
  12861. }>;
  12862. /**
  12863. * If the scaling operation should be done on all axis (default: false)
  12864. */
  12865. uniformScaling: boolean;
  12866. /**
  12867. * Creates an AxisScaleGizmo
  12868. * @param gizmoLayer The utility layer the gizmo will be added to
  12869. * @param dragAxis The axis which the gizmo will be able to scale on
  12870. * @param color The color of the gizmo
  12871. */
  12872. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  12873. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  12874. /**
  12875. * Disposes of the gizmo
  12876. */
  12877. dispose(): void;
  12878. /**
  12879. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  12880. * @param mesh The mesh to replace the default mesh of the gizmo
  12881. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  12882. */
  12883. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  12884. }
  12885. }
  12886. declare module BABYLON {
  12887. /**
  12888. * Bounding box gizmo
  12889. */
  12890. class BoundingBoxGizmo extends Gizmo {
  12891. private _lineBoundingBox;
  12892. private _rotateSpheresParent;
  12893. private _scaleBoxesParent;
  12894. private _boundingDimensions;
  12895. private _renderObserver;
  12896. private _pointerObserver;
  12897. private _scaleDragSpeed;
  12898. private _tmpQuaternion;
  12899. private _tmpVector;
  12900. private _tmpRotationMatrix;
  12901. /**
  12902. * 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)
  12903. */
  12904. ignoreChildren: boolean;
  12905. /**
  12906. * 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)
  12907. */
  12908. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  12909. /**
  12910. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  12911. */
  12912. rotationSphereSize: number;
  12913. /**
  12914. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  12915. */
  12916. scaleBoxSize: number;
  12917. /**
  12918. * 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)
  12919. */
  12920. fixedDragMeshScreenSize: boolean;
  12921. /**
  12922. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  12923. */
  12924. fixedDragMeshScreenSizeDistanceFactor: number;
  12925. /**
  12926. * Fired when a rotation sphere or scale box is dragged
  12927. */
  12928. onDragStartObservable: Observable<{}>;
  12929. /**
  12930. * Fired when a scale box is dragged
  12931. */
  12932. onScaleBoxDragObservable: Observable<{}>;
  12933. /**
  12934. * Fired when a scale box drag is ended
  12935. */
  12936. onScaleBoxDragEndObservable: Observable<{}>;
  12937. /**
  12938. * Fired when a rotation sphere is dragged
  12939. */
  12940. onRotationSphereDragObservable: Observable<{}>;
  12941. /**
  12942. * Fired when a rotation sphere drag is ended
  12943. */
  12944. onRotationSphereDragEndObservable: Observable<{}>;
  12945. /**
  12946. * 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)
  12947. */
  12948. scalePivot: Nullable<Vector3>;
  12949. private _anchorMesh;
  12950. private _existingMeshScale;
  12951. private static _PivotCached;
  12952. private static _OldPivotPoint;
  12953. private static _PivotTranslation;
  12954. private static _PivotTmpVector;
  12955. /** @hidden */
  12956. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  12957. /** @hidden */
  12958. static _RestorePivotPoint(mesh: AbstractMesh): void;
  12959. /**
  12960. * Creates an BoundingBoxGizmo
  12961. * @param gizmoLayer The utility layer the gizmo will be added to
  12962. * @param color The color of the gizmo
  12963. */
  12964. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  12965. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  12966. private _selectNode;
  12967. /**
  12968. * Updates the bounding box information for the Gizmo
  12969. */
  12970. updateBoundingBox(): void;
  12971. /**
  12972. * Enables rotation on the specified axis and disables rotation on the others
  12973. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  12974. */
  12975. setEnabledRotationAxis(axis: string): void;
  12976. /**
  12977. * Disposes of the gizmo
  12978. */
  12979. dispose(): void;
  12980. /**
  12981. * 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)
  12982. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  12983. * @returns the bounding box mesh with the passed in mesh as a child
  12984. */
  12985. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  12986. /**
  12987. * CustomMeshes are not supported by this gizmo
  12988. * @param mesh The mesh to replace the default mesh of the gizmo
  12989. */
  12990. setCustomMesh(mesh: Mesh): void;
  12991. }
  12992. }
  12993. declare module BABYLON {
  12994. /**
  12995. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  12996. */
  12997. class Gizmo implements IDisposable {
  12998. /** The utility layer the gizmo will be added to */
  12999. gizmoLayer: UtilityLayerRenderer;
  13000. /**
  13001. * The root mesh of the gizmo
  13002. */
  13003. protected _rootMesh: Mesh;
  13004. private _attachedMesh;
  13005. /**
  13006. * Ratio for the scale of the gizmo (Default: 1)
  13007. */
  13008. scaleRatio: number;
  13009. private _tmpMatrix;
  13010. /**
  13011. * If a custom mesh has been set (Default: false)
  13012. */
  13013. protected _customMeshSet: boolean;
  13014. /**
  13015. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  13016. * * When set, interactions will be enabled
  13017. */
  13018. attachedMesh: Nullable<AbstractMesh>;
  13019. /**
  13020. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  13021. * @param mesh The mesh to replace the default mesh of the gizmo
  13022. */
  13023. setCustomMesh(mesh: Mesh): void;
  13024. /**
  13025. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  13026. */
  13027. updateGizmoRotationToMatchAttachedMesh: boolean;
  13028. /**
  13029. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  13030. */
  13031. updateGizmoPositionToMatchAttachedMesh: boolean;
  13032. /**
  13033. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  13034. */
  13035. protected _updateScale: boolean;
  13036. protected _interactionsEnabled: boolean;
  13037. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  13038. private _beforeRenderObserver;
  13039. /**
  13040. * Creates a gizmo
  13041. * @param gizmoLayer The utility layer the gizmo will be added to
  13042. */
  13043. constructor(
  13044. /** The utility layer the gizmo will be added to */
  13045. gizmoLayer?: UtilityLayerRenderer);
  13046. private _tempVector;
  13047. /**
  13048. * @hidden
  13049. * Updates the gizmo to match the attached mesh's position/rotation
  13050. */
  13051. protected _update(): void;
  13052. /**
  13053. * Disposes of the gizmo
  13054. */
  13055. dispose(): void;
  13056. }
  13057. }
  13058. declare module BABYLON {
  13059. /**
  13060. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  13061. */
  13062. class GizmoManager implements IDisposable {
  13063. private scene;
  13064. /**
  13065. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  13066. */
  13067. gizmos: {
  13068. positionGizmo: Nullable<PositionGizmo>;
  13069. rotationGizmo: Nullable<RotationGizmo>;
  13070. scaleGizmo: Nullable<ScaleGizmo>;
  13071. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  13072. };
  13073. private _gizmosEnabled;
  13074. private _pointerObserver;
  13075. private _attachedMesh;
  13076. private _boundingBoxColor;
  13077. private _defaultUtilityLayer;
  13078. private _defaultKeepDepthUtilityLayer;
  13079. /**
  13080. * When bounding box gizmo is enabled, this can be used to track drag/end events
  13081. */
  13082. boundingBoxDragBehavior: SixDofDragBehavior;
  13083. /**
  13084. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  13085. */
  13086. attachableMeshes: Nullable<Array<AbstractMesh>>;
  13087. /**
  13088. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  13089. */
  13090. usePointerToAttachGizmos: boolean;
  13091. /**
  13092. * Instatiates a gizmo manager
  13093. * @param scene the scene to overlay the gizmos on top of
  13094. */
  13095. constructor(scene: Scene);
  13096. /**
  13097. * Attaches a set of gizmos to the specified mesh
  13098. * @param mesh The mesh the gizmo's should be attached to
  13099. */
  13100. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  13101. /**
  13102. * If the position gizmo is enabled
  13103. */
  13104. positionGizmoEnabled: boolean;
  13105. /**
  13106. * If the rotation gizmo is enabled
  13107. */
  13108. rotationGizmoEnabled: boolean;
  13109. /**
  13110. * If the scale gizmo is enabled
  13111. */
  13112. scaleGizmoEnabled: boolean;
  13113. /**
  13114. * If the boundingBox gizmo is enabled
  13115. */
  13116. boundingBoxGizmoEnabled: boolean;
  13117. /**
  13118. * Disposes of the gizmo manager
  13119. */
  13120. dispose(): void;
  13121. }
  13122. }
  13123. declare module BABYLON {
  13124. /**
  13125. * Single plane rotation gizmo
  13126. */
  13127. class PlaneRotationGizmo extends Gizmo {
  13128. /**
  13129. * Drag behavior responsible for the gizmos dragging interactions
  13130. */
  13131. dragBehavior: PointerDragBehavior;
  13132. private _pointerObserver;
  13133. /**
  13134. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  13135. */
  13136. snapDistance: number;
  13137. /**
  13138. * Event that fires each time the gizmo snaps to a new location.
  13139. * * snapDistance is the the change in distance
  13140. */
  13141. onSnapObservable: Observable<{
  13142. snapDistance: number;
  13143. }>;
  13144. /**
  13145. * Creates a PlaneRotationGizmo
  13146. * @param gizmoLayer The utility layer the gizmo will be added to
  13147. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  13148. * @param color The color of the gizmo
  13149. * @param tessellation Amount of tessellation to be used when creating rotation circles
  13150. */
  13151. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  13152. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  13153. /**
  13154. * Disposes of the gizmo
  13155. */
  13156. dispose(): void;
  13157. }
  13158. }
  13159. declare module BABYLON {
  13160. /**
  13161. * Gizmo that enables dragging a mesh along 3 axis
  13162. */
  13163. class PositionGizmo extends Gizmo {
  13164. /**
  13165. * Internal gizmo used for interactions on the x axis
  13166. */
  13167. xGizmo: AxisDragGizmo;
  13168. /**
  13169. * Internal gizmo used for interactions on the y axis
  13170. */
  13171. yGizmo: AxisDragGizmo;
  13172. /**
  13173. * Internal gizmo used for interactions on the z axis
  13174. */
  13175. zGizmo: AxisDragGizmo;
  13176. /** Fires an event when any of it's sub gizmos are dragged */
  13177. onDragStartObservable: Observable<{}>;
  13178. /** Fires an event when any of it's sub gizmos are released from dragging */
  13179. onDragEndObservable: Observable<{}>;
  13180. attachedMesh: Nullable<AbstractMesh>;
  13181. /**
  13182. * Creates a PositionGizmo
  13183. * @param gizmoLayer The utility layer the gizmo will be added to
  13184. */
  13185. constructor(gizmoLayer?: UtilityLayerRenderer);
  13186. updateGizmoRotationToMatchAttachedMesh: boolean;
  13187. /**
  13188. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  13189. */
  13190. snapDistance: number;
  13191. /**
  13192. * Ratio for the scale of the gizmo (Default: 1)
  13193. */
  13194. scaleRatio: number;
  13195. /**
  13196. * Disposes of the gizmo
  13197. */
  13198. dispose(): void;
  13199. /**
  13200. * CustomMeshes are not supported by this gizmo
  13201. * @param mesh The mesh to replace the default mesh of the gizmo
  13202. */
  13203. setCustomMesh(mesh: Mesh): void;
  13204. }
  13205. }
  13206. declare module BABYLON {
  13207. /**
  13208. * Gizmo that enables rotating a mesh along 3 axis
  13209. */
  13210. class RotationGizmo extends Gizmo {
  13211. /**
  13212. * Internal gizmo used for interactions on the x axis
  13213. */
  13214. xGizmo: PlaneRotationGizmo;
  13215. /**
  13216. * Internal gizmo used for interactions on the y axis
  13217. */
  13218. yGizmo: PlaneRotationGizmo;
  13219. /**
  13220. * Internal gizmo used for interactions on the z axis
  13221. */
  13222. zGizmo: PlaneRotationGizmo;
  13223. /** Fires an event when any of it's sub gizmos are dragged */
  13224. onDragStartObservable: Observable<{}>;
  13225. /** Fires an event when any of it's sub gizmos are released from dragging */
  13226. onDragEndObservable: Observable<{}>;
  13227. attachedMesh: Nullable<AbstractMesh>;
  13228. /**
  13229. * Creates a RotationGizmo
  13230. * @param gizmoLayer The utility layer the gizmo will be added to
  13231. * @param tessellation Amount of tessellation to be used when creating rotation circles
  13232. */
  13233. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  13234. updateGizmoRotationToMatchAttachedMesh: boolean;
  13235. /**
  13236. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  13237. */
  13238. snapDistance: number;
  13239. /**
  13240. * Ratio for the scale of the gizmo (Default: 1)
  13241. */
  13242. scaleRatio: number;
  13243. /**
  13244. * Disposes of the gizmo
  13245. */
  13246. dispose(): void;
  13247. /**
  13248. * CustomMeshes are not supported by this gizmo
  13249. * @param mesh The mesh to replace the default mesh of the gizmo
  13250. */
  13251. setCustomMesh(mesh: Mesh): void;
  13252. }
  13253. }
  13254. declare module BABYLON {
  13255. /**
  13256. * Gizmo that enables scaling a mesh along 3 axis
  13257. */
  13258. class ScaleGizmo extends Gizmo {
  13259. /**
  13260. * Internal gizmo used for interactions on the x axis
  13261. */
  13262. xGizmo: AxisScaleGizmo;
  13263. /**
  13264. * Internal gizmo used for interactions on the y axis
  13265. */
  13266. yGizmo: AxisScaleGizmo;
  13267. /**
  13268. * Internal gizmo used for interactions on the z axis
  13269. */
  13270. zGizmo: AxisScaleGizmo;
  13271. /**
  13272. * Internal gizmo used to scale all axis equally
  13273. */
  13274. uniformScaleGizmo: AxisScaleGizmo;
  13275. /** Fires an event when any of it's sub gizmos are dragged */
  13276. onDragStartObservable: Observable<{}>;
  13277. /** Fires an event when any of it's sub gizmos are released from dragging */
  13278. onDragEndObservable: Observable<{}>;
  13279. attachedMesh: Nullable<AbstractMesh>;
  13280. /**
  13281. * Creates a ScaleGizmo
  13282. * @param gizmoLayer The utility layer the gizmo will be added to
  13283. */
  13284. constructor(gizmoLayer?: UtilityLayerRenderer);
  13285. updateGizmoRotationToMatchAttachedMesh: boolean;
  13286. /**
  13287. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  13288. */
  13289. snapDistance: number;
  13290. /**
  13291. * Ratio for the scale of the gizmo (Default: 1)
  13292. */
  13293. scaleRatio: number;
  13294. /**
  13295. * Disposes of the gizmo
  13296. */
  13297. dispose(): void;
  13298. }
  13299. }
  13300. declare module BABYLON {
  13301. /**
  13302. * Represents the different options available during the creation of
  13303. * a Environment helper.
  13304. *
  13305. * This can control the default ground, skybox and image processing setup of your scene.
  13306. */
  13307. interface IEnvironmentHelperOptions {
  13308. /**
  13309. * Specifies wether or not to create a ground.
  13310. * True by default.
  13311. */
  13312. createGround: boolean;
  13313. /**
  13314. * Specifies the ground size.
  13315. * 15 by default.
  13316. */
  13317. groundSize: number;
  13318. /**
  13319. * The texture used on the ground for the main color.
  13320. * Comes from the BabylonJS CDN by default.
  13321. *
  13322. * Remarks: Can be either a texture or a url.
  13323. */
  13324. groundTexture: string | BaseTexture;
  13325. /**
  13326. * The color mixed in the ground texture by default.
  13327. * BabylonJS clearColor by default.
  13328. */
  13329. groundColor: Color3;
  13330. /**
  13331. * Specifies the ground opacity.
  13332. * 1 by default.
  13333. */
  13334. groundOpacity: number;
  13335. /**
  13336. * Enables the ground to receive shadows.
  13337. * True by default.
  13338. */
  13339. enableGroundShadow: boolean;
  13340. /**
  13341. * Helps preventing the shadow to be fully black on the ground.
  13342. * 0.5 by default.
  13343. */
  13344. groundShadowLevel: number;
  13345. /**
  13346. * Creates a mirror texture attach to the ground.
  13347. * false by default.
  13348. */
  13349. enableGroundMirror: boolean;
  13350. /**
  13351. * Specifies the ground mirror size ratio.
  13352. * 0.3 by default as the default kernel is 64.
  13353. */
  13354. groundMirrorSizeRatio: number;
  13355. /**
  13356. * Specifies the ground mirror blur kernel size.
  13357. * 64 by default.
  13358. */
  13359. groundMirrorBlurKernel: number;
  13360. /**
  13361. * Specifies the ground mirror visibility amount.
  13362. * 1 by default
  13363. */
  13364. groundMirrorAmount: number;
  13365. /**
  13366. * Specifies the ground mirror reflectance weight.
  13367. * This uses the standard weight of the background material to setup the fresnel effect
  13368. * of the mirror.
  13369. * 1 by default.
  13370. */
  13371. groundMirrorFresnelWeight: number;
  13372. /**
  13373. * Specifies the ground mirror Falloff distance.
  13374. * This can helps reducing the size of the reflection.
  13375. * 0 by Default.
  13376. */
  13377. groundMirrorFallOffDistance: number;
  13378. /**
  13379. * Specifies the ground mirror texture type.
  13380. * Unsigned Int by Default.
  13381. */
  13382. groundMirrorTextureType: number;
  13383. /**
  13384. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  13385. * the shown objects.
  13386. */
  13387. groundYBias: number;
  13388. /**
  13389. * Specifies wether or not to create a skybox.
  13390. * True by default.
  13391. */
  13392. createSkybox: boolean;
  13393. /**
  13394. * Specifies the skybox size.
  13395. * 20 by default.
  13396. */
  13397. skyboxSize: number;
  13398. /**
  13399. * The texture used on the skybox for the main color.
  13400. * Comes from the BabylonJS CDN by default.
  13401. *
  13402. * Remarks: Can be either a texture or a url.
  13403. */
  13404. skyboxTexture: string | BaseTexture;
  13405. /**
  13406. * The color mixed in the skybox texture by default.
  13407. * BabylonJS clearColor by default.
  13408. */
  13409. skyboxColor: Color3;
  13410. /**
  13411. * The background rotation around the Y axis of the scene.
  13412. * This helps aligning the key lights of your scene with the background.
  13413. * 0 by default.
  13414. */
  13415. backgroundYRotation: number;
  13416. /**
  13417. * Compute automatically the size of the elements to best fit with the scene.
  13418. */
  13419. sizeAuto: boolean;
  13420. /**
  13421. * Default position of the rootMesh if autoSize is not true.
  13422. */
  13423. rootPosition: Vector3;
  13424. /**
  13425. * Sets up the image processing in the scene.
  13426. * true by default.
  13427. */
  13428. setupImageProcessing: boolean;
  13429. /**
  13430. * The texture used as your environment texture in the scene.
  13431. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  13432. *
  13433. * Remarks: Can be either a texture or a url.
  13434. */
  13435. environmentTexture: string | BaseTexture;
  13436. /**
  13437. * The value of the exposure to apply to the scene.
  13438. * 0.6 by default if setupImageProcessing is true.
  13439. */
  13440. cameraExposure: number;
  13441. /**
  13442. * The value of the contrast to apply to the scene.
  13443. * 1.6 by default if setupImageProcessing is true.
  13444. */
  13445. cameraContrast: number;
  13446. /**
  13447. * Specifies wether or not tonemapping should be enabled in the scene.
  13448. * true by default if setupImageProcessing is true.
  13449. */
  13450. toneMappingEnabled: boolean;
  13451. }
  13452. /**
  13453. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  13454. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  13455. * It also helps with the default setup of your imageProcessing configuration.
  13456. */
  13457. class EnvironmentHelper {
  13458. /**
  13459. * Default ground texture URL.
  13460. */
  13461. private static _groundTextureCDNUrl;
  13462. /**
  13463. * Default skybox texture URL.
  13464. */
  13465. private static _skyboxTextureCDNUrl;
  13466. /**
  13467. * Default environment texture URL.
  13468. */
  13469. private static _environmentTextureCDNUrl;
  13470. /**
  13471. * Creates the default options for the helper.
  13472. */
  13473. private static _getDefaultOptions;
  13474. private _rootMesh;
  13475. /**
  13476. * Gets the root mesh created by the helper.
  13477. */
  13478. readonly rootMesh: Mesh;
  13479. private _skybox;
  13480. /**
  13481. * Gets the skybox created by the helper.
  13482. */
  13483. readonly skybox: Nullable<Mesh>;
  13484. private _skyboxTexture;
  13485. /**
  13486. * Gets the skybox texture created by the helper.
  13487. */
  13488. readonly skyboxTexture: Nullable<BaseTexture>;
  13489. private _skyboxMaterial;
  13490. /**
  13491. * Gets the skybox material created by the helper.
  13492. */
  13493. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  13494. private _ground;
  13495. /**
  13496. * Gets the ground mesh created by the helper.
  13497. */
  13498. readonly ground: Nullable<Mesh>;
  13499. private _groundTexture;
  13500. /**
  13501. * Gets the ground texture created by the helper.
  13502. */
  13503. readonly groundTexture: Nullable<BaseTexture>;
  13504. private _groundMirror;
  13505. /**
  13506. * Gets the ground mirror created by the helper.
  13507. */
  13508. readonly groundMirror: Nullable<MirrorTexture>;
  13509. /**
  13510. * Gets the ground mirror render list to helps pushing the meshes
  13511. * you wish in the ground reflection.
  13512. */
  13513. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  13514. private _groundMaterial;
  13515. /**
  13516. * Gets the ground material created by the helper.
  13517. */
  13518. readonly groundMaterial: Nullable<BackgroundMaterial>;
  13519. /**
  13520. * Stores the creation options.
  13521. */
  13522. private readonly _scene;
  13523. private _options;
  13524. /**
  13525. * This observable will be notified with any error during the creation of the environment,
  13526. * mainly texture creation errors.
  13527. */
  13528. onErrorObservable: Observable<{
  13529. message?: string;
  13530. exception?: any;
  13531. }>;
  13532. /**
  13533. * constructor
  13534. * @param options
  13535. * @param scene The scene to add the material to
  13536. */
  13537. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  13538. /**
  13539. * Updates the background according to the new options
  13540. * @param options
  13541. */
  13542. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  13543. /**
  13544. * Sets the primary color of all the available elements.
  13545. * @param color the main color to affect to the ground and the background
  13546. */
  13547. setMainColor(color: Color3): void;
  13548. /**
  13549. * Setup the image processing according to the specified options.
  13550. */
  13551. private _setupImageProcessing;
  13552. /**
  13553. * Setup the environment texture according to the specified options.
  13554. */
  13555. private _setupEnvironmentTexture;
  13556. /**
  13557. * Setup the background according to the specified options.
  13558. */
  13559. private _setupBackground;
  13560. /**
  13561. * Get the scene sizes according to the setup.
  13562. */
  13563. private _getSceneSize;
  13564. /**
  13565. * Setup the ground according to the specified options.
  13566. */
  13567. private _setupGround;
  13568. /**
  13569. * Setup the ground material according to the specified options.
  13570. */
  13571. private _setupGroundMaterial;
  13572. /**
  13573. * Setup the ground diffuse texture according to the specified options.
  13574. */
  13575. private _setupGroundDiffuseTexture;
  13576. /**
  13577. * Setup the ground mirror texture according to the specified options.
  13578. */
  13579. private _setupGroundMirrorTexture;
  13580. /**
  13581. * Setup the ground to receive the mirror texture.
  13582. */
  13583. private _setupMirrorInGroundMaterial;
  13584. /**
  13585. * Setup the skybox according to the specified options.
  13586. */
  13587. private _setupSkybox;
  13588. /**
  13589. * Setup the skybox material according to the specified options.
  13590. */
  13591. private _setupSkyboxMaterial;
  13592. /**
  13593. * Setup the skybox reflection texture according to the specified options.
  13594. */
  13595. private _setupSkyboxReflectionTexture;
  13596. private _errorHandler;
  13597. /**
  13598. * Dispose all the elements created by the Helper.
  13599. */
  13600. dispose(): void;
  13601. }
  13602. }
  13603. declare module BABYLON {
  13604. /**
  13605. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  13606. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  13607. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  13608. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  13609. */
  13610. class PhotoDome extends TransformNode {
  13611. private _useDirectMapping;
  13612. /**
  13613. * The texture being displayed on the sphere
  13614. */
  13615. protected _photoTexture: Texture;
  13616. /**
  13617. * Gets or sets the texture being displayed on the sphere
  13618. */
  13619. photoTexture: Texture;
  13620. /**
  13621. * Observable raised when an error occured while loading the 360 image
  13622. */
  13623. onLoadErrorObservable: Observable<string>;
  13624. /**
  13625. * The skybox material
  13626. */
  13627. protected _material: BackgroundMaterial;
  13628. /**
  13629. * The surface used for the skybox
  13630. */
  13631. protected _mesh: Mesh;
  13632. /**
  13633. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  13634. * Also see the options.resolution property.
  13635. */
  13636. fovMultiplier: number;
  13637. /**
  13638. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  13639. * @param name Element's name, child elements will append suffixes for their own names.
  13640. * @param urlsOfPhoto defines the url of the photo to display
  13641. * @param options defines an object containing optional or exposed sub element properties
  13642. * @param onError defines a callback called when an error occured while loading the texture
  13643. */
  13644. constructor(name: string, urlOfPhoto: string, options: {
  13645. resolution?: number;
  13646. size?: number;
  13647. useDirectMapping?: boolean;
  13648. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  13649. /**
  13650. * Releases resources associated with this node.
  13651. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  13652. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  13653. */
  13654. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  13655. }
  13656. }
  13657. declare module BABYLON {
  13658. interface Scene {
  13659. /**
  13660. * Creates a default light for the scene.
  13661. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  13662. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  13663. */
  13664. createDefaultLight(replace?: boolean): void;
  13665. /**
  13666. * Creates a default camera for the scene.
  13667. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  13668. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  13669. * @param replace has default false, when true replaces the active camera in the scene
  13670. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  13671. */
  13672. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  13673. /**
  13674. * Creates a default camera and a default light.
  13675. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  13676. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  13677. * @param replace has the default false, when true replaces the active camera/light in the scene
  13678. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  13679. */
  13680. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  13681. /**
  13682. * Creates a new sky box
  13683. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  13684. * @param environmentTexture defines the texture to use as environment texture
  13685. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  13686. * @param scale defines the overall scale of the skybox
  13687. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  13688. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  13689. * @returns a new mesh holding the sky box
  13690. */
  13691. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  13692. /**
  13693. * Creates a new environment
  13694. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  13695. * @param options defines the options you can use to configure the environment
  13696. * @returns the new EnvironmentHelper
  13697. */
  13698. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  13699. /**
  13700. * Creates a new VREXperienceHelper
  13701. * @see http://doc.babylonjs.com/how_to/webvr_helper
  13702. * @param webVROptions defines the options used to create the new VREXperienceHelper
  13703. * @returns a new VREXperienceHelper
  13704. */
  13705. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  13706. }
  13707. }
  13708. declare module BABYLON {
  13709. /**
  13710. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  13711. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  13712. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  13713. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  13714. */
  13715. class VideoDome extends TransformNode {
  13716. private _useDirectMapping;
  13717. /**
  13718. * The video texture being displayed on the sphere
  13719. */
  13720. protected _videoTexture: VideoTexture;
  13721. /**
  13722. * Gets the video texture being displayed on the sphere
  13723. */
  13724. readonly videoTexture: VideoTexture;
  13725. /**
  13726. * The skybox material
  13727. */
  13728. protected _material: BackgroundMaterial;
  13729. /**
  13730. * The surface used for the skybox
  13731. */
  13732. protected _mesh: Mesh;
  13733. /**
  13734. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  13735. * Also see the options.resolution property.
  13736. */
  13737. fovMultiplier: number;
  13738. /**
  13739. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  13740. * @param name Element's name, child elements will append suffixes for their own names.
  13741. * @param urlsOrVideo defines the url(s) or the video element to use
  13742. * @param options An object containing optional or exposed sub element properties
  13743. */
  13744. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  13745. resolution?: number;
  13746. clickToPlay?: boolean;
  13747. autoPlay?: boolean;
  13748. loop?: boolean;
  13749. size?: number;
  13750. poster?: string;
  13751. useDirectMapping?: boolean;
  13752. }, scene: Scene);
  13753. /**
  13754. * Releases resources associated with this node.
  13755. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  13756. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  13757. */
  13758. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  13759. }
  13760. }
  13761. declare module BABYLON {
  13762. /**
  13763. * This class can be used to get instrumentation data from a Babylon engine
  13764. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  13765. */
  13766. class EngineInstrumentation implements IDisposable {
  13767. /**
  13768. * Define the instrumented engine.
  13769. */
  13770. engine: Engine;
  13771. private _captureGPUFrameTime;
  13772. private _gpuFrameTimeToken;
  13773. private _gpuFrameTime;
  13774. private _captureShaderCompilationTime;
  13775. private _shaderCompilationTime;
  13776. private _onBeginFrameObserver;
  13777. private _onEndFrameObserver;
  13778. private _onBeforeShaderCompilationObserver;
  13779. private _onAfterShaderCompilationObserver;
  13780. /**
  13781. * Gets the perf counter used for GPU frame time
  13782. */
  13783. readonly gpuFrameTimeCounter: PerfCounter;
  13784. /**
  13785. * Gets the GPU frame time capture status
  13786. */
  13787. /**
  13788. * Enable or disable the GPU frame time capture
  13789. */
  13790. captureGPUFrameTime: boolean;
  13791. /**
  13792. * Gets the perf counter used for shader compilation time
  13793. */
  13794. readonly shaderCompilationTimeCounter: PerfCounter;
  13795. /**
  13796. * Gets the shader compilation time capture status
  13797. */
  13798. /**
  13799. * Enable or disable the shader compilation time capture
  13800. */
  13801. captureShaderCompilationTime: boolean;
  13802. /**
  13803. * Instantiates a new engine instrumentation.
  13804. * This class can be used to get instrumentation data from a Babylon engine
  13805. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  13806. * @param engine Defines the engine to instrument
  13807. */
  13808. constructor(
  13809. /**
  13810. * Define the instrumented engine.
  13811. */
  13812. engine: Engine);
  13813. /**
  13814. * Dispose and release associated resources.
  13815. */
  13816. dispose(): void;
  13817. }
  13818. }
  13819. declare module BABYLON {
  13820. /**
  13821. * This class can be used to get instrumentation data from a Babylon engine
  13822. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  13823. */
  13824. class SceneInstrumentation implements IDisposable {
  13825. /**
  13826. * Defines the scene to instrument
  13827. */
  13828. scene: Scene;
  13829. private _captureActiveMeshesEvaluationTime;
  13830. private _activeMeshesEvaluationTime;
  13831. private _captureRenderTargetsRenderTime;
  13832. private _renderTargetsRenderTime;
  13833. private _captureFrameTime;
  13834. private _frameTime;
  13835. private _captureRenderTime;
  13836. private _renderTime;
  13837. private _captureInterFrameTime;
  13838. private _interFrameTime;
  13839. private _captureParticlesRenderTime;
  13840. private _particlesRenderTime;
  13841. private _captureSpritesRenderTime;
  13842. private _spritesRenderTime;
  13843. private _capturePhysicsTime;
  13844. private _physicsTime;
  13845. private _captureAnimationsTime;
  13846. private _animationsTime;
  13847. private _captureCameraRenderTime;
  13848. private _cameraRenderTime;
  13849. private _onBeforeActiveMeshesEvaluationObserver;
  13850. private _onAfterActiveMeshesEvaluationObserver;
  13851. private _onBeforeRenderTargetsRenderObserver;
  13852. private _onAfterRenderTargetsRenderObserver;
  13853. private _onAfterRenderObserver;
  13854. private _onBeforeDrawPhaseObserver;
  13855. private _onAfterDrawPhaseObserver;
  13856. private _onBeforeAnimationsObserver;
  13857. private _onBeforeParticlesRenderingObserver;
  13858. private _onAfterParticlesRenderingObserver;
  13859. private _onBeforeSpritesRenderingObserver;
  13860. private _onAfterSpritesRenderingObserver;
  13861. private _onBeforePhysicsObserver;
  13862. private _onAfterPhysicsObserver;
  13863. private _onAfterAnimationsObserver;
  13864. private _onBeforeCameraRenderObserver;
  13865. private _onAfterCameraRenderObserver;
  13866. /**
  13867. * Gets the perf counter used for active meshes evaluation time
  13868. */
  13869. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  13870. /**
  13871. * Gets the active meshes evaluation time capture status
  13872. */
  13873. /**
  13874. * Enable or disable the active meshes evaluation time capture
  13875. */
  13876. captureActiveMeshesEvaluationTime: boolean;
  13877. /**
  13878. * Gets the perf counter used for render targets render time
  13879. */
  13880. readonly renderTargetsRenderTimeCounter: PerfCounter;
  13881. /**
  13882. * Gets the render targets render time capture status
  13883. */
  13884. /**
  13885. * Enable or disable the render targets render time capture
  13886. */
  13887. captureRenderTargetsRenderTime: boolean;
  13888. /**
  13889. * Gets the perf counter used for particles render time
  13890. */
  13891. readonly particlesRenderTimeCounter: PerfCounter;
  13892. /**
  13893. * Gets the particles render time capture status
  13894. */
  13895. /**
  13896. * Enable or disable the particles render time capture
  13897. */
  13898. captureParticlesRenderTime: boolean;
  13899. /**
  13900. * Gets the perf counter used for sprites render time
  13901. */
  13902. readonly spritesRenderTimeCounter: PerfCounter;
  13903. /**
  13904. * Gets the sprites render time capture status
  13905. */
  13906. /**
  13907. * Enable or disable the sprites render time capture
  13908. */
  13909. captureSpritesRenderTime: boolean;
  13910. /**
  13911. * Gets the perf counter used for physics time
  13912. */
  13913. readonly physicsTimeCounter: PerfCounter;
  13914. /**
  13915. * Gets the physics time capture status
  13916. */
  13917. /**
  13918. * Enable or disable the physics time capture
  13919. */
  13920. capturePhysicsTime: boolean;
  13921. /**
  13922. * Gets the perf counter used for animations time
  13923. */
  13924. readonly animationsTimeCounter: PerfCounter;
  13925. /**
  13926. * Gets the animations time capture status
  13927. */
  13928. /**
  13929. * Enable or disable the animations time capture
  13930. */
  13931. captureAnimationsTime: boolean;
  13932. /**
  13933. * Gets the perf counter used for frame time capture
  13934. */
  13935. readonly frameTimeCounter: PerfCounter;
  13936. /**
  13937. * Gets the frame time capture status
  13938. */
  13939. /**
  13940. * Enable or disable the frame time capture
  13941. */
  13942. captureFrameTime: boolean;
  13943. /**
  13944. * Gets the perf counter used for inter-frames time capture
  13945. */
  13946. readonly interFrameTimeCounter: PerfCounter;
  13947. /**
  13948. * Gets the inter-frames time capture status
  13949. */
  13950. /**
  13951. * Enable or disable the inter-frames time capture
  13952. */
  13953. captureInterFrameTime: boolean;
  13954. /**
  13955. * Gets the perf counter used for render time capture
  13956. */
  13957. readonly renderTimeCounter: PerfCounter;
  13958. /**
  13959. * Gets the render time capture status
  13960. */
  13961. /**
  13962. * Enable or disable the render time capture
  13963. */
  13964. captureRenderTime: boolean;
  13965. /**
  13966. * Gets the perf counter used for camera render time capture
  13967. */
  13968. readonly cameraRenderTimeCounter: PerfCounter;
  13969. /**
  13970. * Gets the camera render time capture status
  13971. */
  13972. /**
  13973. * Enable or disable the camera render time capture
  13974. */
  13975. captureCameraRenderTime: boolean;
  13976. /**
  13977. * Gets the perf counter used for draw calls
  13978. */
  13979. readonly drawCallsCounter: PerfCounter;
  13980. /**
  13981. * Gets the perf counter used for texture collisions
  13982. */
  13983. readonly textureCollisionsCounter: PerfCounter;
  13984. /**
  13985. * Instantiates a new scene instrumentation.
  13986. * This class can be used to get instrumentation data from a Babylon engine
  13987. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  13988. * @param scene Defines the scene to instrument
  13989. */
  13990. constructor(
  13991. /**
  13992. * Defines the scene to instrument
  13993. */
  13994. scene: Scene);
  13995. /**
  13996. * Dispose and release associated resources.
  13997. */
  13998. dispose(): void;
  13999. }
  14000. }
  14001. declare module BABYLON {
  14002. /**
  14003. * @hidden
  14004. **/
  14005. class _TimeToken {
  14006. _startTimeQuery: Nullable<WebGLQuery>;
  14007. _endTimeQuery: Nullable<WebGLQuery>;
  14008. _timeElapsedQuery: Nullable<WebGLQuery>;
  14009. _timeElapsedQueryEnded: boolean;
  14010. }
  14011. }
  14012. declare module BABYLON {
  14013. /**
  14014. * Effect layer options. This helps customizing the behaviour
  14015. * of the effect layer.
  14016. */
  14017. interface IEffectLayerOptions {
  14018. /**
  14019. * Multiplication factor apply to the canvas size to compute the render target size
  14020. * used to generated the objects (the smaller the faster).
  14021. */
  14022. mainTextureRatio: number;
  14023. /**
  14024. * Enforces a fixed size texture to ensure effect stability across devices.
  14025. */
  14026. mainTextureFixedSize?: number;
  14027. /**
  14028. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  14029. */
  14030. alphaBlendingMode: number;
  14031. /**
  14032. * The camera attached to the layer.
  14033. */
  14034. camera: Nullable<Camera>;
  14035. /**
  14036. * The rendering group to draw the layer in.
  14037. */
  14038. renderingGroupId: number;
  14039. }
  14040. /**
  14041. * The effect layer Helps adding post process effect blended with the main pass.
  14042. *
  14043. * This can be for instance use to generate glow or higlight effects on the scene.
  14044. *
  14045. * The effect layer class can not be used directly and is intented to inherited from to be
  14046. * customized per effects.
  14047. */
  14048. abstract class EffectLayer {
  14049. private _vertexBuffers;
  14050. private _indexBuffer;
  14051. private _cachedDefines;
  14052. private _effectLayerMapGenerationEffect;
  14053. private _effectLayerOptions;
  14054. private _mergeEffect;
  14055. protected _scene: Scene;
  14056. protected _engine: Engine;
  14057. protected _maxSize: number;
  14058. protected _mainTextureDesiredSize: ISize;
  14059. protected _mainTexture: RenderTargetTexture;
  14060. protected _shouldRender: boolean;
  14061. protected _postProcesses: PostProcess[];
  14062. protected _textures: BaseTexture[];
  14063. protected _emissiveTextureAndColor: {
  14064. texture: Nullable<BaseTexture>;
  14065. color: Color4;
  14066. };
  14067. /**
  14068. * The name of the layer
  14069. */
  14070. name: string;
  14071. /**
  14072. * The clear color of the texture used to generate the glow map.
  14073. */
  14074. neutralColor: Color4;
  14075. /**
  14076. * Specifies wether the highlight layer is enabled or not.
  14077. */
  14078. isEnabled: boolean;
  14079. /**
  14080. * Gets the camera attached to the layer.
  14081. */
  14082. readonly camera: Nullable<Camera>;
  14083. /**
  14084. * Gets the rendering group id the layer should render in.
  14085. */
  14086. readonly renderingGroupId: number;
  14087. /**
  14088. * An event triggered when the effect layer has been disposed.
  14089. */
  14090. onDisposeObservable: Observable<EffectLayer>;
  14091. /**
  14092. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  14093. */
  14094. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  14095. /**
  14096. * An event triggered when the generated texture is being merged in the scene.
  14097. */
  14098. onBeforeComposeObservable: Observable<EffectLayer>;
  14099. /**
  14100. * An event triggered when the generated texture has been merged in the scene.
  14101. */
  14102. onAfterComposeObservable: Observable<EffectLayer>;
  14103. /**
  14104. * An event triggered when the efffect layer changes its size.
  14105. */
  14106. onSizeChangedObservable: Observable<EffectLayer>;
  14107. /**
  14108. * Instantiates a new effect Layer and references it in the scene.
  14109. * @param name The name of the layer
  14110. * @param scene The scene to use the layer in
  14111. */
  14112. constructor(
  14113. /** The Friendly of the effect in the scene */
  14114. name: string, scene: Scene);
  14115. /**
  14116. * Get the effect name of the layer.
  14117. * @return The effect name
  14118. */
  14119. abstract getEffectName(): string;
  14120. /**
  14121. * Checks for the readiness of the element composing the layer.
  14122. * @param subMesh the mesh to check for
  14123. * @param useInstances specify wether or not to use instances to render the mesh
  14124. * @return true if ready otherwise, false
  14125. */
  14126. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  14127. /**
  14128. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  14129. * @returns true if the effect requires stencil during the main canvas render pass.
  14130. */
  14131. abstract needStencil(): boolean;
  14132. /**
  14133. * Create the merge effect. This is the shader use to blit the information back
  14134. * to the main canvas at the end of the scene rendering.
  14135. * @returns The effect containing the shader used to merge the effect on the main canvas
  14136. */
  14137. protected abstract _createMergeEffect(): Effect;
  14138. /**
  14139. * Creates the render target textures and post processes used in the effect layer.
  14140. */
  14141. protected abstract _createTextureAndPostProcesses(): void;
  14142. /**
  14143. * Implementation specific of rendering the generating effect on the main canvas.
  14144. * @param effect The effect used to render through
  14145. */
  14146. protected abstract _internalRender(effect: Effect): void;
  14147. /**
  14148. * Sets the required values for both the emissive texture and and the main color.
  14149. */
  14150. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  14151. /**
  14152. * Free any resources and references associated to a mesh.
  14153. * Internal use
  14154. * @param mesh The mesh to free.
  14155. */
  14156. abstract _disposeMesh(mesh: Mesh): void;
  14157. /**
  14158. * Serializes this layer (Glow or Highlight for example)
  14159. * @returns a serialized layer object
  14160. */
  14161. abstract serialize?(): any;
  14162. /**
  14163. * Initializes the effect layer with the required options.
  14164. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  14165. */
  14166. protected _init(options: Partial<IEffectLayerOptions>): void;
  14167. /**
  14168. * Generates the index buffer of the full screen quad blending to the main canvas.
  14169. */
  14170. private _generateIndexBuffer;
  14171. /**
  14172. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  14173. */
  14174. private _genrateVertexBuffer;
  14175. /**
  14176. * Sets the main texture desired size which is the closest power of two
  14177. * of the engine canvas size.
  14178. */
  14179. private _setMainTextureSize;
  14180. /**
  14181. * Creates the main texture for the effect layer.
  14182. */
  14183. protected _createMainTexture(): void;
  14184. /**
  14185. * Checks for the readiness of the element composing the layer.
  14186. * @param subMesh the mesh to check for
  14187. * @param useInstances specify wether or not to use instances to render the mesh
  14188. * @param emissiveTexture the associated emissive texture used to generate the glow
  14189. * @return true if ready otherwise, false
  14190. */
  14191. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  14192. /**
  14193. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  14194. */
  14195. render(): void;
  14196. /**
  14197. * Determine if a given mesh will be used in the current effect.
  14198. * @param mesh mesh to test
  14199. * @returns true if the mesh will be used
  14200. */
  14201. hasMesh(mesh: AbstractMesh): boolean;
  14202. /**
  14203. * Returns true if the layer contains information to display, otherwise false.
  14204. * @returns true if the glow layer should be rendered
  14205. */
  14206. shouldRender(): boolean;
  14207. /**
  14208. * Returns true if the mesh should render, otherwise false.
  14209. * @param mesh The mesh to render
  14210. * @returns true if it should render otherwise false
  14211. */
  14212. protected _shouldRenderMesh(mesh: Mesh): boolean;
  14213. /**
  14214. * Returns true if the mesh should render, otherwise false.
  14215. * @param mesh The mesh to render
  14216. * @returns true if it should render otherwise false
  14217. */
  14218. protected _shouldRenderEmissiveTextureForMesh(mesh: Mesh): boolean;
  14219. /**
  14220. * Renders the submesh passed in parameter to the generation map.
  14221. */
  14222. protected _renderSubMesh(subMesh: SubMesh): void;
  14223. /**
  14224. * Rebuild the required buffers.
  14225. * @hidden Internal use only.
  14226. */
  14227. _rebuild(): void;
  14228. /**
  14229. * Dispose only the render target textures and post process.
  14230. */
  14231. private _disposeTextureAndPostProcesses;
  14232. /**
  14233. * Dispose the highlight layer and free resources.
  14234. */
  14235. dispose(): void;
  14236. /**
  14237. * Gets the class name of the effect layer
  14238. * @returns the string with the class name of the effect layer
  14239. */
  14240. getClassName(): string;
  14241. /**
  14242. * Creates an effect layer from parsed effect layer data
  14243. * @param parsedEffectLayer defines effect layer data
  14244. * @param scene defines the current scene
  14245. * @param rootUrl defines the root URL containing the effect layer information
  14246. * @returns a parsed effect Layer
  14247. */
  14248. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  14249. }
  14250. }
  14251. declare module BABYLON {
  14252. interface AbstractScene {
  14253. /**
  14254. * The list of effect layers (highlights/glow) added to the scene
  14255. * @see http://doc.babylonjs.com/how_to/highlight_layer
  14256. * @see http://doc.babylonjs.com/how_to/glow_layer
  14257. */
  14258. effectLayers: Array<EffectLayer>;
  14259. /**
  14260. * Removes the given effect layer from this scene.
  14261. * @param toRemove defines the effect layer to remove
  14262. * @returns the index of the removed effect layer
  14263. */
  14264. removeEffectLayer(toRemove: EffectLayer): number;
  14265. /**
  14266. * Adds the given effect layer to this scene
  14267. * @param newEffectLayer defines the effect layer to add
  14268. */
  14269. addEffectLayer(newEffectLayer: EffectLayer): void;
  14270. }
  14271. /**
  14272. * Defines the layer scene component responsible to manage any effect layers
  14273. * in a given scene.
  14274. */
  14275. class EffectLayerSceneComponent implements ISceneSerializableComponent {
  14276. /**
  14277. * The component name helpfull to identify the component in the list of scene components.
  14278. */
  14279. readonly name: string;
  14280. /**
  14281. * The scene the component belongs to.
  14282. */
  14283. scene: Scene;
  14284. private _engine;
  14285. private _renderEffects;
  14286. private _needStencil;
  14287. private _previousStencilState;
  14288. /**
  14289. * Creates a new instance of the component for the given scene
  14290. * @param scene Defines the scene to register the component in
  14291. */
  14292. constructor(scene: Scene);
  14293. /**
  14294. * Registers the component in a given scene
  14295. */
  14296. register(): void;
  14297. /**
  14298. * Rebuilds the elements related to this component in case of
  14299. * context lost for instance.
  14300. */
  14301. rebuild(): void;
  14302. /**
  14303. * Serializes the component data to the specified json object
  14304. * @param serializationObject The object to serialize to
  14305. */
  14306. serialize(serializationObject: any): void;
  14307. /**
  14308. * Adds all the element from the container to the scene
  14309. * @param container the container holding the elements
  14310. */
  14311. addFromContainer(container: AbstractScene): void;
  14312. /**
  14313. * Removes all the elements in the container from the scene
  14314. * @param container contains the elements to remove
  14315. */
  14316. removeFromContainer(container: AbstractScene): void;
  14317. /**
  14318. * Disposes the component and the associated ressources.
  14319. */
  14320. dispose(): void;
  14321. private _isReadyForMesh;
  14322. private _renderMainTexture;
  14323. private _setStencil;
  14324. private _setStencilBack;
  14325. private _draw;
  14326. private _drawCamera;
  14327. private _drawRenderingGroup;
  14328. }
  14329. }
  14330. declare module BABYLON {
  14331. interface AbstractScene {
  14332. /**
  14333. * Return a the first highlight layer of the scene with a given name.
  14334. * @param name The name of the highlight layer to look for.
  14335. * @return The highlight layer if found otherwise null.
  14336. */
  14337. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  14338. }
  14339. /**
  14340. * Glow layer options. This helps customizing the behaviour
  14341. * of the glow layer.
  14342. */
  14343. interface IGlowLayerOptions {
  14344. /**
  14345. * Multiplication factor apply to the canvas size to compute the render target size
  14346. * used to generated the glowing objects (the smaller the faster).
  14347. */
  14348. mainTextureRatio: number;
  14349. /**
  14350. * Enforces a fixed size texture to ensure resize independant blur.
  14351. */
  14352. mainTextureFixedSize?: number;
  14353. /**
  14354. * How big is the kernel of the blur texture.
  14355. */
  14356. blurKernelSize: number;
  14357. /**
  14358. * The camera attached to the layer.
  14359. */
  14360. camera: Nullable<Camera>;
  14361. /**
  14362. * Enable MSAA by chosing the number of samples.
  14363. */
  14364. mainTextureSamples?: number;
  14365. /**
  14366. * The rendering group to draw the layer in.
  14367. */
  14368. renderingGroupId: number;
  14369. }
  14370. /**
  14371. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  14372. *
  14373. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  14374. * glowy meshes to your scene.
  14375. *
  14376. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  14377. */
  14378. class GlowLayer extends EffectLayer {
  14379. /**
  14380. * Effect Name of the layer.
  14381. */
  14382. static readonly EffectName: string;
  14383. /**
  14384. * The default blur kernel size used for the glow.
  14385. */
  14386. static DefaultBlurKernelSize: number;
  14387. /**
  14388. * The default texture size ratio used for the glow.
  14389. */
  14390. static DefaultTextureRatio: number;
  14391. /**
  14392. * Sets the kernel size of the blur.
  14393. */
  14394. /**
  14395. * Gets the kernel size of the blur.
  14396. */
  14397. blurKernelSize: number;
  14398. /**
  14399. * Sets the glow intensity.
  14400. */
  14401. /**
  14402. * Gets the glow intensity.
  14403. */
  14404. intensity: number;
  14405. private _options;
  14406. private _intensity;
  14407. private _horizontalBlurPostprocess1;
  14408. private _verticalBlurPostprocess1;
  14409. private _horizontalBlurPostprocess2;
  14410. private _verticalBlurPostprocess2;
  14411. private _blurTexture1;
  14412. private _blurTexture2;
  14413. private _postProcesses1;
  14414. private _postProcesses2;
  14415. private _includedOnlyMeshes;
  14416. private _excludedMeshes;
  14417. /**
  14418. * Callback used to let the user override the color selection on a per mesh basis
  14419. */
  14420. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  14421. /**
  14422. * Callback used to let the user override the texture selection on a per mesh basis
  14423. */
  14424. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  14425. /**
  14426. * Instantiates a new glow Layer and references it to the scene.
  14427. * @param name The name of the layer
  14428. * @param scene The scene to use the layer in
  14429. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  14430. */
  14431. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  14432. /**
  14433. * Get the effect name of the layer.
  14434. * @return The effect name
  14435. */
  14436. getEffectName(): string;
  14437. /**
  14438. * Create the merge effect. This is the shader use to blit the information back
  14439. * to the main canvas at the end of the scene rendering.
  14440. */
  14441. protected _createMergeEffect(): Effect;
  14442. /**
  14443. * Creates the render target textures and post processes used in the glow layer.
  14444. */
  14445. protected _createTextureAndPostProcesses(): void;
  14446. /**
  14447. * Checks for the readiness of the element composing the layer.
  14448. * @param subMesh the mesh to check for
  14449. * @param useInstances specify wether or not to use instances to render the mesh
  14450. * @param emissiveTexture the associated emissive texture used to generate the glow
  14451. * @return true if ready otherwise, false
  14452. */
  14453. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  14454. /**
  14455. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  14456. */
  14457. needStencil(): boolean;
  14458. /**
  14459. * Implementation specific of rendering the generating effect on the main canvas.
  14460. * @param effect The effect used to render through
  14461. */
  14462. protected _internalRender(effect: Effect): void;
  14463. /**
  14464. * Sets the required values for both the emissive texture and and the main color.
  14465. */
  14466. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  14467. /**
  14468. * Returns true if the mesh should render, otherwise false.
  14469. * @param mesh The mesh to render
  14470. * @returns true if it should render otherwise false
  14471. */
  14472. protected _shouldRenderMesh(mesh: Mesh): boolean;
  14473. /**
  14474. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  14475. * @param mesh The mesh to exclude from the glow layer
  14476. */
  14477. addExcludedMesh(mesh: Mesh): void;
  14478. /**
  14479. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  14480. * @param mesh The mesh to remove
  14481. */
  14482. removeExcludedMesh(mesh: Mesh): void;
  14483. /**
  14484. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  14485. * @param mesh The mesh to include in the glow layer
  14486. */
  14487. addIncludedOnlyMesh(mesh: Mesh): void;
  14488. /**
  14489. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  14490. * @param mesh The mesh to remove
  14491. */
  14492. removeIncludedOnlyMesh(mesh: Mesh): void;
  14493. /**
  14494. * Determine if a given mesh will be used in the glow layer
  14495. * @param mesh The mesh to test
  14496. * @returns true if the mesh will be highlighted by the current glow layer
  14497. */
  14498. hasMesh(mesh: AbstractMesh): boolean;
  14499. /**
  14500. * Free any resources and references associated to a mesh.
  14501. * Internal use
  14502. * @param mesh The mesh to free.
  14503. * @hidden
  14504. */
  14505. _disposeMesh(mesh: Mesh): void;
  14506. /**
  14507. * Gets the class name of the effect layer
  14508. * @returns the string with the class name of the effect layer
  14509. */
  14510. getClassName(): string;
  14511. /**
  14512. * Serializes this glow layer
  14513. * @returns a serialized glow layer object
  14514. */
  14515. serialize(): any;
  14516. /**
  14517. * Creates a Glow Layer from parsed glow layer data
  14518. * @param parsedGlowLayer defines glow layer data
  14519. * @param scene defines the current scene
  14520. * @param rootUrl defines the root URL containing the glow layer information
  14521. * @returns a parsed Glow Layer
  14522. */
  14523. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  14524. }
  14525. }
  14526. declare module BABYLON {
  14527. interface AbstractScene {
  14528. /**
  14529. * Return a the first highlight layer of the scene with a given name.
  14530. * @param name The name of the highlight layer to look for.
  14531. * @return The highlight layer if found otherwise null.
  14532. */
  14533. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  14534. }
  14535. /**
  14536. * Highlight layer options. This helps customizing the behaviour
  14537. * of the highlight layer.
  14538. */
  14539. interface IHighlightLayerOptions {
  14540. /**
  14541. * Multiplication factor apply to the canvas size to compute the render target size
  14542. * used to generated the glowing objects (the smaller the faster).
  14543. */
  14544. mainTextureRatio: number;
  14545. /**
  14546. * Enforces a fixed size texture to ensure resize independant blur.
  14547. */
  14548. mainTextureFixedSize?: number;
  14549. /**
  14550. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  14551. * of the picture to blur (the smaller the faster).
  14552. */
  14553. blurTextureSizeRatio: number;
  14554. /**
  14555. * How big in texel of the blur texture is the vertical blur.
  14556. */
  14557. blurVerticalSize: number;
  14558. /**
  14559. * How big in texel of the blur texture is the horizontal blur.
  14560. */
  14561. blurHorizontalSize: number;
  14562. /**
  14563. * Alpha blending mode used to apply the blur. Default is combine.
  14564. */
  14565. alphaBlendingMode: number;
  14566. /**
  14567. * The camera attached to the layer.
  14568. */
  14569. camera: Nullable<Camera>;
  14570. /**
  14571. * Should we display highlight as a solid stroke?
  14572. */
  14573. isStroke?: boolean;
  14574. /**
  14575. * The rendering group to draw the layer in.
  14576. */
  14577. renderingGroupId: number;
  14578. }
  14579. /**
  14580. * The highlight layer Helps adding a glow effect around a mesh.
  14581. *
  14582. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  14583. * glowy meshes to your scene.
  14584. *
  14585. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  14586. */
  14587. class HighlightLayer extends EffectLayer {
  14588. name: string;
  14589. /**
  14590. * Effect Name of the highlight layer.
  14591. */
  14592. static readonly EffectName: string;
  14593. /**
  14594. * The neutral color used during the preparation of the glow effect.
  14595. * This is black by default as the blend operation is a blend operation.
  14596. */
  14597. static NeutralColor: Color4;
  14598. /**
  14599. * Stencil value used for glowing meshes.
  14600. */
  14601. static GlowingMeshStencilReference: number;
  14602. /**
  14603. * Stencil value used for the other meshes in the scene.
  14604. */
  14605. static NormalMeshStencilReference: number;
  14606. /**
  14607. * Specifies whether or not the inner glow is ACTIVE in the layer.
  14608. */
  14609. innerGlow: boolean;
  14610. /**
  14611. * Specifies whether or not the outer glow is ACTIVE in the layer.
  14612. */
  14613. outerGlow: boolean;
  14614. /**
  14615. * Specifies the horizontal size of the blur.
  14616. */
  14617. /**
  14618. * Gets the horizontal size of the blur.
  14619. */
  14620. blurHorizontalSize: number;
  14621. /**
  14622. * Specifies the vertical size of the blur.
  14623. */
  14624. /**
  14625. * Gets the vertical size of the blur.
  14626. */
  14627. blurVerticalSize: number;
  14628. /**
  14629. * An event triggered when the highlight layer is being blurred.
  14630. */
  14631. onBeforeBlurObservable: Observable<HighlightLayer>;
  14632. /**
  14633. * An event triggered when the highlight layer has been blurred.
  14634. */
  14635. onAfterBlurObservable: Observable<HighlightLayer>;
  14636. private _instanceGlowingMeshStencilReference;
  14637. private _options;
  14638. private _downSamplePostprocess;
  14639. private _horizontalBlurPostprocess;
  14640. private _verticalBlurPostprocess;
  14641. private _blurTexture;
  14642. private _meshes;
  14643. private _excludedMeshes;
  14644. /**
  14645. * Instantiates a new highlight Layer and references it to the scene..
  14646. * @param name The name of the layer
  14647. * @param scene The scene to use the layer in
  14648. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  14649. */
  14650. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  14651. /**
  14652. * Get the effect name of the layer.
  14653. * @return The effect name
  14654. */
  14655. getEffectName(): string;
  14656. /**
  14657. * Create the merge effect. This is the shader use to blit the information back
  14658. * to the main canvas at the end of the scene rendering.
  14659. */
  14660. protected _createMergeEffect(): Effect;
  14661. /**
  14662. * Creates the render target textures and post processes used in the highlight layer.
  14663. */
  14664. protected _createTextureAndPostProcesses(): void;
  14665. /**
  14666. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  14667. */
  14668. needStencil(): boolean;
  14669. /**
  14670. * Checks for the readiness of the element composing the layer.
  14671. * @param subMesh the mesh to check for
  14672. * @param useInstances specify wether or not to use instances to render the mesh
  14673. * @param emissiveTexture the associated emissive texture used to generate the glow
  14674. * @return true if ready otherwise, false
  14675. */
  14676. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  14677. /**
  14678. * Implementation specific of rendering the generating effect on the main canvas.
  14679. * @param effect The effect used to render through
  14680. */
  14681. protected _internalRender(effect: Effect): void;
  14682. /**
  14683. * Returns true if the layer contains information to display, otherwise false.
  14684. */
  14685. shouldRender(): boolean;
  14686. /**
  14687. * Returns true if the mesh should render, otherwise false.
  14688. * @param mesh The mesh to render
  14689. * @returns true if it should render otherwise false
  14690. */
  14691. protected _shouldRenderMesh(mesh: Mesh): boolean;
  14692. /**
  14693. * Sets the required values for both the emissive texture and and the main color.
  14694. */
  14695. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  14696. /**
  14697. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  14698. * @param mesh The mesh to exclude from the highlight layer
  14699. */
  14700. addExcludedMesh(mesh: Mesh): void;
  14701. /**
  14702. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  14703. * @param mesh The mesh to highlight
  14704. */
  14705. removeExcludedMesh(mesh: Mesh): void;
  14706. /**
  14707. * Determine if a given mesh will be highlighted by the current HighlightLayer
  14708. * @param mesh mesh to test
  14709. * @returns true if the mesh will be highlighted by the current HighlightLayer
  14710. */
  14711. hasMesh(mesh: AbstractMesh): boolean;
  14712. /**
  14713. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  14714. * @param mesh The mesh to highlight
  14715. * @param color The color of the highlight
  14716. * @param glowEmissiveOnly Extract the glow from the emissive texture
  14717. */
  14718. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  14719. /**
  14720. * Remove a mesh from the highlight layer in order to make it stop glowing.
  14721. * @param mesh The mesh to highlight
  14722. */
  14723. removeMesh(mesh: Mesh): void;
  14724. /**
  14725. * Force the stencil to the normal expected value for none glowing parts
  14726. */
  14727. private _defaultStencilReference;
  14728. /**
  14729. * Free any resources and references associated to a mesh.
  14730. * Internal use
  14731. * @param mesh The mesh to free.
  14732. * @hidden
  14733. */
  14734. _disposeMesh(mesh: Mesh): void;
  14735. /**
  14736. * Dispose the highlight layer and free resources.
  14737. */
  14738. dispose(): void;
  14739. /**
  14740. * Gets the class name of the effect layer
  14741. * @returns the string with the class name of the effect layer
  14742. */
  14743. getClassName(): string;
  14744. /**
  14745. * Serializes this Highlight layer
  14746. * @returns a serialized Highlight layer object
  14747. */
  14748. serialize(): any;
  14749. /**
  14750. * Creates a Highlight layer from parsed Highlight layer data
  14751. * @param parsedHightlightLayer defines the Highlight layer data
  14752. * @param scene defines the current scene
  14753. * @param rootUrl defines the root URL containing the Highlight layer information
  14754. * @returns a parsed Highlight layer
  14755. */
  14756. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  14757. }
  14758. }
  14759. declare module BABYLON {
  14760. /**
  14761. * This represents a full screen 2d layer.
  14762. * This can be usefull to display a picture in the background of your scene for instance.
  14763. * @see https://www.babylonjs-playground.com/#08A2BS#1
  14764. */
  14765. class Layer {
  14766. /**
  14767. * Define the name of the layer.
  14768. */
  14769. name: string;
  14770. /**
  14771. * Define the texture the layer should display.
  14772. */
  14773. texture: Nullable<Texture>;
  14774. /**
  14775. * Is the layer in background or foreground.
  14776. */
  14777. isBackground: boolean;
  14778. /**
  14779. * Define the color of the layer (instead of texture).
  14780. */
  14781. color: Color4;
  14782. /**
  14783. * Define the scale of the layer in order to zoom in out of the texture.
  14784. */
  14785. scale: Vector2;
  14786. /**
  14787. * Define an offset for the layer in order to shift the texture.
  14788. */
  14789. offset: Vector2;
  14790. /**
  14791. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  14792. */
  14793. alphaBlendingMode: number;
  14794. /**
  14795. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  14796. * Alpha test will not mix with the background color in case of transparency.
  14797. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  14798. */
  14799. alphaTest: boolean;
  14800. /**
  14801. * Define a mask to restrict the layer to only some of the scene cameras.
  14802. */
  14803. layerMask: number;
  14804. private _scene;
  14805. private _vertexBuffers;
  14806. private _indexBuffer;
  14807. private _effect;
  14808. private _alphaTestEffect;
  14809. /**
  14810. * An event triggered when the layer is disposed.
  14811. */
  14812. onDisposeObservable: Observable<Layer>;
  14813. private _onDisposeObserver;
  14814. /**
  14815. * Back compatibility with callback before the onDisposeObservable existed.
  14816. * The set callback will be triggered when the layer has been disposed.
  14817. */
  14818. onDispose: () => void;
  14819. /**
  14820. * An event triggered before rendering the scene
  14821. */
  14822. onBeforeRenderObservable: Observable<Layer>;
  14823. private _onBeforeRenderObserver;
  14824. /**
  14825. * Back compatibility with callback before the onBeforeRenderObservable existed.
  14826. * The set callback will be triggered just before rendering the layer.
  14827. */
  14828. onBeforeRender: () => void;
  14829. /**
  14830. * An event triggered after rendering the scene
  14831. */
  14832. onAfterRenderObservable: Observable<Layer>;
  14833. private _onAfterRenderObserver;
  14834. /**
  14835. * Back compatibility with callback before the onAfterRenderObservable existed.
  14836. * The set callback will be triggered just after rendering the layer.
  14837. */
  14838. onAfterRender: () => void;
  14839. /**
  14840. * Instantiates a new layer.
  14841. * This represents a full screen 2d layer.
  14842. * This can be usefull to display a picture in the background of your scene for instance.
  14843. * @see https://www.babylonjs-playground.com/#08A2BS#1
  14844. * @param name Define the name of the layer in the scene
  14845. * @param imgUrl Define the url of the texture to display in the layer
  14846. * @param scene Define the scene the layer belongs to
  14847. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  14848. * @param color Defines a color for the layer
  14849. */
  14850. constructor(
  14851. /**
  14852. * Define the name of the layer.
  14853. */
  14854. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  14855. private _createIndexBuffer;
  14856. /** @hidden */
  14857. _rebuild(): void;
  14858. /**
  14859. * Renders the layer in the scene.
  14860. */
  14861. render(): void;
  14862. /**
  14863. * Disposes and releases the associated ressources.
  14864. */
  14865. dispose(): void;
  14866. }
  14867. }
  14868. declare module BABYLON {
  14869. interface AbstractScene {
  14870. /**
  14871. * The list of layers (background and foreground) of the scene
  14872. */
  14873. layers: Array<Layer>;
  14874. }
  14875. /**
  14876. * Defines the layer scene component responsible to manage any layers
  14877. * in a given scene.
  14878. */
  14879. class LayerSceneComponent implements ISceneComponent {
  14880. /**
  14881. * The component name helpfull to identify the component in the list of scene components.
  14882. */
  14883. readonly name: string;
  14884. /**
  14885. * The scene the component belongs to.
  14886. */
  14887. scene: Scene;
  14888. private _engine;
  14889. /**
  14890. * Creates a new instance of the component for the given scene
  14891. * @param scene Defines the scene to register the component in
  14892. */
  14893. constructor(scene: Scene);
  14894. /**
  14895. * Registers the component in a given scene
  14896. */
  14897. register(): void;
  14898. /**
  14899. * Rebuilds the elements related to this component in case of
  14900. * context lost for instance.
  14901. */
  14902. rebuild(): void;
  14903. /**
  14904. * Disposes the component and the associated ressources.
  14905. */
  14906. dispose(): void;
  14907. private _draw;
  14908. private _drawBackground;
  14909. private _drawForeground;
  14910. }
  14911. }
  14912. declare module BABYLON {
  14913. /**
  14914. * This represents one of the lens effect in a `BABYLON.lensFlareSystem`.
  14915. * It controls one of the indiviual texture used in the effect.
  14916. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  14917. */
  14918. class LensFlare {
  14919. /**
  14920. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  14921. */
  14922. size: number;
  14923. /**
  14924. * 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.
  14925. */
  14926. position: number;
  14927. /**
  14928. * Define the lens color.
  14929. */
  14930. color: Color3;
  14931. /**
  14932. * Define the lens texture.
  14933. */
  14934. texture: Nullable<Texture>;
  14935. /**
  14936. * Define the alpha mode to render this particular lens.
  14937. */
  14938. alphaMode: number;
  14939. private _system;
  14940. /**
  14941. * Creates a new Lens Flare.
  14942. * This represents one of the lens effect in a `BABYLON.lensFlareSystem`.
  14943. * It controls one of the indiviual texture used in the effect.
  14944. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  14945. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  14946. * @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.
  14947. * @param color Define the lens color
  14948. * @param imgUrl Define the lens texture url
  14949. * @param system Define the `lensFlareSystem` this flare is part of
  14950. * @returns The newly created Lens Flare
  14951. */
  14952. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  14953. /**
  14954. * Instantiates a new Lens Flare.
  14955. * This represents one of the lens effect in a `BABYLON.lensFlareSystem`.
  14956. * It controls one of the indiviual texture used in the effect.
  14957. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  14958. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  14959. * @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.
  14960. * @param color Define the lens color
  14961. * @param imgUrl Define the lens texture url
  14962. * @param system Define the `lensFlareSystem` this flare is part of
  14963. */
  14964. constructor(
  14965. /**
  14966. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  14967. */
  14968. size: number,
  14969. /**
  14970. * 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.
  14971. */
  14972. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  14973. /**
  14974. * Dispose and release the lens flare with its associated resources.
  14975. */
  14976. dispose(): void;
  14977. }
  14978. }
  14979. declare module BABYLON {
  14980. /**
  14981. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  14982. * It is usually composed of several `BABYLON.lensFlare`.
  14983. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  14984. */
  14985. class LensFlareSystem {
  14986. /**
  14987. * Define the name of the lens flare system
  14988. */
  14989. name: string;
  14990. /**
  14991. * List of lens flares used in this system.
  14992. */
  14993. lensFlares: LensFlare[];
  14994. /**
  14995. * Define a limit from the border the lens flare can be visible.
  14996. */
  14997. borderLimit: number;
  14998. /**
  14999. * Define a viewport border we do not want to see the lens flare in.
  15000. */
  15001. viewportBorder: number;
  15002. /**
  15003. * Define a predicate which could limit the list of meshes able to occlude the effect.
  15004. */
  15005. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  15006. /**
  15007. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  15008. */
  15009. layerMask: number;
  15010. /**
  15011. * Define the id of the lens flare system in the scene.
  15012. * (equal to name by default)
  15013. */
  15014. id: string;
  15015. private _scene;
  15016. private _emitter;
  15017. private _vertexBuffers;
  15018. private _indexBuffer;
  15019. private _effect;
  15020. private _positionX;
  15021. private _positionY;
  15022. private _isEnabled;
  15023. /**
  15024. * Instantiates a lens flare system.
  15025. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  15026. * It is usually composed of several `BABYLON.lensFlare`.
  15027. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15028. * @param name Define the name of the lens flare system in the scene
  15029. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  15030. * @param scene Define the scene the lens flare system belongs to
  15031. */
  15032. constructor(
  15033. /**
  15034. * Define the name of the lens flare system
  15035. */
  15036. name: string, emitter: any, scene: Scene);
  15037. /**
  15038. * Define if the lens flare system is enabled.
  15039. */
  15040. isEnabled: boolean;
  15041. /**
  15042. * Get the scene the effects belongs to.
  15043. * @returns the scene holding the lens flare system
  15044. */
  15045. getScene(): Scene;
  15046. /**
  15047. * Get the emitter of the lens flare system.
  15048. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  15049. * @returns the emitter of the lens flare system
  15050. */
  15051. getEmitter(): any;
  15052. /**
  15053. * Set the emitter of the lens flare system.
  15054. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  15055. * @param newEmitter Define the new emitter of the system
  15056. */
  15057. setEmitter(newEmitter: any): void;
  15058. /**
  15059. * Get the lens flare system emitter position.
  15060. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  15061. * @returns the position
  15062. */
  15063. getEmitterPosition(): Vector3;
  15064. /**
  15065. * @hidden
  15066. */
  15067. computeEffectivePosition(globalViewport: Viewport): boolean;
  15068. /** @hidden */
  15069. _isVisible(): boolean;
  15070. /**
  15071. * @hidden
  15072. */
  15073. render(): boolean;
  15074. /**
  15075. * Dispose and release the lens flare with its associated resources.
  15076. */
  15077. dispose(): void;
  15078. /**
  15079. * Parse a lens flare system from a JSON repressentation
  15080. * @param parsedLensFlareSystem Define the JSON to parse
  15081. * @param scene Define the scene the parsed system should be instantiated in
  15082. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  15083. * @returns the parsed system
  15084. */
  15085. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  15086. /**
  15087. * Serialize the current Lens Flare System into a JSON representation.
  15088. * @returns the serialized JSON
  15089. */
  15090. serialize(): any;
  15091. }
  15092. }
  15093. declare module BABYLON {
  15094. interface AbstractScene {
  15095. /**
  15096. * The list of lens flare system added to the scene
  15097. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15098. */
  15099. lensFlareSystems: Array<LensFlareSystem>;
  15100. /**
  15101. * Removes the given lens flare system from this scene.
  15102. * @param toRemove The lens flare system to remove
  15103. * @returns The index of the removed lens flare system
  15104. */
  15105. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  15106. /**
  15107. * Adds the given lens flare system to this scene
  15108. * @param newLensFlareSystem The lens flare system to add
  15109. */
  15110. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  15111. /**
  15112. * Gets a lens flare system using its name
  15113. * @param name defines the name to look for
  15114. * @returns the lens flare system or null if not found
  15115. */
  15116. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  15117. /**
  15118. * Gets a lens flare system using its id
  15119. * @param id defines the id to look for
  15120. * @returns the lens flare system or null if not found
  15121. */
  15122. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  15123. }
  15124. /**
  15125. * Defines the lens flare scene component responsible to manage any lens flares
  15126. * in a given scene.
  15127. */
  15128. class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  15129. /**
  15130. * The component name helpfull to identify the component in the list of scene components.
  15131. */
  15132. readonly name: string;
  15133. /**
  15134. * The scene the component belongs to.
  15135. */
  15136. scene: Scene;
  15137. /**
  15138. * Creates a new instance of the component for the given scene
  15139. * @param scene Defines the scene to register the component in
  15140. */
  15141. constructor(scene: Scene);
  15142. /**
  15143. * Registers the component in a given scene
  15144. */
  15145. register(): void;
  15146. /**
  15147. * Rebuilds the elements related to this component in case of
  15148. * context lost for instance.
  15149. */
  15150. rebuild(): void;
  15151. /**
  15152. * Adds all the element from the container to the scene
  15153. * @param container the container holding the elements
  15154. */
  15155. addFromContainer(container: AbstractScene): void;
  15156. /**
  15157. * Removes all the elements in the container from the scene
  15158. * @param container contains the elements to remove
  15159. */
  15160. removeFromContainer(container: AbstractScene): void;
  15161. /**
  15162. * Serializes the component data to the specified json object
  15163. * @param serializationObject The object to serialize to
  15164. */
  15165. serialize(serializationObject: any): void;
  15166. /**
  15167. * Disposes the component and the associated ressources.
  15168. */
  15169. dispose(): void;
  15170. private _draw;
  15171. }
  15172. }
  15173. declare module BABYLON {
  15174. /**
  15175. * A directional light is defined by a direction (what a surprise!).
  15176. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  15177. * 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.
  15178. * Documentation: https://doc.babylonjs.com/babylon101/lights
  15179. */
  15180. class DirectionalLight extends ShadowLight {
  15181. private _shadowFrustumSize;
  15182. /**
  15183. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  15184. */
  15185. /**
  15186. * Specifies a fix frustum size for the shadow generation.
  15187. */
  15188. shadowFrustumSize: number;
  15189. private _shadowOrthoScale;
  15190. /**
  15191. * Gets the shadow projection scale against the optimal computed one.
  15192. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  15193. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  15194. */
  15195. /**
  15196. * Sets the shadow projection scale against the optimal computed one.
  15197. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  15198. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  15199. */
  15200. shadowOrthoScale: number;
  15201. /**
  15202. * Automatically compute the projection matrix to best fit (including all the casters)
  15203. * on each frame.
  15204. */
  15205. autoUpdateExtends: boolean;
  15206. private _orthoLeft;
  15207. private _orthoRight;
  15208. private _orthoTop;
  15209. private _orthoBottom;
  15210. /**
  15211. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  15212. * The directional light is emitted from everywhere in the given direction.
  15213. * It can cast shadows.
  15214. * Documentation : http://doc.babylonjs.com/tutorials/lights
  15215. * @param name The friendly name of the light
  15216. * @param direction The direction of the light
  15217. * @param scene The scene the light belongs to
  15218. */
  15219. constructor(name: string, direction: Vector3, scene: Scene);
  15220. /**
  15221. * Returns the string "DirectionalLight".
  15222. * @return The class name
  15223. */
  15224. getClassName(): string;
  15225. /**
  15226. * Returns the integer 1.
  15227. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15228. */
  15229. getTypeID(): number;
  15230. /**
  15231. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  15232. * Returns the DirectionalLight Shadow projection matrix.
  15233. */
  15234. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  15235. /**
  15236. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  15237. * Returns the DirectionalLight Shadow projection matrix.
  15238. */
  15239. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix): void;
  15240. /**
  15241. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  15242. * Returns the DirectionalLight Shadow projection matrix.
  15243. */
  15244. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  15245. protected _buildUniformLayout(): void;
  15246. /**
  15247. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  15248. * @param effect The effect to update
  15249. * @param lightIndex The index of the light in the effect to update
  15250. * @returns The directional light
  15251. */
  15252. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  15253. /**
  15254. * Gets the minZ used for shadow according to both the scene and the light.
  15255. *
  15256. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  15257. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  15258. * @param activeCamera The camera we are returning the min for
  15259. * @returns the depth min z
  15260. */
  15261. getDepthMinZ(activeCamera: Camera): number;
  15262. /**
  15263. * Gets the maxZ used for shadow according to both the scene and the light.
  15264. *
  15265. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  15266. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  15267. * @param activeCamera The camera we are returning the max for
  15268. * @returns the depth max z
  15269. */
  15270. getDepthMaxZ(activeCamera: Camera): number;
  15271. /**
  15272. * Prepares the list of defines specific to the light type.
  15273. * @param defines the list of defines
  15274. * @param lightIndex defines the index of the light for the effect
  15275. */
  15276. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15277. }
  15278. }
  15279. declare module BABYLON {
  15280. /**
  15281. * The HemisphericLight simulates the ambient environment light,
  15282. * so the passed direction is the light reflection direction, not the incoming direction.
  15283. */
  15284. class HemisphericLight extends Light {
  15285. /**
  15286. * The groundColor is the light in the opposite direction to the one specified during creation.
  15287. * 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.
  15288. */
  15289. groundColor: Color3;
  15290. /**
  15291. * The light reflection direction, not the incoming direction.
  15292. */
  15293. direction: Vector3;
  15294. /**
  15295. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  15296. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  15297. * The HemisphericLight can't cast shadows.
  15298. * Documentation : http://doc.babylonjs.com/tutorials/lights
  15299. * @param name The friendly name of the light
  15300. * @param direction The direction of the light reflection
  15301. * @param scene The scene the light belongs to
  15302. */
  15303. constructor(name: string, direction: Vector3, scene: Scene);
  15304. protected _buildUniformLayout(): void;
  15305. /**
  15306. * Returns the string "HemisphericLight".
  15307. * @return The class name
  15308. */
  15309. getClassName(): string;
  15310. /**
  15311. * Sets the HemisphericLight direction towards the passed target (Vector3).
  15312. * Returns the updated direction.
  15313. * @param target The target the direction should point to
  15314. * @return The computed direction
  15315. */
  15316. setDirectionToTarget(target: Vector3): Vector3;
  15317. /**
  15318. * Returns the shadow generator associated to the light.
  15319. * @returns Always null for hemispheric lights because it does not support shadows.
  15320. */
  15321. getShadowGenerator(): Nullable<IShadowGenerator>;
  15322. /**
  15323. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  15324. * @param effect The effect to update
  15325. * @param lightIndex The index of the light in the effect to update
  15326. * @returns The hemispheric light
  15327. */
  15328. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  15329. /**
  15330. * Computes the world matrix of the node
  15331. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15332. * @param useWasUpdatedFlag defines a reserved property
  15333. * @returns the world matrix
  15334. */
  15335. computeWorldMatrix(force?: boolean, useWasUpdatedFlag?: boolean): Matrix;
  15336. /**
  15337. * Returns the integer 3.
  15338. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15339. */
  15340. getTypeID(): number;
  15341. /**
  15342. * Prepares the list of defines specific to the light type.
  15343. * @param defines the list of defines
  15344. * @param lightIndex defines the index of the light for the effect
  15345. */
  15346. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15347. }
  15348. }
  15349. declare module BABYLON {
  15350. /**
  15351. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  15352. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  15353. * 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.
  15354. */
  15355. abstract class Light extends Node {
  15356. /**
  15357. * Falloff Default: light is falling off following the material specification:
  15358. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  15359. */
  15360. static readonly FALLOFF_DEFAULT: number;
  15361. /**
  15362. * Falloff Physical: light is falling off following the inverse squared distance law.
  15363. */
  15364. static readonly FALLOFF_PHYSICAL: number;
  15365. /**
  15366. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  15367. * to enhance interoperability with other engines.
  15368. */
  15369. static readonly FALLOFF_GLTF: number;
  15370. /**
  15371. * Falloff Standard: light is falling off like in the standard material
  15372. * to enhance interoperability with other materials.
  15373. */
  15374. static readonly FALLOFF_STANDARD: number;
  15375. /**
  15376. * If every light affecting the material is in this lightmapMode,
  15377. * material.lightmapTexture adds or multiplies
  15378. * (depends on material.useLightmapAsShadowmap)
  15379. * after every other light calculations.
  15380. */
  15381. static readonly LIGHTMAP_DEFAULT: number;
  15382. /**
  15383. * material.lightmapTexture as only diffuse lighting from this light
  15384. * adds only specular lighting from this light
  15385. * adds dynamic shadows
  15386. */
  15387. static readonly LIGHTMAP_SPECULAR: number;
  15388. /**
  15389. * material.lightmapTexture as only lighting
  15390. * no light calculation from this light
  15391. * only adds dynamic shadows from this light
  15392. */
  15393. static readonly LIGHTMAP_SHADOWSONLY: number;
  15394. /**
  15395. * Each light type uses the default quantity according to its type:
  15396. * point/spot lights use luminous intensity
  15397. * directional lights use illuminance
  15398. */
  15399. static readonly INTENSITYMODE_AUTOMATIC: number;
  15400. /**
  15401. * lumen (lm)
  15402. */
  15403. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  15404. /**
  15405. * candela (lm/sr)
  15406. */
  15407. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  15408. /**
  15409. * lux (lm/m^2)
  15410. */
  15411. static readonly INTENSITYMODE_ILLUMINANCE: number;
  15412. /**
  15413. * nit (cd/m^2)
  15414. */
  15415. static readonly INTENSITYMODE_LUMINANCE: number;
  15416. /**
  15417. * Light type const id of the point light.
  15418. */
  15419. static readonly LIGHTTYPEID_POINTLIGHT: number;
  15420. /**
  15421. * Light type const id of the directional light.
  15422. */
  15423. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  15424. /**
  15425. * Light type const id of the spot light.
  15426. */
  15427. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  15428. /**
  15429. * Light type const id of the hemispheric light.
  15430. */
  15431. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  15432. /**
  15433. * Diffuse gives the basic color to an object.
  15434. */
  15435. diffuse: Color3;
  15436. /**
  15437. * Specular produces a highlight color on an object.
  15438. * Note: This is note affecting PBR materials.
  15439. */
  15440. specular: Color3;
  15441. /**
  15442. * Defines the falloff type for this light. This lets overrriding how punctual light are
  15443. * falling off base on range or angle.
  15444. * This can be set to any values in Light.FALLOFF_x.
  15445. *
  15446. * Note: This is only usefull for PBR Materials at the moment. This could be extended if required to
  15447. * other types of materials.
  15448. */
  15449. falloffType: number;
  15450. /**
  15451. * Strength of the light.
  15452. * Note: By default it is define in the framework own unit.
  15453. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  15454. */
  15455. intensity: number;
  15456. private _range;
  15457. protected _inverseSquaredRange: number;
  15458. /**
  15459. * Defines how far from the source the light is impacting in scene units.
  15460. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  15461. */
  15462. /**
  15463. * Defines how far from the source the light is impacting in scene units.
  15464. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  15465. */
  15466. range: number;
  15467. /**
  15468. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  15469. * of light.
  15470. */
  15471. private _photometricScale;
  15472. private _intensityMode;
  15473. /**
  15474. * Gets the photometric scale used to interpret the intensity.
  15475. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  15476. */
  15477. /**
  15478. * Sets the photometric scale used to interpret the intensity.
  15479. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  15480. */
  15481. intensityMode: number;
  15482. private _radius;
  15483. /**
  15484. * Gets the light radius used by PBR Materials to simulate soft area lights.
  15485. */
  15486. /**
  15487. * sets the light radius used by PBR Materials to simulate soft area lights.
  15488. */
  15489. radius: number;
  15490. private _renderPriority;
  15491. /**
  15492. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  15493. * exceeding the number allowed of the materials.
  15494. */
  15495. renderPriority: number;
  15496. private _shadowEnabled;
  15497. /**
  15498. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  15499. * the current shadow generator.
  15500. */
  15501. /**
  15502. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  15503. * the current shadow generator.
  15504. */
  15505. shadowEnabled: boolean;
  15506. private _includedOnlyMeshes;
  15507. /**
  15508. * Gets the only meshes impacted by this light.
  15509. */
  15510. /**
  15511. * Sets the only meshes impacted by this light.
  15512. */
  15513. includedOnlyMeshes: AbstractMesh[];
  15514. private _excludedMeshes;
  15515. /**
  15516. * Gets the meshes not impacted by this light.
  15517. */
  15518. /**
  15519. * Sets the meshes not impacted by this light.
  15520. */
  15521. excludedMeshes: AbstractMesh[];
  15522. private _excludeWithLayerMask;
  15523. /**
  15524. * Gets the layer id use to find what meshes are not impacted by the light.
  15525. * Inactive if 0
  15526. */
  15527. /**
  15528. * Sets the layer id use to find what meshes are not impacted by the light.
  15529. * Inactive if 0
  15530. */
  15531. excludeWithLayerMask: number;
  15532. private _includeOnlyWithLayerMask;
  15533. /**
  15534. * Gets the layer id use to find what meshes are impacted by the light.
  15535. * Inactive if 0
  15536. */
  15537. /**
  15538. * Sets the layer id use to find what meshes are impacted by the light.
  15539. * Inactive if 0
  15540. */
  15541. includeOnlyWithLayerMask: number;
  15542. private _lightmapMode;
  15543. /**
  15544. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  15545. */
  15546. /**
  15547. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  15548. */
  15549. lightmapMode: number;
  15550. /**
  15551. * Shadow generator associted to the light.
  15552. * @hidden Internal use only.
  15553. */
  15554. _shadowGenerator: Nullable<IShadowGenerator>;
  15555. /**
  15556. * @hidden Internal use only.
  15557. */
  15558. _excludedMeshesIds: string[];
  15559. /**
  15560. * @hidden Internal use only.
  15561. */
  15562. _includedOnlyMeshesIds: string[];
  15563. /**
  15564. * The current light unifom buffer.
  15565. * @hidden Internal use only.
  15566. */
  15567. _uniformBuffer: UniformBuffer;
  15568. /**
  15569. * Creates a Light object in the scene.
  15570. * Documentation : http://doc.babylonjs.com/tutorials/lights
  15571. * @param name The firendly name of the light
  15572. * @param scene The scene the light belongs too
  15573. */
  15574. constructor(name: string, scene: Scene);
  15575. protected abstract _buildUniformLayout(): void;
  15576. /**
  15577. * Sets the passed Effect "effect" with the Light information.
  15578. * @param effect The effect to update
  15579. * @param lightIndex The index of the light in the effect to update
  15580. * @returns The light
  15581. */
  15582. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  15583. /**
  15584. * Returns the string "Light".
  15585. * @returns the class name
  15586. */
  15587. getClassName(): string;
  15588. /**
  15589. * Converts the light information to a readable string for debug purpose.
  15590. * @param fullDetails Supports for multiple levels of logging within scene loading
  15591. * @returns the human readable light info
  15592. */
  15593. toString(fullDetails?: boolean): string;
  15594. /** @hidden */
  15595. protected _syncParentEnabledState(): void;
  15596. /**
  15597. * Set the enabled state of this node.
  15598. * @param value - the new enabled state
  15599. */
  15600. setEnabled(value: boolean): void;
  15601. /**
  15602. * Returns the Light associated shadow generator if any.
  15603. * @return the associated shadow generator.
  15604. */
  15605. getShadowGenerator(): Nullable<IShadowGenerator>;
  15606. /**
  15607. * Returns a Vector3, the absolute light position in the World.
  15608. * @returns the world space position of the light
  15609. */
  15610. getAbsolutePosition(): Vector3;
  15611. /**
  15612. * Specifies if the light will affect the passed mesh.
  15613. * @param mesh The mesh to test against the light
  15614. * @return true the mesh is affected otherwise, false.
  15615. */
  15616. canAffectMesh(mesh: AbstractMesh): boolean;
  15617. /**
  15618. * Sort function to order lights for rendering.
  15619. * @param a First Light object to compare to second.
  15620. * @param b Second Light object to compare first.
  15621. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  15622. */
  15623. static CompareLightsPriority(a: Light, b: Light): number;
  15624. /**
  15625. * Releases resources associated with this node.
  15626. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15627. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15628. */
  15629. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15630. /**
  15631. * Returns the light type ID (integer).
  15632. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15633. */
  15634. getTypeID(): number;
  15635. /**
  15636. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  15637. * @returns the scaled intensity in intensity mode unit
  15638. */
  15639. getScaledIntensity(): number;
  15640. /**
  15641. * Returns a new Light object, named "name", from the current one.
  15642. * @param name The name of the cloned light
  15643. * @returns the new created light
  15644. */
  15645. clone(name: string): Nullable<Light>;
  15646. /**
  15647. * Serializes the current light into a Serialization object.
  15648. * @returns the serialized object.
  15649. */
  15650. serialize(): any;
  15651. /**
  15652. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  15653. * This new light is named "name" and added to the passed scene.
  15654. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  15655. * @param name The friendly name of the light
  15656. * @param scene The scene the new light will belong to
  15657. * @returns the constructor function
  15658. */
  15659. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  15660. /**
  15661. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  15662. * @param parsedLight The JSON representation of the light
  15663. * @param scene The scene to create the parsed light in
  15664. * @returns the created light after parsing
  15665. */
  15666. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  15667. private _hookArrayForExcluded;
  15668. private _hookArrayForIncludedOnly;
  15669. private _resyncMeshes;
  15670. /**
  15671. * Forces the meshes to update their light related information in their rendering used effects
  15672. * @hidden Internal Use Only
  15673. */
  15674. _markMeshesAsLightDirty(): void;
  15675. /**
  15676. * Recomputes the cached photometric scale if needed.
  15677. */
  15678. private _computePhotometricScale;
  15679. /**
  15680. * Returns the Photometric Scale according to the light type and intensity mode.
  15681. */
  15682. private _getPhotometricScale;
  15683. /**
  15684. * Reorder the light in the scene according to their defined priority.
  15685. * @hidden Internal Use Only
  15686. */
  15687. _reorderLightsInScene(): void;
  15688. /**
  15689. * Prepares the list of defines specific to the light type.
  15690. * @param defines the list of defines
  15691. * @param lightIndex defines the index of the light for the effect
  15692. */
  15693. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15694. }
  15695. }
  15696. declare module BABYLON {
  15697. /**
  15698. * A point light is a light defined by an unique point in world space.
  15699. * The light is emitted in every direction from this point.
  15700. * A good example of a point light is a standard light bulb.
  15701. * Documentation: https://doc.babylonjs.com/babylon101/lights
  15702. */
  15703. class PointLight extends ShadowLight {
  15704. private _shadowAngle;
  15705. /**
  15706. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  15707. * This specifies what angle the shadow will use to be created.
  15708. *
  15709. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  15710. */
  15711. /**
  15712. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  15713. * This specifies what angle the shadow will use to be created.
  15714. *
  15715. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  15716. */
  15717. shadowAngle: number;
  15718. /**
  15719. * Gets the direction if it has been set.
  15720. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  15721. */
  15722. /**
  15723. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  15724. */
  15725. direction: Vector3;
  15726. /**
  15727. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  15728. * A PointLight emits the light in every direction.
  15729. * It can cast shadows.
  15730. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  15731. * ```javascript
  15732. * var pointLight = new BABYLON.PointLight("pl", camera.position, scene);
  15733. * ```
  15734. * Documentation : http://doc.babylonjs.com/tutorials/lights
  15735. * @param name The light friendly name
  15736. * @param position The position of the point light in the scene
  15737. * @param scene The scene the lights belongs to
  15738. */
  15739. constructor(name: string, position: Vector3, scene: Scene);
  15740. /**
  15741. * Returns the string "PointLight"
  15742. * @returns the class name
  15743. */
  15744. getClassName(): string;
  15745. /**
  15746. * Returns the integer 0.
  15747. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15748. */
  15749. getTypeID(): number;
  15750. /**
  15751. * Specifies wether or not the shadowmap should be a cube texture.
  15752. * @returns true if the shadowmap needs to be a cube texture.
  15753. */
  15754. needCube(): boolean;
  15755. /**
  15756. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  15757. * @param faceIndex The index of the face we are computed the direction to generate shadow
  15758. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  15759. */
  15760. getShadowDirection(faceIndex?: number): Vector3;
  15761. /**
  15762. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  15763. * - fov = PI / 2
  15764. * - aspect ratio : 1.0
  15765. * - z-near and far equal to the active camera minZ and maxZ.
  15766. * Returns the PointLight.
  15767. */
  15768. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  15769. protected _buildUniformLayout(): void;
  15770. /**
  15771. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  15772. * @param effect The effect to update
  15773. * @param lightIndex The index of the light in the effect to update
  15774. * @returns The point light
  15775. */
  15776. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  15777. /**
  15778. * Prepares the list of defines specific to the light type.
  15779. * @param defines the list of defines
  15780. * @param lightIndex defines the index of the light for the effect
  15781. */
  15782. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15783. }
  15784. }
  15785. declare module BABYLON {
  15786. /**
  15787. * Interface describing all the common properties and methods a shadow light needs to implement.
  15788. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  15789. * as well as binding the different shadow properties to the effects.
  15790. */
  15791. interface IShadowLight extends Light {
  15792. /**
  15793. * The light id in the scene (used in scene.findLighById for instance)
  15794. */
  15795. id: string;
  15796. /**
  15797. * The position the shdow will be casted from.
  15798. */
  15799. position: Vector3;
  15800. /**
  15801. * In 2d mode (needCube being false), the direction used to cast the shadow.
  15802. */
  15803. direction: Vector3;
  15804. /**
  15805. * The transformed position. Position of the light in world space taking parenting in account.
  15806. */
  15807. transformedPosition: Vector3;
  15808. /**
  15809. * The transformed direction. Direction of the light in world space taking parenting in account.
  15810. */
  15811. transformedDirection: Vector3;
  15812. /**
  15813. * The friendly name of the light in the scene.
  15814. */
  15815. name: string;
  15816. /**
  15817. * Defines the shadow projection clipping minimum z value.
  15818. */
  15819. shadowMinZ: number;
  15820. /**
  15821. * Defines the shadow projection clipping maximum z value.
  15822. */
  15823. shadowMaxZ: number;
  15824. /**
  15825. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  15826. * @returns true if the information has been computed, false if it does not need to (no parenting)
  15827. */
  15828. computeTransformedInformation(): boolean;
  15829. /**
  15830. * Gets the scene the light belongs to.
  15831. * @returns The scene
  15832. */
  15833. getScene(): Scene;
  15834. /**
  15835. * Callback defining a custom Projection Matrix Builder.
  15836. * This can be used to override the default projection matrix computation.
  15837. */
  15838. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  15839. /**
  15840. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  15841. * @param matrix The materix to updated with the projection information
  15842. * @param viewMatrix The transform matrix of the light
  15843. * @param renderList The list of mesh to render in the map
  15844. * @returns The current light
  15845. */
  15846. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  15847. /**
  15848. * Gets the current depth scale used in ESM.
  15849. * @returns The scale
  15850. */
  15851. getDepthScale(): number;
  15852. /**
  15853. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  15854. * @returns true if a cube texture needs to be use
  15855. */
  15856. needCube(): boolean;
  15857. /**
  15858. * Detects if the projection matrix requires to be recomputed this frame.
  15859. * @returns true if it requires to be recomputed otherwise, false.
  15860. */
  15861. needProjectionMatrixCompute(): boolean;
  15862. /**
  15863. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  15864. */
  15865. forceProjectionMatrixCompute(): void;
  15866. /**
  15867. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  15868. * @param faceIndex The index of the face we are computed the direction to generate shadow
  15869. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  15870. */
  15871. getShadowDirection(faceIndex?: number): Vector3;
  15872. /**
  15873. * Gets the minZ used for shadow according to both the scene and the light.
  15874. * @param activeCamera The camera we are returning the min for
  15875. * @returns the depth min z
  15876. */
  15877. getDepthMinZ(activeCamera: Camera): number;
  15878. /**
  15879. * Gets the maxZ used for shadow according to both the scene and the light.
  15880. * @param activeCamera The camera we are returning the max for
  15881. * @returns the depth max z
  15882. */
  15883. getDepthMaxZ(activeCamera: Camera): number;
  15884. }
  15885. /**
  15886. * Base implementation IShadowLight
  15887. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  15888. */
  15889. abstract class ShadowLight extends Light implements IShadowLight {
  15890. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  15891. protected _position: Vector3;
  15892. protected _setPosition(value: Vector3): void;
  15893. /**
  15894. * Sets the position the shadow will be casted from. Also use as the light position for both
  15895. * point and spot lights.
  15896. */
  15897. /**
  15898. * Sets the position the shadow will be casted from. Also use as the light position for both
  15899. * point and spot lights.
  15900. */
  15901. position: Vector3;
  15902. protected _direction: Vector3;
  15903. protected _setDirection(value: Vector3): void;
  15904. /**
  15905. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  15906. * Also use as the light direction on spot and directional lights.
  15907. */
  15908. /**
  15909. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  15910. * Also use as the light direction on spot and directional lights.
  15911. */
  15912. direction: Vector3;
  15913. private _shadowMinZ;
  15914. /**
  15915. * Gets the shadow projection clipping minimum z value.
  15916. */
  15917. /**
  15918. * Sets the shadow projection clipping minimum z value.
  15919. */
  15920. shadowMinZ: number;
  15921. private _shadowMaxZ;
  15922. /**
  15923. * Sets the shadow projection clipping maximum z value.
  15924. */
  15925. /**
  15926. * Gets the shadow projection clipping maximum z value.
  15927. */
  15928. shadowMaxZ: number;
  15929. /**
  15930. * Callback defining a custom Projection Matrix Builder.
  15931. * This can be used to override the default projection matrix computation.
  15932. */
  15933. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  15934. /**
  15935. * The transformed position. Position of the light in world space taking parenting in account.
  15936. */
  15937. transformedPosition: Vector3;
  15938. /**
  15939. * The transformed direction. Direction of the light in world space taking parenting in account.
  15940. */
  15941. transformedDirection: Vector3;
  15942. private _needProjectionMatrixCompute;
  15943. /**
  15944. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  15945. * @returns true if the information has been computed, false if it does not need to (no parenting)
  15946. */
  15947. computeTransformedInformation(): boolean;
  15948. /**
  15949. * Return the depth scale used for the shadow map.
  15950. * @returns the depth scale.
  15951. */
  15952. getDepthScale(): number;
  15953. /**
  15954. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  15955. * @param faceIndex The index of the face we are computed the direction to generate shadow
  15956. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  15957. */
  15958. getShadowDirection(faceIndex?: number): Vector3;
  15959. /**
  15960. * Returns the ShadowLight absolute position in the World.
  15961. * @returns the position vector in world space
  15962. */
  15963. getAbsolutePosition(): Vector3;
  15964. /**
  15965. * Sets the ShadowLight direction toward the passed target.
  15966. * @param target The point tot target in local space
  15967. * @returns the updated ShadowLight direction
  15968. */
  15969. setDirectionToTarget(target: Vector3): Vector3;
  15970. /**
  15971. * Returns the light rotation in euler definition.
  15972. * @returns the x y z rotation in local space.
  15973. */
  15974. getRotation(): Vector3;
  15975. /**
  15976. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  15977. * @returns true if a cube texture needs to be use
  15978. */
  15979. needCube(): boolean;
  15980. /**
  15981. * Detects if the projection matrix requires to be recomputed this frame.
  15982. * @returns true if it requires to be recomputed otherwise, false.
  15983. */
  15984. needProjectionMatrixCompute(): boolean;
  15985. /**
  15986. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  15987. */
  15988. forceProjectionMatrixCompute(): void;
  15989. /** @hidden */
  15990. _initCache(): void;
  15991. /** @hidden */
  15992. _isSynchronized(): boolean;
  15993. /**
  15994. * Computes the world matrix of the node
  15995. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15996. * @returns the world matrix
  15997. */
  15998. computeWorldMatrix(force?: boolean): Matrix;
  15999. /**
  16000. * Gets the minZ used for shadow according to both the scene and the light.
  16001. * @param activeCamera The camera we are returning the min for
  16002. * @returns the depth min z
  16003. */
  16004. getDepthMinZ(activeCamera: Camera): number;
  16005. /**
  16006. * Gets the maxZ used for shadow according to both the scene and the light.
  16007. * @param activeCamera The camera we are returning the max for
  16008. * @returns the depth max z
  16009. */
  16010. getDepthMaxZ(activeCamera: Camera): number;
  16011. /**
  16012. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  16013. * @param matrix The materix to updated with the projection information
  16014. * @param viewMatrix The transform matrix of the light
  16015. * @param renderList The list of mesh to render in the map
  16016. * @returns The current light
  16017. */
  16018. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  16019. }
  16020. }
  16021. declare module BABYLON {
  16022. /**
  16023. * A spot light is defined by a position, a direction, an angle, and an exponent.
  16024. * These values define a cone of light starting from the position, emitting toward the direction.
  16025. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  16026. * and the exponent defines the speed of the decay of the light with distance (reach).
  16027. * Documentation: https://doc.babylonjs.com/babylon101/lights
  16028. */
  16029. class SpotLight extends ShadowLight {
  16030. private _angle;
  16031. private _innerAngle;
  16032. private _cosHalfAngle;
  16033. private _lightAngleScale;
  16034. private _lightAngleOffset;
  16035. /**
  16036. * Gets the cone angle of the spot light in Radians.
  16037. */
  16038. /**
  16039. * Sets the cone angle of the spot light in Radians.
  16040. */
  16041. angle: number;
  16042. /**
  16043. * Only used in gltf falloff mode, this defines the angle where
  16044. * the directional falloff will start before cutting at angle which could be seen
  16045. * as outer angle.
  16046. */
  16047. /**
  16048. * Only used in gltf falloff mode, this defines the angle where
  16049. * the directional falloff will start before cutting at angle which could be seen
  16050. * as outer angle.
  16051. */
  16052. innerAngle: number;
  16053. private _shadowAngleScale;
  16054. /**
  16055. * Allows scaling the angle of the light for shadow generation only.
  16056. */
  16057. /**
  16058. * Allows scaling the angle of the light for shadow generation only.
  16059. */
  16060. shadowAngleScale: number;
  16061. /**
  16062. * The light decay speed with the distance from the emission spot.
  16063. */
  16064. exponent: number;
  16065. private _projectionTextureMatrix;
  16066. /**
  16067. * Allows reading the projecton texture
  16068. */
  16069. readonly projectionTextureMatrix: Matrix;
  16070. protected _projectionTextureLightNear: number;
  16071. /**
  16072. * Gets the near clip of the Spotlight for texture projection.
  16073. */
  16074. /**
  16075. * Sets the near clip of the Spotlight for texture projection.
  16076. */
  16077. projectionTextureLightNear: number;
  16078. protected _projectionTextureLightFar: number;
  16079. /**
  16080. * Gets the far clip of the Spotlight for texture projection.
  16081. */
  16082. /**
  16083. * Sets the far clip of the Spotlight for texture projection.
  16084. */
  16085. projectionTextureLightFar: number;
  16086. protected _projectionTextureUpDirection: Vector3;
  16087. /**
  16088. * Gets the Up vector of the Spotlight for texture projection.
  16089. */
  16090. /**
  16091. * Sets the Up vector of the Spotlight for texture projection.
  16092. */
  16093. projectionTextureUpDirection: Vector3;
  16094. private _projectionTexture;
  16095. /**
  16096. * Gets the projection texture of the light.
  16097. */
  16098. /**
  16099. * Sets the projection texture of the light.
  16100. */
  16101. projectionTexture: Nullable<BaseTexture>;
  16102. private _projectionTextureViewLightDirty;
  16103. private _projectionTextureProjectionLightDirty;
  16104. private _projectionTextureDirty;
  16105. private _projectionTextureViewTargetVector;
  16106. private _projectionTextureViewLightMatrix;
  16107. private _projectionTextureProjectionLightMatrix;
  16108. private _projectionTextureScalingMatrix;
  16109. /**
  16110. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  16111. * It can cast shadows.
  16112. * Documentation : http://doc.babylonjs.com/tutorials/lights
  16113. * @param name The light friendly name
  16114. * @param position The position of the spot light in the scene
  16115. * @param direction The direction of the light in the scene
  16116. * @param angle The cone angle of the light in Radians
  16117. * @param exponent The light decay speed with the distance from the emission spot
  16118. * @param scene The scene the lights belongs to
  16119. */
  16120. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  16121. /**
  16122. * Returns the string "SpotLight".
  16123. * @returns the class name
  16124. */
  16125. getClassName(): string;
  16126. /**
  16127. * Returns the integer 2.
  16128. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  16129. */
  16130. getTypeID(): number;
  16131. /**
  16132. * Overrides the direction setter to recompute the projection texture view light Matrix.
  16133. */
  16134. protected _setDirection(value: Vector3): void;
  16135. /**
  16136. * Overrides the position setter to recompute the projection texture view light Matrix.
  16137. */
  16138. protected _setPosition(value: Vector3): void;
  16139. /**
  16140. * 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.
  16141. * Returns the SpotLight.
  16142. */
  16143. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  16144. protected _computeProjectionTextureViewLightMatrix(): void;
  16145. protected _computeProjectionTextureProjectionLightMatrix(): void;
  16146. /**
  16147. * Main function for light texture projection matrix computing.
  16148. */
  16149. protected _computeProjectionTextureMatrix(): void;
  16150. protected _buildUniformLayout(): void;
  16151. private _computeAngleValues;
  16152. /**
  16153. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  16154. * @param effect The effect to update
  16155. * @param lightIndex The index of the light in the effect to update
  16156. * @returns The spot light
  16157. */
  16158. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  16159. /**
  16160. * Disposes the light and the associated resources.
  16161. */
  16162. dispose(): void;
  16163. /**
  16164. * Prepares the list of defines specific to the light type.
  16165. * @param defines the list of defines
  16166. * @param lightIndex defines the index of the light for the effect
  16167. */
  16168. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  16169. }
  16170. }
  16171. declare module BABYLON {
  16172. /**
  16173. * Interface used to present a loading screen while loading a scene
  16174. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  16175. */
  16176. interface ILoadingScreen {
  16177. /**
  16178. * Function called to display the loading screen
  16179. */
  16180. displayLoadingUI: () => void;
  16181. /**
  16182. * Function called to hide the loading screen
  16183. */
  16184. hideLoadingUI: () => void;
  16185. /**
  16186. * Gets or sets the color to use for the background
  16187. */
  16188. loadingUIBackgroundColor: string;
  16189. /**
  16190. * Gets or sets the text to display while loading
  16191. */
  16192. loadingUIText: string;
  16193. }
  16194. /**
  16195. * Class used for the default loading screen
  16196. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  16197. */
  16198. class DefaultLoadingScreen implements ILoadingScreen {
  16199. private _renderingCanvas;
  16200. private _loadingText;
  16201. private _loadingDivBackgroundColor;
  16202. private _loadingDiv;
  16203. private _loadingTextDiv;
  16204. /**
  16205. * Creates a new default loading screen
  16206. * @param _renderingCanvas defines the canvas used to render the scene
  16207. * @param _loadingText defines the default text to display
  16208. * @param _loadingDivBackgroundColor defines the default background color
  16209. */
  16210. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  16211. /**
  16212. * Function called to display the loading screen
  16213. */
  16214. displayLoadingUI(): void;
  16215. /**
  16216. * Function called to hide the loading screen
  16217. */
  16218. hideLoadingUI(): void;
  16219. /**
  16220. * Gets or sets the text to display while loading
  16221. */
  16222. loadingUIText: string;
  16223. /**
  16224. * Gets or sets the color to use for the background
  16225. */
  16226. loadingUIBackgroundColor: string;
  16227. private _resizeLoadingUI;
  16228. }
  16229. }
  16230. declare module BABYLON {
  16231. /**
  16232. * Class used to represent data loading progression
  16233. */
  16234. class SceneLoaderProgressEvent {
  16235. /** defines if data length to load can be evaluated */
  16236. readonly lengthComputable: boolean;
  16237. /** defines the loaded data length */
  16238. readonly loaded: number;
  16239. /** defines the data length to load */
  16240. readonly total: number;
  16241. /**
  16242. * Create a new progress event
  16243. * @param lengthComputable defines if data length to load can be evaluated
  16244. * @param loaded defines the loaded data length
  16245. * @param total defines the data length to load
  16246. */
  16247. constructor(
  16248. /** defines if data length to load can be evaluated */
  16249. lengthComputable: boolean,
  16250. /** defines the loaded data length */
  16251. loaded: number,
  16252. /** defines the data length to load */
  16253. total: number);
  16254. /**
  16255. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  16256. * @param event defines the source event
  16257. * @returns a new SceneLoaderProgressEvent
  16258. */
  16259. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  16260. }
  16261. /**
  16262. * Interface used by SceneLoader plugins to define supported file extensions
  16263. */
  16264. interface ISceneLoaderPluginExtensions {
  16265. /**
  16266. * Defines the list of supported extensions
  16267. */
  16268. [extension: string]: {
  16269. isBinary: boolean;
  16270. };
  16271. }
  16272. /**
  16273. * Interface used by SceneLoader plugin factory
  16274. */
  16275. interface ISceneLoaderPluginFactory {
  16276. /**
  16277. * Defines the name of the factory
  16278. */
  16279. name: string;
  16280. /**
  16281. * Function called to create a new plugin
  16282. * @return the new plugin
  16283. */
  16284. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  16285. /**
  16286. * Boolean indicating if the plugin can direct load specific data
  16287. */
  16288. canDirectLoad?: (data: string) => boolean;
  16289. }
  16290. /**
  16291. * Interface used to define a SceneLoader plugin
  16292. */
  16293. interface ISceneLoaderPlugin {
  16294. /**
  16295. * The friendly name of this plugin.
  16296. */
  16297. name: string;
  16298. /**
  16299. * The file extensions supported by this plugin.
  16300. */
  16301. extensions: string | ISceneLoaderPluginExtensions;
  16302. /**
  16303. * Import meshes into a scene.
  16304. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  16305. * @param scene The scene to import into
  16306. * @param data The data to import
  16307. * @param rootUrl The root url for scene and resources
  16308. * @param meshes The meshes array to import into
  16309. * @param particleSystems The particle systems array to import into
  16310. * @param skeletons The skeletons array to import into
  16311. * @param onError The callback when import fails
  16312. * @returns True if successful or false otherwise
  16313. */
  16314. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  16315. /**
  16316. * Load into a scene.
  16317. * @param scene The scene to load into
  16318. * @param data The data to import
  16319. * @param rootUrl The root url for scene and resources
  16320. * @param onError The callback when import fails
  16321. * @returns true if successful or false otherwise
  16322. */
  16323. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  16324. /**
  16325. * The callback that returns true if the data can be directly loaded.
  16326. */
  16327. canDirectLoad?: (data: string) => boolean;
  16328. /**
  16329. * The callback that allows custom handling of the root url based on the response url.
  16330. */
  16331. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  16332. /**
  16333. * Load into an asset container.
  16334. * @param scene The scene to load into
  16335. * @param data The data to import
  16336. * @param rootUrl The root url for scene and resources
  16337. * @param onError The callback when import fails
  16338. * @returns The loaded asset container
  16339. */
  16340. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  16341. }
  16342. /**
  16343. * Interface used to define an async SceneLoader plugin
  16344. */
  16345. interface ISceneLoaderPluginAsync {
  16346. /**
  16347. * The friendly name of this plugin.
  16348. */
  16349. name: string;
  16350. /**
  16351. * The file extensions supported by this plugin.
  16352. */
  16353. extensions: string | ISceneLoaderPluginExtensions;
  16354. /**
  16355. * Import meshes into a scene.
  16356. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  16357. * @param scene The scene to import into
  16358. * @param data The data to import
  16359. * @param rootUrl The root url for scene and resources
  16360. * @param onProgress The callback when the load progresses
  16361. * @param fileName Defines the name of the file to load
  16362. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  16363. */
  16364. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  16365. meshes: AbstractMesh[];
  16366. particleSystems: IParticleSystem[];
  16367. skeletons: Skeleton[];
  16368. animationGroups: AnimationGroup[];
  16369. }>;
  16370. /**
  16371. * Load into a scene.
  16372. * @param scene The scene to load into
  16373. * @param data The data to import
  16374. * @param rootUrl The root url for scene and resources
  16375. * @param onProgress The callback when the load progresses
  16376. * @param fileName Defines the name of the file to load
  16377. * @returns Nothing
  16378. */
  16379. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  16380. /**
  16381. * The callback that returns true if the data can be directly loaded.
  16382. */
  16383. canDirectLoad?: (data: string) => boolean;
  16384. /**
  16385. * The callback that allows custom handling of the root url based on the response url.
  16386. */
  16387. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  16388. /**
  16389. * Load into an asset container.
  16390. * @param scene The scene to load into
  16391. * @param data The data to import
  16392. * @param rootUrl The root url for scene and resources
  16393. * @param onProgress The callback when the load progresses
  16394. * @param fileName Defines the name of the file to load
  16395. * @returns The loaded asset container
  16396. */
  16397. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  16398. }
  16399. /**
  16400. * Class used to load scene from various file formats using registered plugins
  16401. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  16402. */
  16403. class SceneLoader {
  16404. private static _ForceFullSceneLoadingForIncremental;
  16405. private static _ShowLoadingScreen;
  16406. private static _CleanBoneMatrixWeights;
  16407. /**
  16408. * No logging while loading
  16409. */
  16410. static readonly NO_LOGGING: number;
  16411. /**
  16412. * Minimal logging while loading
  16413. */
  16414. static readonly MINIMAL_LOGGING: number;
  16415. /**
  16416. * Summary logging while loading
  16417. */
  16418. static readonly SUMMARY_LOGGING: number;
  16419. /**
  16420. * Detailled logging while loading
  16421. */
  16422. static readonly DETAILED_LOGGING: number;
  16423. private static _loggingLevel;
  16424. /**
  16425. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  16426. */
  16427. static ForceFullSceneLoadingForIncremental: boolean;
  16428. /**
  16429. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  16430. */
  16431. static ShowLoadingScreen: boolean;
  16432. /**
  16433. * Defines the current logging level (while loading the scene)
  16434. * @ignorenaming
  16435. */
  16436. static loggingLevel: number;
  16437. /**
  16438. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  16439. */
  16440. static CleanBoneMatrixWeights: boolean;
  16441. /**
  16442. * Event raised when a plugin is used to load a scene
  16443. */
  16444. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  16445. private static _registeredPlugins;
  16446. private static _getDefaultPlugin;
  16447. private static _getPluginForExtension;
  16448. private static _getPluginForDirectLoad;
  16449. private static _getPluginForFilename;
  16450. private static _getDirectLoad;
  16451. private static _loadData;
  16452. private static _getFileInfo;
  16453. /**
  16454. * Gets a plugin that can load the given extension
  16455. * @param extension defines the extension to load
  16456. * @returns a plugin or null if none works
  16457. */
  16458. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  16459. /**
  16460. * Gets a boolean indicating that the given extension can be loaded
  16461. * @param extension defines the extension to load
  16462. * @returns true if the extension is supported
  16463. */
  16464. static IsPluginForExtensionAvailable(extension: string): boolean;
  16465. /**
  16466. * Adds a new plugin to the list of registered plugins
  16467. * @param plugin defines the plugin to add
  16468. */
  16469. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  16470. /**
  16471. * Import meshes into a scene
  16472. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  16473. * @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)
  16474. * @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)
  16475. * @param scene the instance of BABYLON.Scene to append to
  16476. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  16477. * @param onProgress a callback with a progress event for each file being loaded
  16478. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  16479. * @param pluginExtension the extension used to determine the plugin
  16480. * @returns The loaded plugin
  16481. */
  16482. static ImportMesh(meshNames: any, rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onSuccess?: Nullable<(meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[]) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  16483. /**
  16484. * Import meshes into a scene
  16485. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  16486. * @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)
  16487. * @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)
  16488. * @param scene the instance of BABYLON.Scene to append to
  16489. * @param onProgress a callback with a progress event for each file being loaded
  16490. * @param pluginExtension the extension used to determine the plugin
  16491. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  16492. */
  16493. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  16494. meshes: AbstractMesh[];
  16495. particleSystems: IParticleSystem[];
  16496. skeletons: Skeleton[];
  16497. animationGroups: AnimationGroup[];
  16498. }>;
  16499. /**
  16500. * Load a scene
  16501. * @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)
  16502. * @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)
  16503. * @param engine is the instance of BABYLON.Engine to use to create the scene
  16504. * @param onSuccess a callback with the scene when import succeeds
  16505. * @param onProgress a callback with a progress event for each file being loaded
  16506. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  16507. * @param pluginExtension the extension used to determine the plugin
  16508. * @returns The loaded plugin
  16509. */
  16510. static Load(rootUrl: string, sceneFilename: string, engine: Engine, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  16511. /**
  16512. * Load a scene
  16513. * @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)
  16514. * @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)
  16515. * @param engine is the instance of BABYLON.Engine to use to create the scene
  16516. * @param onProgress a callback with a progress event for each file being loaded
  16517. * @param pluginExtension the extension used to determine the plugin
  16518. * @returns The loaded scene
  16519. */
  16520. static LoadAsync(rootUrl: string, sceneFilename: string, engine: Engine, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  16521. /**
  16522. * Append a scene
  16523. * @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)
  16524. * @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)
  16525. * @param scene is the instance of BABYLON.Scene to append to
  16526. * @param onSuccess a callback with the scene when import succeeds
  16527. * @param onProgress a callback with a progress event for each file being loaded
  16528. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  16529. * @param pluginExtension the extension used to determine the plugin
  16530. * @returns The loaded plugin
  16531. */
  16532. static Append(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  16533. /**
  16534. * Append a scene
  16535. * @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)
  16536. * @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)
  16537. * @param scene is the instance of BABYLON.Scene to append to
  16538. * @param onProgress a callback with a progress event for each file being loaded
  16539. * @param pluginExtension the extension used to determine the plugin
  16540. * @returns The given scene
  16541. */
  16542. static AppendAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  16543. /**
  16544. * Load a scene into an asset container
  16545. * @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)
  16546. * @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)
  16547. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  16548. * @param onSuccess a callback with the scene when import succeeds
  16549. * @param onProgress a callback with a progress event for each file being loaded
  16550. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  16551. * @param pluginExtension the extension used to determine the plugin
  16552. * @returns The loaded plugin
  16553. */
  16554. static LoadAssetContainer(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onSuccess?: Nullable<(assets: AssetContainer) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  16555. /**
  16556. * Load a scene into an asset container
  16557. * @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)
  16558. * @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)
  16559. * @param scene is the instance of BABYLON.Scene to append to
  16560. * @param onProgress a callback with a progress event for each file being loaded
  16561. * @param pluginExtension the extension used to determine the plugin
  16562. * @returns The loaded asset container
  16563. */
  16564. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  16565. }
  16566. }
  16567. declare module BABYLON {
  16568. /**
  16569. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  16570. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  16571. * 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;
  16572. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  16573. */
  16574. class ColorCurves {
  16575. private _dirty;
  16576. private _tempColor;
  16577. private _globalCurve;
  16578. private _highlightsCurve;
  16579. private _midtonesCurve;
  16580. private _shadowsCurve;
  16581. private _positiveCurve;
  16582. private _negativeCurve;
  16583. private _globalHue;
  16584. private _globalDensity;
  16585. private _globalSaturation;
  16586. private _globalExposure;
  16587. /**
  16588. * Gets the global Hue value.
  16589. * 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).
  16590. */
  16591. /**
  16592. * Sets the global Hue value.
  16593. * 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).
  16594. */
  16595. globalHue: number;
  16596. /**
  16597. * Gets the global Density value.
  16598. * 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.
  16599. * Values less than zero provide a filter of opposite hue.
  16600. */
  16601. /**
  16602. * Sets the global Density value.
  16603. * 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.
  16604. * Values less than zero provide a filter of opposite hue.
  16605. */
  16606. globalDensity: number;
  16607. /**
  16608. * Gets the global Saturation value.
  16609. * 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.
  16610. */
  16611. /**
  16612. * Sets the global Saturation value.
  16613. * 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.
  16614. */
  16615. globalSaturation: number;
  16616. /**
  16617. * Gets the global Exposure value.
  16618. * 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.
  16619. */
  16620. /**
  16621. * Sets the global Exposure value.
  16622. * 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.
  16623. */
  16624. globalExposure: number;
  16625. private _highlightsHue;
  16626. private _highlightsDensity;
  16627. private _highlightsSaturation;
  16628. private _highlightsExposure;
  16629. /**
  16630. * Gets the highlights Hue value.
  16631. * 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).
  16632. */
  16633. /**
  16634. * Sets the highlights Hue value.
  16635. * 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).
  16636. */
  16637. highlightsHue: number;
  16638. /**
  16639. * Gets the highlights Density value.
  16640. * 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.
  16641. * Values less than zero provide a filter of opposite hue.
  16642. */
  16643. /**
  16644. * Sets the highlights Density value.
  16645. * 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.
  16646. * Values less than zero provide a filter of opposite hue.
  16647. */
  16648. highlightsDensity: number;
  16649. /**
  16650. * Gets the highlights Saturation value.
  16651. * 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.
  16652. */
  16653. /**
  16654. * Sets the highlights Saturation value.
  16655. * 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.
  16656. */
  16657. highlightsSaturation: number;
  16658. /**
  16659. * Gets the highlights Exposure value.
  16660. * 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.
  16661. */
  16662. /**
  16663. * Sets the highlights Exposure value.
  16664. * 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.
  16665. */
  16666. highlightsExposure: number;
  16667. private _midtonesHue;
  16668. private _midtonesDensity;
  16669. private _midtonesSaturation;
  16670. private _midtonesExposure;
  16671. /**
  16672. * Gets the midtones Hue value.
  16673. * 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).
  16674. */
  16675. /**
  16676. * Sets the midtones Hue value.
  16677. * 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).
  16678. */
  16679. midtonesHue: number;
  16680. /**
  16681. * Gets the midtones Density value.
  16682. * 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.
  16683. * Values less than zero provide a filter of opposite hue.
  16684. */
  16685. /**
  16686. * Sets the midtones Density value.
  16687. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  16688. * Values less than zero provide a filter of opposite hue.
  16689. */
  16690. midtonesDensity: number;
  16691. /**
  16692. * Gets the midtones Saturation value.
  16693. * 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.
  16694. */
  16695. /**
  16696. * Sets the midtones Saturation value.
  16697. * 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.
  16698. */
  16699. midtonesSaturation: number;
  16700. /**
  16701. * Gets the midtones Exposure value.
  16702. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  16703. */
  16704. /**
  16705. * Sets the midtones Exposure value.
  16706. * 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.
  16707. */
  16708. midtonesExposure: number;
  16709. private _shadowsHue;
  16710. private _shadowsDensity;
  16711. private _shadowsSaturation;
  16712. private _shadowsExposure;
  16713. /**
  16714. * Gets the shadows Hue value.
  16715. * 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).
  16716. */
  16717. /**
  16718. * Sets the shadows Hue value.
  16719. * 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).
  16720. */
  16721. shadowsHue: number;
  16722. /**
  16723. * Gets the shadows Density value.
  16724. * 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.
  16725. * Values less than zero provide a filter of opposite hue.
  16726. */
  16727. /**
  16728. * Sets the shadows Density value.
  16729. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  16730. * Values less than zero provide a filter of opposite hue.
  16731. */
  16732. shadowsDensity: number;
  16733. /**
  16734. * Gets the shadows Saturation value.
  16735. * 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.
  16736. */
  16737. /**
  16738. * Sets the shadows Saturation value.
  16739. * 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.
  16740. */
  16741. shadowsSaturation: number;
  16742. /**
  16743. * Gets the shadows Exposure value.
  16744. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  16745. */
  16746. /**
  16747. * Sets the shadows Exposure value.
  16748. * 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.
  16749. */
  16750. shadowsExposure: number;
  16751. /**
  16752. * Returns the class name
  16753. * @returns The class name
  16754. */
  16755. getClassName(): string;
  16756. /**
  16757. * Binds the color curves to the shader.
  16758. * @param colorCurves The color curve to bind
  16759. * @param effect The effect to bind to
  16760. * @param positiveUniform The positive uniform shader parameter
  16761. * @param neutralUniform The neutral uniform shader parameter
  16762. * @param negativeUniform The negative uniform shader parameter
  16763. */
  16764. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  16765. /**
  16766. * Prepare the list of uniforms associated with the ColorCurves effects.
  16767. * @param uniformsList The list of uniforms used in the effect
  16768. */
  16769. static PrepareUniforms(uniformsList: string[]): void;
  16770. /**
  16771. * Returns color grading data based on a hue, density, saturation and exposure value.
  16772. * @param filterHue The hue of the color filter.
  16773. * @param filterDensity The density of the color filter.
  16774. * @param saturation The saturation.
  16775. * @param exposure The exposure.
  16776. * @param result The result data container.
  16777. */
  16778. private getColorGradingDataToRef;
  16779. /**
  16780. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  16781. * @param value The input slider value in range [-100,100].
  16782. * @returns Adjusted value.
  16783. */
  16784. private static applyColorGradingSliderNonlinear;
  16785. /**
  16786. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  16787. * @param hue The hue (H) input.
  16788. * @param saturation The saturation (S) input.
  16789. * @param brightness The brightness (B) input.
  16790. * @result An RGBA color represented as Vector4.
  16791. */
  16792. private static fromHSBToRef;
  16793. /**
  16794. * Returns a value clamped between min and max
  16795. * @param value The value to clamp
  16796. * @param min The minimum of value
  16797. * @param max The maximum of value
  16798. * @returns The clamped value.
  16799. */
  16800. private static clamp;
  16801. /**
  16802. * Clones the current color curve instance.
  16803. * @return The cloned curves
  16804. */
  16805. clone(): ColorCurves;
  16806. /**
  16807. * Serializes the current color curve instance to a json representation.
  16808. * @return a JSON representation
  16809. */
  16810. serialize(): any;
  16811. /**
  16812. * Parses the color curve from a json representation.
  16813. * @param source the JSON source to parse
  16814. * @return The parsed curves
  16815. */
  16816. static Parse(source: any): ColorCurves;
  16817. }
  16818. }
  16819. declare module BABYLON {
  16820. /**
  16821. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  16822. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  16823. */
  16824. class EffectFallbacks {
  16825. private _defines;
  16826. private _currentRank;
  16827. private _maxRank;
  16828. private _mesh;
  16829. /**
  16830. * Removes the fallback from the bound mesh.
  16831. */
  16832. unBindMesh(): void;
  16833. /**
  16834. * Adds a fallback on the specified property.
  16835. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  16836. * @param define The name of the define in the shader
  16837. */
  16838. addFallback(rank: number, define: string): void;
  16839. /**
  16840. * Sets the mesh to use CPU skinning when needing to fallback.
  16841. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  16842. * @param mesh The mesh to use the fallbacks.
  16843. */
  16844. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  16845. /**
  16846. * Checks to see if more fallbacks are still availible.
  16847. */
  16848. readonly isMoreFallbacks: boolean;
  16849. /**
  16850. * Removes the defines that shoould be removed when falling back.
  16851. * @param currentDefines defines the current define statements for the shader.
  16852. * @param effect defines the current effect we try to compile
  16853. * @returns The resulting defines with defines of the current rank removed.
  16854. */
  16855. reduce(currentDefines: string, effect: Effect): string;
  16856. }
  16857. /**
  16858. * Options to be used when creating an effect.
  16859. */
  16860. class EffectCreationOptions {
  16861. /**
  16862. * Atrributes that will be used in the shader.
  16863. */
  16864. attributes: string[];
  16865. /**
  16866. * Uniform varible names that will be set in the shader.
  16867. */
  16868. uniformsNames: string[];
  16869. /**
  16870. * Uniform buffer varible names that will be set in the shader.
  16871. */
  16872. uniformBuffersNames: string[];
  16873. /**
  16874. * Sampler texture variable names that will be set in the shader.
  16875. */
  16876. samplers: string[];
  16877. /**
  16878. * Define statements that will be set in the shader.
  16879. */
  16880. defines: any;
  16881. /**
  16882. * Possible fallbacks for this effect to improve performance when needed.
  16883. */
  16884. fallbacks: Nullable<EffectFallbacks>;
  16885. /**
  16886. * Callback that will be called when the shader is compiled.
  16887. */
  16888. onCompiled: Nullable<(effect: Effect) => void>;
  16889. /**
  16890. * Callback that will be called if an error occurs during shader compilation.
  16891. */
  16892. onError: Nullable<(effect: Effect, errors: string) => void>;
  16893. /**
  16894. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  16895. */
  16896. indexParameters: any;
  16897. /**
  16898. * Max number of lights that can be used in the shader.
  16899. */
  16900. maxSimultaneousLights: number;
  16901. /**
  16902. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  16903. */
  16904. transformFeedbackVaryings: Nullable<string[]>;
  16905. }
  16906. /**
  16907. * Effect containing vertex and fragment shader that can be executed on an object.
  16908. */
  16909. class Effect {
  16910. /**
  16911. * Name of the effect.
  16912. */
  16913. name: any;
  16914. /**
  16915. * String container all the define statements that should be set on the shader.
  16916. */
  16917. defines: string;
  16918. /**
  16919. * Callback that will be called when the shader is compiled.
  16920. */
  16921. onCompiled: Nullable<(effect: Effect) => void>;
  16922. /**
  16923. * Callback that will be called if an error occurs during shader compilation.
  16924. */
  16925. onError: Nullable<(effect: Effect, errors: string) => void>;
  16926. /**
  16927. * Callback that will be called when effect is bound.
  16928. */
  16929. onBind: Nullable<(effect: Effect) => void>;
  16930. /**
  16931. * Unique ID of the effect.
  16932. */
  16933. uniqueId: number;
  16934. /**
  16935. * Observable that will be called when the shader is compiled.
  16936. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  16937. */
  16938. onCompileObservable: Observable<Effect>;
  16939. /**
  16940. * Observable that will be called if an error occurs during shader compilation.
  16941. */
  16942. onErrorObservable: Observable<Effect>;
  16943. /** @hidden */
  16944. _onBindObservable: Nullable<Observable<Effect>>;
  16945. /**
  16946. * Observable that will be called when effect is bound.
  16947. */
  16948. readonly onBindObservable: Observable<Effect>;
  16949. /** @hidden */
  16950. _bonesComputationForcedToCPU: boolean;
  16951. private static _uniqueIdSeed;
  16952. private _engine;
  16953. private _uniformBuffersNames;
  16954. private _uniformsNames;
  16955. private _samplers;
  16956. private _isReady;
  16957. private _compilationError;
  16958. private _attributesNames;
  16959. private _attributes;
  16960. private _uniforms;
  16961. /**
  16962. * Key for the effect.
  16963. * @hidden
  16964. */
  16965. _key: string;
  16966. private _indexParameters;
  16967. private _fallbacks;
  16968. private _vertexSourceCode;
  16969. private _fragmentSourceCode;
  16970. private _vertexSourceCodeOverride;
  16971. private _fragmentSourceCodeOverride;
  16972. private _transformFeedbackVaryings;
  16973. /**
  16974. * Compiled shader to webGL program.
  16975. * @hidden
  16976. */
  16977. _program: WebGLProgram;
  16978. private _valueCache;
  16979. private static _baseCache;
  16980. /**
  16981. * Instantiates an effect.
  16982. * An effect can be used to create/manage/execute vertex and fragment shaders.
  16983. * @param baseName Name of the effect.
  16984. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  16985. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  16986. * @param samplers List of sampler variables that will be passed to the shader.
  16987. * @param engine Engine to be used to render the effect
  16988. * @param defines Define statements to be added to the shader.
  16989. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  16990. * @param onCompiled Callback that will be called when the shader is compiled.
  16991. * @param onError Callback that will be called if an error occurs during shader compilation.
  16992. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  16993. */
  16994. 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);
  16995. /**
  16996. * Unique key for this effect
  16997. */
  16998. readonly key: string;
  16999. /**
  17000. * If the effect has been compiled and prepared.
  17001. * @returns if the effect is compiled and prepared.
  17002. */
  17003. isReady(): boolean;
  17004. /**
  17005. * The engine the effect was initialized with.
  17006. * @returns the engine.
  17007. */
  17008. getEngine(): Engine;
  17009. /**
  17010. * The compiled webGL program for the effect
  17011. * @returns the webGL program.
  17012. */
  17013. getProgram(): WebGLProgram;
  17014. /**
  17015. * The set of names of attribute variables for the shader.
  17016. * @returns An array of attribute names.
  17017. */
  17018. getAttributesNames(): string[];
  17019. /**
  17020. * Returns the attribute at the given index.
  17021. * @param index The index of the attribute.
  17022. * @returns The location of the attribute.
  17023. */
  17024. getAttributeLocation(index: number): number;
  17025. /**
  17026. * Returns the attribute based on the name of the variable.
  17027. * @param name of the attribute to look up.
  17028. * @returns the attribute location.
  17029. */
  17030. getAttributeLocationByName(name: string): number;
  17031. /**
  17032. * The number of attributes.
  17033. * @returns the numnber of attributes.
  17034. */
  17035. getAttributesCount(): number;
  17036. /**
  17037. * Gets the index of a uniform variable.
  17038. * @param uniformName of the uniform to look up.
  17039. * @returns the index.
  17040. */
  17041. getUniformIndex(uniformName: string): number;
  17042. /**
  17043. * Returns the attribute based on the name of the variable.
  17044. * @param uniformName of the uniform to look up.
  17045. * @returns the location of the uniform.
  17046. */
  17047. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  17048. /**
  17049. * Returns an array of sampler variable names
  17050. * @returns The array of sampler variable neames.
  17051. */
  17052. getSamplers(): string[];
  17053. /**
  17054. * The error from the last compilation.
  17055. * @returns the error string.
  17056. */
  17057. getCompilationError(): string;
  17058. /**
  17059. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  17060. * @param func The callback to be used.
  17061. */
  17062. executeWhenCompiled(func: (effect: Effect) => void): void;
  17063. private _checkIsReady;
  17064. /** @hidden */
  17065. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  17066. /** @hidden */
  17067. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  17068. /** @hidden */
  17069. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  17070. private _processShaderConversion;
  17071. private _processIncludes;
  17072. private _processPrecision;
  17073. /**
  17074. * Recompiles the webGL program
  17075. * @param vertexSourceCode The source code for the vertex shader.
  17076. * @param fragmentSourceCode The source code for the fragment shader.
  17077. * @param onCompiled Callback called when completed.
  17078. * @param onError Callback called on error.
  17079. * @hidden
  17080. */
  17081. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  17082. /**
  17083. * Gets the uniform locations of the the specified variable names
  17084. * @param names THe names of the variables to lookup.
  17085. * @returns Array of locations in the same order as variable names.
  17086. */
  17087. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  17088. /**
  17089. * Prepares the effect
  17090. * @hidden
  17091. */
  17092. _prepareEffect(): void;
  17093. /**
  17094. * Checks if the effect is supported. (Must be called after compilation)
  17095. */
  17096. readonly isSupported: boolean;
  17097. /**
  17098. * Binds a texture to the engine to be used as output of the shader.
  17099. * @param channel Name of the output variable.
  17100. * @param texture Texture to bind.
  17101. * @hidden
  17102. */
  17103. _bindTexture(channel: string, texture: InternalTexture): void;
  17104. /**
  17105. * Sets a texture on the engine to be used in the shader.
  17106. * @param channel Name of the sampler variable.
  17107. * @param texture Texture to set.
  17108. */
  17109. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  17110. /**
  17111. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  17112. * @param channel Name of the sampler variable.
  17113. * @param texture Texture to set.
  17114. */
  17115. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  17116. /**
  17117. * Sets an array of textures on the engine to be used in the shader.
  17118. * @param channel Name of the variable.
  17119. * @param textures Textures to set.
  17120. */
  17121. setTextureArray(channel: string, textures: BaseTexture[]): void;
  17122. /**
  17123. * 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)
  17124. * @param channel Name of the sampler variable.
  17125. * @param postProcess Post process to get the input texture from.
  17126. */
  17127. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  17128. /**
  17129. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  17130. * 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)
  17131. * @param channel Name of the sampler variable.
  17132. * @param postProcess Post process to get the output texture from.
  17133. */
  17134. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  17135. /** @hidden */
  17136. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  17137. /** @hidden */
  17138. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  17139. /** @hidden */
  17140. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  17141. /** @hidden */
  17142. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  17143. /**
  17144. * Binds a buffer to a uniform.
  17145. * @param buffer Buffer to bind.
  17146. * @param name Name of the uniform variable to bind to.
  17147. */
  17148. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  17149. /**
  17150. * Binds block to a uniform.
  17151. * @param blockName Name of the block to bind.
  17152. * @param index Index to bind.
  17153. */
  17154. bindUniformBlock(blockName: string, index: number): void;
  17155. /**
  17156. * Sets an interger value on a uniform variable.
  17157. * @param uniformName Name of the variable.
  17158. * @param value Value to be set.
  17159. * @returns this effect.
  17160. */
  17161. setInt(uniformName: string, value: number): Effect;
  17162. /**
  17163. * Sets an int array on a uniform variable.
  17164. * @param uniformName Name of the variable.
  17165. * @param array array to be set.
  17166. * @returns this effect.
  17167. */
  17168. setIntArray(uniformName: string, array: Int32Array): Effect;
  17169. /**
  17170. * 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)
  17171. * @param uniformName Name of the variable.
  17172. * @param array array to be set.
  17173. * @returns this effect.
  17174. */
  17175. setIntArray2(uniformName: string, array: Int32Array): Effect;
  17176. /**
  17177. * 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)
  17178. * @param uniformName Name of the variable.
  17179. * @param array array to be set.
  17180. * @returns this effect.
  17181. */
  17182. setIntArray3(uniformName: string, array: Int32Array): Effect;
  17183. /**
  17184. * 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)
  17185. * @param uniformName Name of the variable.
  17186. * @param array array to be set.
  17187. * @returns this effect.
  17188. */
  17189. setIntArray4(uniformName: string, array: Int32Array): Effect;
  17190. /**
  17191. * Sets an float array on a uniform variable.
  17192. * @param uniformName Name of the variable.
  17193. * @param array array to be set.
  17194. * @returns this effect.
  17195. */
  17196. setFloatArray(uniformName: string, array: Float32Array): Effect;
  17197. /**
  17198. * 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)
  17199. * @param uniformName Name of the variable.
  17200. * @param array array to be set.
  17201. * @returns this effect.
  17202. */
  17203. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  17204. /**
  17205. * 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)
  17206. * @param uniformName Name of the variable.
  17207. * @param array array to be set.
  17208. * @returns this effect.
  17209. */
  17210. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  17211. /**
  17212. * 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)
  17213. * @param uniformName Name of the variable.
  17214. * @param array array to be set.
  17215. * @returns this effect.
  17216. */
  17217. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  17218. /**
  17219. * Sets an array on a uniform variable.
  17220. * @param uniformName Name of the variable.
  17221. * @param array array to be set.
  17222. * @returns this effect.
  17223. */
  17224. setArray(uniformName: string, array: number[]): Effect;
  17225. /**
  17226. * 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)
  17227. * @param uniformName Name of the variable.
  17228. * @param array array to be set.
  17229. * @returns this effect.
  17230. */
  17231. setArray2(uniformName: string, array: number[]): Effect;
  17232. /**
  17233. * 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)
  17234. * @param uniformName Name of the variable.
  17235. * @param array array to be set.
  17236. * @returns this effect.
  17237. */
  17238. setArray3(uniformName: string, array: number[]): Effect;
  17239. /**
  17240. * 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)
  17241. * @param uniformName Name of the variable.
  17242. * @param array array to be set.
  17243. * @returns this effect.
  17244. */
  17245. setArray4(uniformName: string, array: number[]): Effect;
  17246. /**
  17247. * Sets matrices on a uniform variable.
  17248. * @param uniformName Name of the variable.
  17249. * @param matrices matrices to be set.
  17250. * @returns this effect.
  17251. */
  17252. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  17253. /**
  17254. * Sets matrix on a uniform variable.
  17255. * @param uniformName Name of the variable.
  17256. * @param matrix matrix to be set.
  17257. * @returns this effect.
  17258. */
  17259. setMatrix(uniformName: string, matrix: Matrix): Effect;
  17260. /**
  17261. * 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)
  17262. * @param uniformName Name of the variable.
  17263. * @param matrix matrix to be set.
  17264. * @returns this effect.
  17265. */
  17266. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  17267. /**
  17268. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  17269. * @param uniformName Name of the variable.
  17270. * @param matrix matrix to be set.
  17271. * @returns this effect.
  17272. */
  17273. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  17274. /**
  17275. * Sets a float on a uniform variable.
  17276. * @param uniformName Name of the variable.
  17277. * @param value value to be set.
  17278. * @returns this effect.
  17279. */
  17280. setFloat(uniformName: string, value: number): Effect;
  17281. /**
  17282. * Sets a boolean on a uniform variable.
  17283. * @param uniformName Name of the variable.
  17284. * @param bool value to be set.
  17285. * @returns this effect.
  17286. */
  17287. setBool(uniformName: string, bool: boolean): Effect;
  17288. /**
  17289. * Sets a Vector2 on a uniform variable.
  17290. * @param uniformName Name of the variable.
  17291. * @param vector2 vector2 to be set.
  17292. * @returns this effect.
  17293. */
  17294. setVector2(uniformName: string, vector2: Vector2): Effect;
  17295. /**
  17296. * Sets a float2 on a uniform variable.
  17297. * @param uniformName Name of the variable.
  17298. * @param x First float in float2.
  17299. * @param y Second float in float2.
  17300. * @returns this effect.
  17301. */
  17302. setFloat2(uniformName: string, x: number, y: number): Effect;
  17303. /**
  17304. * Sets a Vector3 on a uniform variable.
  17305. * @param uniformName Name of the variable.
  17306. * @param vector3 Value to be set.
  17307. * @returns this effect.
  17308. */
  17309. setVector3(uniformName: string, vector3: Vector3): Effect;
  17310. /**
  17311. * Sets a float3 on a uniform variable.
  17312. * @param uniformName Name of the variable.
  17313. * @param x First float in float3.
  17314. * @param y Second float in float3.
  17315. * @param z Third float in float3.
  17316. * @returns this effect.
  17317. */
  17318. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  17319. /**
  17320. * Sets a Vector4 on a uniform variable.
  17321. * @param uniformName Name of the variable.
  17322. * @param vector4 Value to be set.
  17323. * @returns this effect.
  17324. */
  17325. setVector4(uniformName: string, vector4: Vector4): Effect;
  17326. /**
  17327. * Sets a float4 on a uniform variable.
  17328. * @param uniformName Name of the variable.
  17329. * @param x First float in float4.
  17330. * @param y Second float in float4.
  17331. * @param z Third float in float4.
  17332. * @param w Fourth float in float4.
  17333. * @returns this effect.
  17334. */
  17335. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  17336. /**
  17337. * Sets a Color3 on a uniform variable.
  17338. * @param uniformName Name of the variable.
  17339. * @param color3 Value to be set.
  17340. * @returns this effect.
  17341. */
  17342. setColor3(uniformName: string, color3: Color3): Effect;
  17343. /**
  17344. * Sets a Color4 on a uniform variable.
  17345. * @param uniformName Name of the variable.
  17346. * @param color3 Value to be set.
  17347. * @param alpha Alpha value to be set.
  17348. * @returns this effect.
  17349. */
  17350. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  17351. /**
  17352. * Sets a Color4 on a uniform variable
  17353. * @param uniformName defines the name of the variable
  17354. * @param color4 defines the value to be set
  17355. * @returns this effect.
  17356. */
  17357. setDirectColor4(uniformName: string, color4: Color4): Effect;
  17358. /**
  17359. * This function will add a new shader to the shader store
  17360. * @param name the name of the shader
  17361. * @param pixelShader optional pixel shader content
  17362. * @param vertexShader optional vertex shader content
  17363. */
  17364. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  17365. /**
  17366. * Store of each shader (The can be looked up using effect.key)
  17367. */
  17368. static ShadersStore: {
  17369. [key: string]: string;
  17370. };
  17371. /**
  17372. * Store of each included file for a shader (The can be looked up using effect.key)
  17373. */
  17374. static IncludesShadersStore: {
  17375. [key: string]: string;
  17376. };
  17377. /**
  17378. * Resets the cache of effects.
  17379. */
  17380. static ResetCache(): void;
  17381. }
  17382. }
  17383. declare module BABYLON {
  17384. /**
  17385. * This represents all the required information to add a fresnel effect on a material:
  17386. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  17387. */
  17388. class FresnelParameters {
  17389. private _isEnabled;
  17390. /**
  17391. * Define if the fresnel effect is enable or not.
  17392. */
  17393. isEnabled: boolean;
  17394. /**
  17395. * Define the color used on edges (grazing angle)
  17396. */
  17397. leftColor: Color3;
  17398. /**
  17399. * Define the color used on center
  17400. */
  17401. rightColor: Color3;
  17402. /**
  17403. * Define bias applied to computed fresnel term
  17404. */
  17405. bias: number;
  17406. /**
  17407. * Defined the power exponent applied to fresnel term
  17408. */
  17409. power: number;
  17410. /**
  17411. * Clones the current fresnel and its valuues
  17412. * @returns a clone fresnel configuration
  17413. */
  17414. clone(): FresnelParameters;
  17415. /**
  17416. * Serializes the current fresnel parameters to a JSON representation.
  17417. * @return the JSON serialization
  17418. */
  17419. serialize(): any;
  17420. /**
  17421. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  17422. * @param parsedFresnelParameters Define the JSON representation
  17423. * @returns the parsed parameters
  17424. */
  17425. static Parse(parsedFresnelParameters: any): FresnelParameters;
  17426. }
  17427. }
  17428. declare module BABYLON {
  17429. /**
  17430. * Interface to follow in your material defines to integrate easily the
  17431. * Image proccessing functions.
  17432. * @hidden
  17433. */
  17434. interface IImageProcessingConfigurationDefines {
  17435. IMAGEPROCESSING: boolean;
  17436. VIGNETTE: boolean;
  17437. VIGNETTEBLENDMODEMULTIPLY: boolean;
  17438. VIGNETTEBLENDMODEOPAQUE: boolean;
  17439. TONEMAPPING: boolean;
  17440. TONEMAPPING_ACES: boolean;
  17441. CONTRAST: boolean;
  17442. EXPOSURE: boolean;
  17443. COLORCURVES: boolean;
  17444. COLORGRADING: boolean;
  17445. COLORGRADING3D: boolean;
  17446. SAMPLER3DGREENDEPTH: boolean;
  17447. SAMPLER3DBGRMAP: boolean;
  17448. IMAGEPROCESSINGPOSTPROCESS: boolean;
  17449. }
  17450. /**
  17451. * @hidden
  17452. */
  17453. class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  17454. IMAGEPROCESSING: boolean;
  17455. VIGNETTE: boolean;
  17456. VIGNETTEBLENDMODEMULTIPLY: boolean;
  17457. VIGNETTEBLENDMODEOPAQUE: boolean;
  17458. TONEMAPPING: boolean;
  17459. TONEMAPPING_ACES: boolean;
  17460. CONTRAST: boolean;
  17461. COLORCURVES: boolean;
  17462. COLORGRADING: boolean;
  17463. COLORGRADING3D: boolean;
  17464. SAMPLER3DGREENDEPTH: boolean;
  17465. SAMPLER3DBGRMAP: boolean;
  17466. IMAGEPROCESSINGPOSTPROCESS: boolean;
  17467. EXPOSURE: boolean;
  17468. constructor();
  17469. }
  17470. /**
  17471. * This groups together the common properties used for image processing either in direct forward pass
  17472. * or through post processing effect depending on the use of the image processing pipeline in your scene
  17473. * or not.
  17474. */
  17475. class ImageProcessingConfiguration {
  17476. /**
  17477. * Default tone mapping applied in BabylonJS.
  17478. */
  17479. static readonly TONEMAPPING_STANDARD: number;
  17480. /**
  17481. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  17482. * to other engines rendering to increase portability.
  17483. */
  17484. static readonly TONEMAPPING_ACES: number;
  17485. /**
  17486. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  17487. */
  17488. colorCurves: Nullable<ColorCurves>;
  17489. private _colorCurvesEnabled;
  17490. /**
  17491. * Gets wether the color curves effect is enabled.
  17492. */
  17493. /**
  17494. * Sets wether the color curves effect is enabled.
  17495. */
  17496. colorCurvesEnabled: boolean;
  17497. private _colorGradingTexture;
  17498. /**
  17499. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  17500. */
  17501. /**
  17502. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  17503. */
  17504. colorGradingTexture: Nullable<BaseTexture>;
  17505. private _colorGradingEnabled;
  17506. /**
  17507. * Gets wether the color grading effect is enabled.
  17508. */
  17509. /**
  17510. * Sets wether the color grading effect is enabled.
  17511. */
  17512. colorGradingEnabled: boolean;
  17513. private _colorGradingWithGreenDepth;
  17514. /**
  17515. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  17516. */
  17517. /**
  17518. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  17519. */
  17520. colorGradingWithGreenDepth: boolean;
  17521. private _colorGradingBGR;
  17522. /**
  17523. * Gets wether the color grading texture contains BGR values.
  17524. */
  17525. /**
  17526. * Sets wether the color grading texture contains BGR values.
  17527. */
  17528. colorGradingBGR: boolean;
  17529. /** @hidden */
  17530. _exposure: number;
  17531. /**
  17532. * Gets the Exposure used in the effect.
  17533. */
  17534. /**
  17535. * Sets the Exposure used in the effect.
  17536. */
  17537. exposure: number;
  17538. private _toneMappingEnabled;
  17539. /**
  17540. * Gets wether the tone mapping effect is enabled.
  17541. */
  17542. /**
  17543. * Sets wether the tone mapping effect is enabled.
  17544. */
  17545. toneMappingEnabled: boolean;
  17546. private _toneMappingType;
  17547. /**
  17548. * Gets the type of tone mapping effect.
  17549. */
  17550. /**
  17551. * Sets the type of tone mapping effect used in BabylonJS.
  17552. */
  17553. toneMappingType: number;
  17554. protected _contrast: number;
  17555. /**
  17556. * Gets the contrast used in the effect.
  17557. */
  17558. /**
  17559. * Sets the contrast used in the effect.
  17560. */
  17561. contrast: number;
  17562. /**
  17563. * Vignette stretch size.
  17564. */
  17565. vignetteStretch: number;
  17566. /**
  17567. * Vignette centre X Offset.
  17568. */
  17569. vignetteCentreX: number;
  17570. /**
  17571. * Vignette centre Y Offset.
  17572. */
  17573. vignetteCentreY: number;
  17574. /**
  17575. * Vignette weight or intensity of the vignette effect.
  17576. */
  17577. vignetteWeight: number;
  17578. /**
  17579. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  17580. * if vignetteEnabled is set to true.
  17581. */
  17582. vignetteColor: Color4;
  17583. /**
  17584. * Camera field of view used by the Vignette effect.
  17585. */
  17586. vignetteCameraFov: number;
  17587. private _vignetteBlendMode;
  17588. /**
  17589. * Gets the vignette blend mode allowing different kind of effect.
  17590. */
  17591. /**
  17592. * Sets the vignette blend mode allowing different kind of effect.
  17593. */
  17594. vignetteBlendMode: number;
  17595. private _vignetteEnabled;
  17596. /**
  17597. * Gets wether the vignette effect is enabled.
  17598. */
  17599. /**
  17600. * Sets wether the vignette effect is enabled.
  17601. */
  17602. vignetteEnabled: boolean;
  17603. private _applyByPostProcess;
  17604. /**
  17605. * Gets wether the image processing is applied through a post process or not.
  17606. */
  17607. /**
  17608. * Sets wether the image processing is applied through a post process or not.
  17609. */
  17610. applyByPostProcess: boolean;
  17611. private _isEnabled;
  17612. /**
  17613. * Gets wether the image processing is enabled or not.
  17614. */
  17615. /**
  17616. * Sets wether the image processing is enabled or not.
  17617. */
  17618. isEnabled: boolean;
  17619. /**
  17620. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  17621. */
  17622. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  17623. /**
  17624. * Method called each time the image processing information changes requires to recompile the effect.
  17625. */
  17626. protected _updateParameters(): void;
  17627. /**
  17628. * Gets the current class name.
  17629. * @return "ImageProcessingConfiguration"
  17630. */
  17631. getClassName(): string;
  17632. /**
  17633. * Prepare the list of uniforms associated with the Image Processing effects.
  17634. * @param uniforms The list of uniforms used in the effect
  17635. * @param defines the list of defines currently in use
  17636. */
  17637. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  17638. /**
  17639. * Prepare the list of samplers associated with the Image Processing effects.
  17640. * @param samplersList The list of uniforms used in the effect
  17641. * @param defines the list of defines currently in use
  17642. */
  17643. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  17644. /**
  17645. * Prepare the list of defines associated to the shader.
  17646. * @param defines the list of defines to complete
  17647. * @param forPostProcess Define if we are currently in post process mode or not
  17648. */
  17649. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  17650. /**
  17651. * Returns true if all the image processing information are ready.
  17652. * @returns True if ready, otherwise, false
  17653. */
  17654. isReady(): boolean;
  17655. /**
  17656. * Binds the image processing to the shader.
  17657. * @param effect The effect to bind to
  17658. * @param aspectRatio Define the current aspect ratio of the effect
  17659. */
  17660. bind(effect: Effect, aspectRatio?: number): void;
  17661. /**
  17662. * Clones the current image processing instance.
  17663. * @return The cloned image processing
  17664. */
  17665. clone(): ImageProcessingConfiguration;
  17666. /**
  17667. * Serializes the current image processing instance to a json representation.
  17668. * @return a JSON representation
  17669. */
  17670. serialize(): any;
  17671. /**
  17672. * Parses the image processing from a json representation.
  17673. * @param source the JSON source to parse
  17674. * @return The parsed image processing
  17675. */
  17676. static Parse(source: any): ImageProcessingConfiguration;
  17677. private static _VIGNETTEMODE_MULTIPLY;
  17678. private static _VIGNETTEMODE_OPAQUE;
  17679. /**
  17680. * Used to apply the vignette as a mix with the pixel color.
  17681. */
  17682. static readonly VIGNETTEMODE_MULTIPLY: number;
  17683. /**
  17684. * Used to apply the vignette as a replacement of the pixel color.
  17685. */
  17686. static readonly VIGNETTEMODE_OPAQUE: number;
  17687. }
  17688. }
  17689. declare module BABYLON {
  17690. /**
  17691. * Manages the defines for the Material
  17692. */
  17693. class MaterialDefines {
  17694. private _keys;
  17695. private _isDirty;
  17696. /** @hidden */
  17697. _renderId: number;
  17698. /** @hidden */
  17699. _areLightsDirty: boolean;
  17700. /** @hidden */
  17701. _areAttributesDirty: boolean;
  17702. /** @hidden */
  17703. _areTexturesDirty: boolean;
  17704. /** @hidden */
  17705. _areFresnelDirty: boolean;
  17706. /** @hidden */
  17707. _areMiscDirty: boolean;
  17708. /** @hidden */
  17709. _areImageProcessingDirty: boolean;
  17710. /** @hidden */
  17711. _normals: boolean;
  17712. /** @hidden */
  17713. _uvs: boolean;
  17714. /** @hidden */
  17715. _needNormals: boolean;
  17716. /** @hidden */
  17717. _needUVs: boolean;
  17718. /**
  17719. * Specifies if the material needs to be re-calculated
  17720. */
  17721. readonly isDirty: boolean;
  17722. /**
  17723. * Marks the material to indicate that it has been re-calculated
  17724. */
  17725. markAsProcessed(): void;
  17726. /**
  17727. * Marks the material to indicate that it needs to be re-calculated
  17728. */
  17729. markAsUnprocessed(): void;
  17730. /**
  17731. * Marks the material to indicate all of its defines need to be re-calculated
  17732. */
  17733. markAllAsDirty(): void;
  17734. /**
  17735. * Marks the material to indicate that image processing needs to be re-calculated
  17736. */
  17737. markAsImageProcessingDirty(): void;
  17738. /**
  17739. * Marks the material to indicate the lights need to be re-calculated
  17740. */
  17741. markAsLightDirty(): void;
  17742. /**
  17743. * Marks the attribute state as changed
  17744. */
  17745. markAsAttributesDirty(): void;
  17746. /**
  17747. * Marks the texture state as changed
  17748. */
  17749. markAsTexturesDirty(): void;
  17750. /**
  17751. * Marks the fresnel state as changed
  17752. */
  17753. markAsFresnelDirty(): void;
  17754. /**
  17755. * Marks the misc state as changed
  17756. */
  17757. markAsMiscDirty(): void;
  17758. /**
  17759. * Rebuilds the material defines
  17760. */
  17761. rebuild(): void;
  17762. /**
  17763. * Specifies if two material defines are equal
  17764. * @param other - A material define instance to compare to
  17765. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  17766. */
  17767. isEqual(other: MaterialDefines): boolean;
  17768. /**
  17769. * Clones this instance's defines to another instance
  17770. * @param other - material defines to clone values to
  17771. */
  17772. cloneTo(other: MaterialDefines): void;
  17773. /**
  17774. * Resets the material define values
  17775. */
  17776. reset(): void;
  17777. /**
  17778. * Converts the material define values to a string
  17779. * @returns - String of material define information
  17780. */
  17781. toString(): string;
  17782. }
  17783. /**
  17784. * Base class for the main features of a material in Babylon.js
  17785. */
  17786. class Material implements IAnimatable {
  17787. private static _TriangleFillMode;
  17788. private static _WireFrameFillMode;
  17789. private static _PointFillMode;
  17790. private static _PointListDrawMode;
  17791. private static _LineListDrawMode;
  17792. private static _LineLoopDrawMode;
  17793. private static _LineStripDrawMode;
  17794. private static _TriangleStripDrawMode;
  17795. private static _TriangleFanDrawMode;
  17796. /**
  17797. * Returns the triangle fill mode
  17798. */
  17799. static readonly TriangleFillMode: number;
  17800. /**
  17801. * Returns the wireframe mode
  17802. */
  17803. static readonly WireFrameFillMode: number;
  17804. /**
  17805. * Returns the point fill mode
  17806. */
  17807. static readonly PointFillMode: number;
  17808. /**
  17809. * Returns the point list draw mode
  17810. */
  17811. static readonly PointListDrawMode: number;
  17812. /**
  17813. * Returns the line list draw mode
  17814. */
  17815. static readonly LineListDrawMode: number;
  17816. /**
  17817. * Returns the line loop draw mode
  17818. */
  17819. static readonly LineLoopDrawMode: number;
  17820. /**
  17821. * Returns the line strip draw mode
  17822. */
  17823. static readonly LineStripDrawMode: number;
  17824. /**
  17825. * Returns the triangle strip draw mode
  17826. */
  17827. static readonly TriangleStripDrawMode: number;
  17828. /**
  17829. * Returns the triangle fan draw mode
  17830. */
  17831. static readonly TriangleFanDrawMode: number;
  17832. /**
  17833. * Stores the clock-wise side orientation
  17834. */
  17835. private static _ClockWiseSideOrientation;
  17836. /**
  17837. * Stores the counter clock-wise side orientation
  17838. */
  17839. private static _CounterClockWiseSideOrientation;
  17840. /**
  17841. * Returns the clock-wise side orientation
  17842. */
  17843. static readonly ClockWiseSideOrientation: number;
  17844. /**
  17845. * Returns the counter clock-wise side orientation
  17846. */
  17847. static readonly CounterClockWiseSideOrientation: number;
  17848. /**
  17849. * The dirty texture flag value
  17850. */
  17851. static readonly TextureDirtyFlag: number;
  17852. /**
  17853. * The dirty light flag value
  17854. */
  17855. static readonly LightDirtyFlag: number;
  17856. /**
  17857. * The dirty fresnel flag value
  17858. */
  17859. static readonly FresnelDirtyFlag: number;
  17860. /**
  17861. * The dirty attribute flag value
  17862. */
  17863. static readonly AttributesDirtyFlag: number;
  17864. /**
  17865. * The dirty misc flag value
  17866. */
  17867. static readonly MiscDirtyFlag: number;
  17868. /**
  17869. * The all dirty flag value
  17870. */
  17871. static readonly AllDirtyFlag: number;
  17872. /**
  17873. * The ID of the material
  17874. */
  17875. id: string;
  17876. /**
  17877. * Gets or sets the unique id of the material
  17878. */
  17879. uniqueId: number;
  17880. /**
  17881. * The name of the material
  17882. */
  17883. name: string;
  17884. /**
  17885. * Specifies if the ready state should be checked on each call
  17886. */
  17887. checkReadyOnEveryCall: boolean;
  17888. /**
  17889. * Specifies if the ready state should be checked once
  17890. */
  17891. checkReadyOnlyOnce: boolean;
  17892. /**
  17893. * The state of the material
  17894. */
  17895. state: string;
  17896. /**
  17897. * The alpha value of the material
  17898. */
  17899. protected _alpha: number;
  17900. /**
  17901. * Sets the alpha value of the material
  17902. */
  17903. /**
  17904. * Gets the alpha value of the material
  17905. */
  17906. alpha: number;
  17907. /**
  17908. * Specifies if back face culling is enabled
  17909. */
  17910. protected _backFaceCulling: boolean;
  17911. /**
  17912. * Sets the back-face culling state
  17913. */
  17914. /**
  17915. * Gets the back-face culling state
  17916. */
  17917. backFaceCulling: boolean;
  17918. /**
  17919. * Stores the value for side orientation
  17920. */
  17921. sideOrientation: number;
  17922. /**
  17923. * Callback triggered when the material is compiled
  17924. */
  17925. onCompiled: (effect: Effect) => void;
  17926. /**
  17927. * Callback triggered when an error occurs
  17928. */
  17929. onError: (effect: Effect, errors: string) => void;
  17930. /**
  17931. * Callback triggered to get the render target textures
  17932. */
  17933. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  17934. /**
  17935. * Gets a boolean indicating that current material needs to register RTT
  17936. */
  17937. readonly hasRenderTargetTextures: boolean;
  17938. /**
  17939. * Specifies if the material should be serialized
  17940. */
  17941. doNotSerialize: boolean;
  17942. /**
  17943. * Specifies if the effect should be stored on sub meshes
  17944. */
  17945. storeEffectOnSubMeshes: boolean;
  17946. /**
  17947. * Stores the animations for the material
  17948. */
  17949. animations: Array<Animation>;
  17950. /**
  17951. * An event triggered when the material is disposed
  17952. */
  17953. onDisposeObservable: Observable<Material>;
  17954. /**
  17955. * An observer which watches for dispose events
  17956. */
  17957. private _onDisposeObserver;
  17958. private _onUnBindObservable;
  17959. /**
  17960. * Called during a dispose event
  17961. */
  17962. onDispose: () => void;
  17963. private _onBindObservable;
  17964. /**
  17965. * An event triggered when the material is bound
  17966. */
  17967. readonly onBindObservable: Observable<AbstractMesh>;
  17968. /**
  17969. * An observer which watches for bind events
  17970. */
  17971. private _onBindObserver;
  17972. /**
  17973. * Called during a bind event
  17974. */
  17975. onBind: (Mesh: AbstractMesh) => void;
  17976. /**
  17977. * An event triggered when the material is unbound
  17978. */
  17979. readonly onUnBindObservable: Observable<Material>;
  17980. /**
  17981. * Stores the value of the alpha mode
  17982. */
  17983. private _alphaMode;
  17984. /**
  17985. * Sets the value of the alpha mode.
  17986. *
  17987. * | Value | Type | Description |
  17988. * | --- | --- | --- |
  17989. * | 0 | ALPHA_DISABLE | |
  17990. * | 1 | ALPHA_ADD | |
  17991. * | 2 | ALPHA_COMBINE | |
  17992. * | 3 | ALPHA_SUBTRACT | |
  17993. * | 4 | ALPHA_MULTIPLY | |
  17994. * | 5 | ALPHA_MAXIMIZED | |
  17995. * | 6 | ALPHA_ONEONE | |
  17996. * | 7 | ALPHA_PREMULTIPLIED | |
  17997. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  17998. * | 9 | ALPHA_INTERPOLATE | |
  17999. * | 10 | ALPHA_SCREENMODE | |
  18000. *
  18001. */
  18002. /**
  18003. * Gets the value of the alpha mode
  18004. */
  18005. alphaMode: number;
  18006. /**
  18007. * Stores the state of the need depth pre-pass value
  18008. */
  18009. private _needDepthPrePass;
  18010. /**
  18011. * Sets the need depth pre-pass value
  18012. */
  18013. /**
  18014. * Gets the depth pre-pass value
  18015. */
  18016. needDepthPrePass: boolean;
  18017. /**
  18018. * Specifies if depth writing should be disabled
  18019. */
  18020. disableDepthWrite: boolean;
  18021. /**
  18022. * Specifies if depth writing should be forced
  18023. */
  18024. forceDepthWrite: boolean;
  18025. /**
  18026. * Specifies if there should be a separate pass for culling
  18027. */
  18028. separateCullingPass: boolean;
  18029. /**
  18030. * Stores the state specifing if fog should be enabled
  18031. */
  18032. private _fogEnabled;
  18033. /**
  18034. * Sets the state for enabling fog
  18035. */
  18036. /**
  18037. * Gets the value of the fog enabled state
  18038. */
  18039. fogEnabled: boolean;
  18040. /**
  18041. * Stores the size of points
  18042. */
  18043. pointSize: number;
  18044. /**
  18045. * Stores the z offset value
  18046. */
  18047. zOffset: number;
  18048. /**
  18049. * Gets a value specifying if wireframe mode is enabled
  18050. */
  18051. /**
  18052. * Sets the state of wireframe mode
  18053. */
  18054. wireframe: boolean;
  18055. /**
  18056. * Gets the value specifying if point clouds are enabled
  18057. */
  18058. /**
  18059. * Sets the state of point cloud mode
  18060. */
  18061. pointsCloud: boolean;
  18062. /**
  18063. * Gets the material fill mode
  18064. */
  18065. /**
  18066. * Sets the material fill mode
  18067. */
  18068. fillMode: number;
  18069. /**
  18070. * @hidden
  18071. * Stores the effects for the material
  18072. */
  18073. _effect: Nullable<Effect>;
  18074. /**
  18075. * @hidden
  18076. * Specifies if the material was previously ready
  18077. */
  18078. _wasPreviouslyReady: boolean;
  18079. /**
  18080. * Specifies if uniform buffers should be used
  18081. */
  18082. private _useUBO;
  18083. /**
  18084. * Stores a reference to the scene
  18085. */
  18086. private _scene;
  18087. /**
  18088. * Stores the fill mode state
  18089. */
  18090. private _fillMode;
  18091. /**
  18092. * Specifies if the depth write state should be cached
  18093. */
  18094. private _cachedDepthWriteState;
  18095. /**
  18096. * Stores the uniform buffer
  18097. */
  18098. protected _uniformBuffer: UniformBuffer;
  18099. /**
  18100. * Creates a material instance
  18101. * @param name defines the name of the material
  18102. * @param scene defines the scene to reference
  18103. * @param doNotAdd specifies if the material should be added to the scene
  18104. */
  18105. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  18106. /**
  18107. * Returns a string representation of the current material
  18108. * @param fullDetails defines a boolean indicating which levels of logging is desired
  18109. * @returns a string with material information
  18110. */
  18111. toString(fullDetails?: boolean): string;
  18112. /**
  18113. * Gets the class name of the material
  18114. * @returns a string with the class name of the material
  18115. */
  18116. getClassName(): string;
  18117. /**
  18118. * Specifies if updates for the material been locked
  18119. */
  18120. readonly isFrozen: boolean;
  18121. /**
  18122. * Locks updates for the material
  18123. */
  18124. freeze(): void;
  18125. /**
  18126. * Unlocks updates for the material
  18127. */
  18128. unfreeze(): void;
  18129. /**
  18130. * Specifies if the material is ready to be used
  18131. * @param mesh defines the mesh to check
  18132. * @param useInstances specifies if instances should be used
  18133. * @returns a boolean indicating if the material is ready to be used
  18134. */
  18135. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  18136. /**
  18137. * Specifies that the submesh is ready to be used
  18138. * @param mesh defines the mesh to check
  18139. * @param subMesh defines which submesh to check
  18140. * @param useInstances specifies that instances should be used
  18141. * @returns a boolean indicating that the submesh is ready or not
  18142. */
  18143. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  18144. /**
  18145. * Returns the material effect
  18146. * @returns the effect associated with the material
  18147. */
  18148. getEffect(): Nullable<Effect>;
  18149. /**
  18150. * Returns the current scene
  18151. * @returns a Scene
  18152. */
  18153. getScene(): Scene;
  18154. /**
  18155. * Specifies if the material will require alpha blending
  18156. * @returns a boolean specifying if alpha blending is needed
  18157. */
  18158. needAlphaBlending(): boolean;
  18159. /**
  18160. * Specifies if the mesh will require alpha blending
  18161. * @param mesh defines the mesh to check
  18162. * @returns a boolean specifying if alpha blending is needed for the mesh
  18163. */
  18164. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  18165. /**
  18166. * Specifies if this material should be rendered in alpha test mode
  18167. * @returns a boolean specifying if an alpha test is needed.
  18168. */
  18169. needAlphaTesting(): boolean;
  18170. /**
  18171. * Gets the texture used for the alpha test
  18172. * @returns the texture to use for alpha testing
  18173. */
  18174. getAlphaTestTexture(): Nullable<BaseTexture>;
  18175. /**
  18176. * Marks the material to indicate that it needs to be re-calculated
  18177. */
  18178. markDirty(): void;
  18179. /** @hidden */
  18180. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  18181. /**
  18182. * Binds the material to the mesh
  18183. * @param world defines the world transformation matrix
  18184. * @param mesh defines the mesh to bind the material to
  18185. */
  18186. bind(world: Matrix, mesh?: Mesh): void;
  18187. /**
  18188. * Binds the submesh to the material
  18189. * @param world defines the world transformation matrix
  18190. * @param mesh defines the mesh containing the submesh
  18191. * @param subMesh defines the submesh to bind the material to
  18192. */
  18193. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  18194. /**
  18195. * Binds the world matrix to the material
  18196. * @param world defines the world transformation matrix
  18197. */
  18198. bindOnlyWorldMatrix(world: Matrix): void;
  18199. /**
  18200. * Binds the scene's uniform buffer to the effect.
  18201. * @param effect defines the effect to bind to the scene uniform buffer
  18202. * @param sceneUbo defines the uniform buffer storing scene data
  18203. */
  18204. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  18205. /**
  18206. * Binds the view matrix to the effect
  18207. * @param effect defines the effect to bind the view matrix to
  18208. */
  18209. bindView(effect: Effect): void;
  18210. /**
  18211. * Binds the view projection matrix to the effect
  18212. * @param effect defines the effect to bind the view projection matrix to
  18213. */
  18214. bindViewProjection(effect: Effect): void;
  18215. /**
  18216. * Specifies if material alpha testing should be turned on for the mesh
  18217. * @param mesh defines the mesh to check
  18218. */
  18219. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  18220. /**
  18221. * Processes to execute after binding the material to a mesh
  18222. * @param mesh defines the rendered mesh
  18223. */
  18224. protected _afterBind(mesh?: Mesh): void;
  18225. /**
  18226. * Unbinds the material from the mesh
  18227. */
  18228. unbind(): void;
  18229. /**
  18230. * Gets the active textures from the material
  18231. * @returns an array of textures
  18232. */
  18233. getActiveTextures(): BaseTexture[];
  18234. /**
  18235. * Specifies if the material uses a texture
  18236. * @param texture defines the texture to check against the material
  18237. * @returns a boolean specifying if the material uses the texture
  18238. */
  18239. hasTexture(texture: BaseTexture): boolean;
  18240. /**
  18241. * Makes a duplicate of the material, and gives it a new name
  18242. * @param name defines the new name for the duplicated material
  18243. * @returns the cloned material
  18244. */
  18245. clone(name: string): Nullable<Material>;
  18246. /**
  18247. * Gets the meshes bound to the material
  18248. * @returns an array of meshes bound to the material
  18249. */
  18250. getBindedMeshes(): AbstractMesh[];
  18251. /**
  18252. * Force shader compilation
  18253. * @param mesh defines the mesh associated with this material
  18254. * @param onCompiled defines a function to execute once the material is compiled
  18255. * @param options defines the options to configure the compilation
  18256. */
  18257. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  18258. clipPlane: boolean;
  18259. }>): void;
  18260. /**
  18261. * Force shader compilation
  18262. * @param mesh defines the mesh that will use this material
  18263. * @param options defines additional options for compiling the shaders
  18264. * @returns a promise that resolves when the compilation completes
  18265. */
  18266. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  18267. clipPlane: boolean;
  18268. }>): Promise<void>;
  18269. /**
  18270. * Marks a define in the material to indicate that it needs to be re-computed
  18271. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  18272. */
  18273. markAsDirty(flag: number): void;
  18274. /**
  18275. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  18276. * @param func defines a function which checks material defines against the submeshes
  18277. */
  18278. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  18279. /**
  18280. * Indicates that image processing needs to be re-calculated for all submeshes
  18281. */
  18282. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  18283. /**
  18284. * Indicates that textures need to be re-calculated for all submeshes
  18285. */
  18286. protected _markAllSubMeshesAsTexturesDirty(): void;
  18287. /**
  18288. * Indicates that fresnel needs to be re-calculated for all submeshes
  18289. */
  18290. protected _markAllSubMeshesAsFresnelDirty(): void;
  18291. /**
  18292. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  18293. */
  18294. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  18295. /**
  18296. * Indicates that lights need to be re-calculated for all submeshes
  18297. */
  18298. protected _markAllSubMeshesAsLightsDirty(): void;
  18299. /**
  18300. * Indicates that attributes need to be re-calculated for all submeshes
  18301. */
  18302. protected _markAllSubMeshesAsAttributesDirty(): void;
  18303. /**
  18304. * Indicates that misc needs to be re-calculated for all submeshes
  18305. */
  18306. protected _markAllSubMeshesAsMiscDirty(): void;
  18307. /**
  18308. * Indicates that textures and misc need to be re-calculated for all submeshes
  18309. */
  18310. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  18311. /**
  18312. * Disposes the material
  18313. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  18314. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  18315. */
  18316. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  18317. /**
  18318. * Serializes this material
  18319. * @returns the serialized material object
  18320. */
  18321. serialize(): any;
  18322. /**
  18323. * Creates a MultiMaterial from parsed MultiMaterial data.
  18324. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  18325. * @param scene defines the hosting scene
  18326. * @returns a new MultiMaterial
  18327. */
  18328. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  18329. /**
  18330. * Creates a material from parsed material data
  18331. * @param parsedMaterial defines parsed material data
  18332. * @param scene defines the hosting scene
  18333. * @param rootUrl defines the root URL to use to load textures
  18334. * @returns a new material
  18335. */
  18336. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  18337. }
  18338. }
  18339. declare module BABYLON {
  18340. /**
  18341. * "Static Class" containing the most commonly used helper while dealing with material for
  18342. * rendering purpose.
  18343. *
  18344. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  18345. *
  18346. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  18347. */
  18348. class MaterialHelper {
  18349. /**
  18350. * Bind the current view position to an effect.
  18351. * @param effect The effect to be bound
  18352. * @param scene The scene the eyes position is used from
  18353. */
  18354. static BindEyePosition(effect: Effect, scene: Scene): void;
  18355. /**
  18356. * Helps preparing the defines values about the UVs in used in the effect.
  18357. * UVs are shared as much as we can accross channels in the shaders.
  18358. * @param texture The texture we are preparing the UVs for
  18359. * @param defines The defines to update
  18360. * @param key The channel key "diffuse", "specular"... used in the shader
  18361. */
  18362. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  18363. /**
  18364. * Binds a texture matrix value to its corrsponding uniform
  18365. * @param texture The texture to bind the matrix for
  18366. * @param uniformBuffer The uniform buffer receivin the data
  18367. * @param key The channel key "diffuse", "specular"... used in the shader
  18368. */
  18369. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  18370. /**
  18371. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  18372. * @param mesh defines the current mesh
  18373. * @param scene defines the current scene
  18374. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  18375. * @param pointsCloud defines if point cloud rendering has to be turned on
  18376. * @param fogEnabled defines if fog has to be turned on
  18377. * @param alphaTest defines if alpha testing has to be turned on
  18378. * @param defines defines the current list of defines
  18379. */
  18380. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  18381. /**
  18382. * Helper used to prepare the list of defines associated with frame values for shader compilation
  18383. * @param scene defines the current scene
  18384. * @param engine defines the current engine
  18385. * @param defines specifies the list of active defines
  18386. * @param useInstances defines if instances have to be turned on
  18387. * @param useClipPlane defines if clip plane have to be turned on
  18388. */
  18389. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  18390. /**
  18391. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  18392. * @param mesh The mesh containing the geometry data we will draw
  18393. * @param defines The defines to update
  18394. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  18395. * @param useBones Precise whether bones should be used or not (override mesh info)
  18396. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  18397. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  18398. * @returns false if defines are considered not dirty and have not been checked
  18399. */
  18400. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  18401. /**
  18402. * Prepares the defines related to the light information passed in parameter
  18403. * @param scene The scene we are intending to draw
  18404. * @param mesh The mesh the effect is compiling for
  18405. * @param defines The defines to update
  18406. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  18407. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  18408. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  18409. * @returns true if normals will be required for the rest of the effect
  18410. */
  18411. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  18412. /**
  18413. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  18414. * that won t be acctive due to defines being turned off.
  18415. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  18416. * @param samplersList The samplers list
  18417. * @param defines The defines helping in the list generation
  18418. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  18419. */
  18420. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  18421. /**
  18422. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  18423. * @param defines The defines to update while falling back
  18424. * @param fallbacks The authorized effect fallbacks
  18425. * @param maxSimultaneousLights The maximum number of lights allowed
  18426. * @param rank the current rank of the Effect
  18427. * @returns The newly affected rank
  18428. */
  18429. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  18430. /**
  18431. * Prepares the list of attributes required for morph targets according to the effect defines.
  18432. * @param attribs The current list of supported attribs
  18433. * @param mesh The mesh to prepare the morph targets attributes for
  18434. * @param defines The current Defines of the effect
  18435. */
  18436. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  18437. /**
  18438. * Prepares the list of attributes required for bones according to the effect defines.
  18439. * @param attribs The current list of supported attribs
  18440. * @param mesh The mesh to prepare the bones attributes for
  18441. * @param defines The current Defines of the effect
  18442. * @param fallbacks The current efffect fallback strategy
  18443. */
  18444. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  18445. /**
  18446. * Prepares the list of attributes required for instances according to the effect defines.
  18447. * @param attribs The current list of supported attribs
  18448. * @param defines The current Defines of the effect
  18449. */
  18450. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  18451. /**
  18452. * Binds the light shadow information to the effect for the given mesh.
  18453. * @param light The light containing the generator
  18454. * @param scene The scene the lights belongs to
  18455. * @param mesh The mesh we are binding the information to render
  18456. * @param lightIndex The light index in the effect used to render the mesh
  18457. * @param effect The effect we are binding the data to
  18458. */
  18459. static BindLightShadow(light: Light, scene: Scene, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  18460. /**
  18461. * Binds the light information to the effect.
  18462. * @param light The light containing the generator
  18463. * @param effect The effect we are binding the data to
  18464. * @param lightIndex The light index in the effect used to render
  18465. */
  18466. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  18467. /**
  18468. * Binds the lights information from the scene to the effect for the given mesh.
  18469. * @param scene The scene the lights belongs to
  18470. * @param mesh The mesh we are binding the information to render
  18471. * @param effect The effect we are binding the data to
  18472. * @param defines The generated defines for the effect
  18473. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  18474. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  18475. */
  18476. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  18477. private static _tempFogColor;
  18478. /**
  18479. * Binds the fog information from the scene to the effect for the given mesh.
  18480. * @param scene The scene the lights belongs to
  18481. * @param mesh The mesh we are binding the information to render
  18482. * @param effect The effect we are binding the data to
  18483. * @param linearSpace Defines if the fog effect is applied in linear space
  18484. */
  18485. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  18486. /**
  18487. * Binds the bones information from the mesh to the effect.
  18488. * @param mesh The mesh we are binding the information to render
  18489. * @param effect The effect we are binding the data to
  18490. */
  18491. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  18492. /**
  18493. * Binds the morph targets information from the mesh to the effect.
  18494. * @param abstractMesh The mesh we are binding the information to render
  18495. * @param effect The effect we are binding the data to
  18496. */
  18497. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  18498. /**
  18499. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  18500. * @param defines The generated defines used in the effect
  18501. * @param effect The effect we are binding the data to
  18502. * @param scene The scene we are willing to render with logarithmic scale for
  18503. */
  18504. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  18505. /**
  18506. * Binds the clip plane information from the scene to the effect.
  18507. * @param scene The scene the clip plane information are extracted from
  18508. * @param effect The effect we are binding the data to
  18509. */
  18510. static BindClipPlane(effect: Effect, scene: Scene): void;
  18511. }
  18512. }
  18513. declare module BABYLON {
  18514. /**
  18515. * A multi-material is used to apply different materials to different parts of the same object without the need of
  18516. * separate meshes. This can be use to improve performances.
  18517. * @see http://doc.babylonjs.com/how_to/multi_materials
  18518. */
  18519. class MultiMaterial extends Material {
  18520. private _subMaterials;
  18521. /**
  18522. * Gets or Sets the list of Materials used within the multi material.
  18523. * They need to be ordered according to the submeshes order in the associated mesh
  18524. */
  18525. subMaterials: Nullable<Material>[];
  18526. /**
  18527. * Instantiates a new Multi Material
  18528. * A multi-material is used to apply different materials to different parts of the same object without the need of
  18529. * separate meshes. This can be use to improve performances.
  18530. * @see http://doc.babylonjs.com/how_to/multi_materials
  18531. * @param name Define the name in the scene
  18532. * @param scene Define the scene the material belongs to
  18533. */
  18534. constructor(name: string, scene: Scene);
  18535. private _hookArray;
  18536. /**
  18537. * Get one of the submaterial by its index in the submaterials array
  18538. * @param index The index to look the sub material at
  18539. * @returns The Material if the index has been defined
  18540. */
  18541. getSubMaterial(index: number): Nullable<Material>;
  18542. /**
  18543. * Get the list of active textures for the whole sub materials list.
  18544. * @returns All the textures that will be used during the rendering
  18545. */
  18546. getActiveTextures(): BaseTexture[];
  18547. /**
  18548. * Gets the current class name of the material e.g. "MultiMaterial"
  18549. * Mainly use in serialization.
  18550. * @returns the class name
  18551. */
  18552. getClassName(): string;
  18553. /**
  18554. * Checks if the material is ready to render the requested sub mesh
  18555. * @param mesh Define the mesh the submesh belongs to
  18556. * @param subMesh Define the sub mesh to look readyness for
  18557. * @param useInstances Define whether or not the material is used with instances
  18558. * @returns true if ready, otherwise false
  18559. */
  18560. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  18561. /**
  18562. * Clones the current material and its related sub materials
  18563. * @param name Define the name of the newly cloned material
  18564. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  18565. * @returns the cloned material
  18566. */
  18567. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  18568. /**
  18569. * Serializes the materials into a JSON representation.
  18570. * @returns the JSON representation
  18571. */
  18572. serialize(): any;
  18573. /**
  18574. * Dispose the material and release its associated resources
  18575. * @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)
  18576. * @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)
  18577. */
  18578. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  18579. }
  18580. }
  18581. declare module BABYLON {
  18582. /**
  18583. * Base class of materials working in push mode in babylon JS
  18584. * @hidden
  18585. */
  18586. class PushMaterial extends Material {
  18587. protected _activeEffect: Effect;
  18588. protected _normalMatrix: Matrix;
  18589. constructor(name: string, scene: Scene);
  18590. getEffect(): Effect;
  18591. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  18592. /**
  18593. * Binds the given world matrix to the active effect
  18594. *
  18595. * @param world the matrix to bind
  18596. */
  18597. bindOnlyWorldMatrix(world: Matrix): void;
  18598. /**
  18599. * Binds the given normal matrix to the active effect
  18600. *
  18601. * @param normalMatrix the matrix to bind
  18602. */
  18603. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  18604. bind(world: Matrix, mesh?: Mesh): void;
  18605. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  18606. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  18607. }
  18608. }
  18609. declare module BABYLON {
  18610. /**
  18611. * Defines the options associated with the creation of a shader material.
  18612. */
  18613. interface IShaderMaterialOptions {
  18614. /**
  18615. * Does the material work in alpha blend mode
  18616. */
  18617. needAlphaBlending: boolean;
  18618. /**
  18619. * Does the material work in alpha test mode
  18620. */
  18621. needAlphaTesting: boolean;
  18622. /**
  18623. * The list of attribute names used in the shader
  18624. */
  18625. attributes: string[];
  18626. /**
  18627. * The list of unifrom names used in the shader
  18628. */
  18629. uniforms: string[];
  18630. /**
  18631. * The list of UBO names used in the shader
  18632. */
  18633. uniformBuffers: string[];
  18634. /**
  18635. * The list of sampler names used in the shader
  18636. */
  18637. samplers: string[];
  18638. /**
  18639. * The list of defines used in the shader
  18640. */
  18641. defines: string[];
  18642. }
  18643. /**
  18644. * 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.
  18645. *
  18646. * This returned material effects how the mesh will look based on the code in the shaders.
  18647. *
  18648. * @see http://doc.babylonjs.com/how_to/shader_material
  18649. */
  18650. class ShaderMaterial extends Material {
  18651. private _shaderPath;
  18652. private _options;
  18653. private _textures;
  18654. private _textureArrays;
  18655. private _floats;
  18656. private _ints;
  18657. private _floatsArrays;
  18658. private _colors3;
  18659. private _colors3Arrays;
  18660. private _colors4;
  18661. private _vectors2;
  18662. private _vectors3;
  18663. private _vectors4;
  18664. private _matrices;
  18665. private _matrices3x3;
  18666. private _matrices2x2;
  18667. private _vectors2Arrays;
  18668. private _vectors3Arrays;
  18669. private _cachedWorldViewMatrix;
  18670. private _renderId;
  18671. /**
  18672. * Instantiate a new shader material.
  18673. * 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.
  18674. * This returned material effects how the mesh will look based on the code in the shaders.
  18675. * @see http://doc.babylonjs.com/how_to/shader_material
  18676. * @param name Define the name of the material in the scene
  18677. * @param scene Define the scene the material belongs to
  18678. * @param shaderPath Defines the route to the shader code in one of three ways:
  18679. * - object - { vertex: "custom", fragment: "custom" }, used with BABYLON.Effect.ShadersStore["customVertexShader"] and BABYLON.Effect.ShadersStore["customFragmentShader"]
  18680. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  18681. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  18682. * @param options Define the options used to create the shader
  18683. */
  18684. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  18685. /**
  18686. * Gets the current class name of the material e.g. "ShaderMaterial"
  18687. * Mainly use in serialization.
  18688. * @returns the class name
  18689. */
  18690. getClassName(): string;
  18691. /**
  18692. * Specifies if the material will require alpha blending
  18693. * @returns a boolean specifying if alpha blending is needed
  18694. */
  18695. needAlphaBlending(): boolean;
  18696. /**
  18697. * Specifies if this material should be rendered in alpha test mode
  18698. * @returns a boolean specifying if an alpha test is needed.
  18699. */
  18700. needAlphaTesting(): boolean;
  18701. private _checkUniform;
  18702. /**
  18703. * Set a texture in the shader.
  18704. * @param name Define the name of the uniform samplers as defined in the shader
  18705. * @param texture Define the texture to bind to this sampler
  18706. * @return the material itself allowing "fluent" like uniform updates
  18707. */
  18708. setTexture(name: string, texture: Texture): ShaderMaterial;
  18709. /**
  18710. * Set a texture array in the shader.
  18711. * @param name Define the name of the uniform sampler array as defined in the shader
  18712. * @param textures Define the list of textures to bind to this sampler
  18713. * @return the material itself allowing "fluent" like uniform updates
  18714. */
  18715. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  18716. /**
  18717. * Set a float in the shader.
  18718. * @param name Define the name of the uniform as defined in the shader
  18719. * @param value Define the value to give to the uniform
  18720. * @return the material itself allowing "fluent" like uniform updates
  18721. */
  18722. setFloat(name: string, value: number): ShaderMaterial;
  18723. /**
  18724. * Set a int in the shader.
  18725. * @param name Define the name of the uniform as defined in the shader
  18726. * @param value Define the value to give to the uniform
  18727. * @return the material itself allowing "fluent" like uniform updates
  18728. */
  18729. setInt(name: string, value: number): ShaderMaterial;
  18730. /**
  18731. * Set an array of floats in the shader.
  18732. * @param name Define the name of the uniform as defined in the shader
  18733. * @param value Define the value to give to the uniform
  18734. * @return the material itself allowing "fluent" like uniform updates
  18735. */
  18736. setFloats(name: string, value: number[]): ShaderMaterial;
  18737. /**
  18738. * Set a vec3 in the shader from a Color3.
  18739. * @param name Define the name of the uniform as defined in the shader
  18740. * @param value Define the value to give to the uniform
  18741. * @return the material itself allowing "fluent" like uniform updates
  18742. */
  18743. setColor3(name: string, value: Color3): ShaderMaterial;
  18744. /**
  18745. * Set a vec3 array in the shader from a Color3 array.
  18746. * @param name Define the name of the uniform as defined in the shader
  18747. * @param value Define the value to give to the uniform
  18748. * @return the material itself allowing "fluent" like uniform updates
  18749. */
  18750. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  18751. /**
  18752. * Set a vec4 in the shader from a Color4.
  18753. * @param name Define the name of the uniform as defined in the shader
  18754. * @param value Define the value to give to the uniform
  18755. * @return the material itself allowing "fluent" like uniform updates
  18756. */
  18757. setColor4(name: string, value: Color4): ShaderMaterial;
  18758. /**
  18759. * Set a vec2 in the shader from a Vector2.
  18760. * @param name Define the name of the uniform as defined in the shader
  18761. * @param value Define the value to give to the uniform
  18762. * @return the material itself allowing "fluent" like uniform updates
  18763. */
  18764. setVector2(name: string, value: Vector2): ShaderMaterial;
  18765. /**
  18766. * Set a vec3 in the shader from a Vector3.
  18767. * @param name Define the name of the uniform as defined in the shader
  18768. * @param value Define the value to give to the uniform
  18769. * @return the material itself allowing "fluent" like uniform updates
  18770. */
  18771. setVector3(name: string, value: Vector3): ShaderMaterial;
  18772. /**
  18773. * Set a vec4 in the shader from a Vector4.
  18774. * @param name Define the name of the uniform as defined in the shader
  18775. * @param value Define the value to give to the uniform
  18776. * @return the material itself allowing "fluent" like uniform updates
  18777. */
  18778. setVector4(name: string, value: Vector4): ShaderMaterial;
  18779. /**
  18780. * Set a mat4 in the shader from a Matrix.
  18781. * @param name Define the name of the uniform as defined in the shader
  18782. * @param value Define the value to give to the uniform
  18783. * @return the material itself allowing "fluent" like uniform updates
  18784. */
  18785. setMatrix(name: string, value: Matrix): ShaderMaterial;
  18786. /**
  18787. * Set a mat3 in the shader from a Float32Array.
  18788. * @param name Define the name of the uniform as defined in the shader
  18789. * @param value Define the value to give to the uniform
  18790. * @return the material itself allowing "fluent" like uniform updates
  18791. */
  18792. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  18793. /**
  18794. * Set a mat2 in the shader from a Float32Array.
  18795. * @param name Define the name of the uniform as defined in the shader
  18796. * @param value Define the value to give to the uniform
  18797. * @return the material itself allowing "fluent" like uniform updates
  18798. */
  18799. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  18800. /**
  18801. * Set a vec2 array in the shader from a number array.
  18802. * @param name Define the name of the uniform as defined in the shader
  18803. * @param value Define the value to give to the uniform
  18804. * @return the material itself allowing "fluent" like uniform updates
  18805. */
  18806. setArray2(name: string, value: number[]): ShaderMaterial;
  18807. /**
  18808. * Set a vec3 array in the shader from a number array.
  18809. * @param name Define the name of the uniform as defined in the shader
  18810. * @param value Define the value to give to the uniform
  18811. * @return the material itself allowing "fluent" like uniform updates
  18812. */
  18813. setArray3(name: string, value: number[]): ShaderMaterial;
  18814. private _checkCache;
  18815. /**
  18816. * Checks if the material is ready to render the requested mesh
  18817. * @param mesh Define the mesh to render
  18818. * @param useInstances Define whether or not the material is used with instances
  18819. * @returns true if ready, otherwise false
  18820. */
  18821. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  18822. /**
  18823. * Binds the world matrix to the material
  18824. * @param world defines the world transformation matrix
  18825. */
  18826. bindOnlyWorldMatrix(world: Matrix): void;
  18827. /**
  18828. * Binds the material to the mesh
  18829. * @param world defines the world transformation matrix
  18830. * @param mesh defines the mesh to bind the material to
  18831. */
  18832. bind(world: Matrix, mesh?: Mesh): void;
  18833. /**
  18834. * Gets the active textures from the material
  18835. * @returns an array of textures
  18836. */
  18837. getActiveTextures(): BaseTexture[];
  18838. /**
  18839. * Specifies if the material uses a texture
  18840. * @param texture defines the texture to check against the material
  18841. * @returns a boolean specifying if the material uses the texture
  18842. */
  18843. hasTexture(texture: BaseTexture): boolean;
  18844. /**
  18845. * Makes a duplicate of the material, and gives it a new name
  18846. * @param name defines the new name for the duplicated material
  18847. * @returns the cloned material
  18848. */
  18849. clone(name: string): ShaderMaterial;
  18850. /**
  18851. * Disposes the material
  18852. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  18853. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  18854. */
  18855. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  18856. /**
  18857. * Serializes this material in a JSON representation
  18858. * @returns the serialized material object
  18859. */
  18860. serialize(): any;
  18861. /**
  18862. * Creates a shader material from parsed shader material data
  18863. * @param source defines the JSON represnetation of the material
  18864. * @param scene defines the hosting scene
  18865. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18866. * @returns a new material
  18867. */
  18868. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  18869. }
  18870. }
  18871. declare module BABYLON {
  18872. /** @hidden */
  18873. class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  18874. MAINUV1: boolean;
  18875. MAINUV2: boolean;
  18876. DIFFUSE: boolean;
  18877. DIFFUSEDIRECTUV: number;
  18878. AMBIENT: boolean;
  18879. AMBIENTDIRECTUV: number;
  18880. OPACITY: boolean;
  18881. OPACITYDIRECTUV: number;
  18882. OPACITYRGB: boolean;
  18883. REFLECTION: boolean;
  18884. EMISSIVE: boolean;
  18885. EMISSIVEDIRECTUV: number;
  18886. SPECULAR: boolean;
  18887. SPECULARDIRECTUV: number;
  18888. BUMP: boolean;
  18889. BUMPDIRECTUV: number;
  18890. PARALLAX: boolean;
  18891. PARALLAXOCCLUSION: boolean;
  18892. SPECULAROVERALPHA: boolean;
  18893. CLIPPLANE: boolean;
  18894. CLIPPLANE2: boolean;
  18895. CLIPPLANE3: boolean;
  18896. CLIPPLANE4: boolean;
  18897. ALPHATEST: boolean;
  18898. DEPTHPREPASS: boolean;
  18899. ALPHAFROMDIFFUSE: boolean;
  18900. POINTSIZE: boolean;
  18901. FOG: boolean;
  18902. SPECULARTERM: boolean;
  18903. DIFFUSEFRESNEL: boolean;
  18904. OPACITYFRESNEL: boolean;
  18905. REFLECTIONFRESNEL: boolean;
  18906. REFRACTIONFRESNEL: boolean;
  18907. EMISSIVEFRESNEL: boolean;
  18908. FRESNEL: boolean;
  18909. NORMAL: boolean;
  18910. UV1: boolean;
  18911. UV2: boolean;
  18912. VERTEXCOLOR: boolean;
  18913. VERTEXALPHA: boolean;
  18914. NUM_BONE_INFLUENCERS: number;
  18915. BonesPerMesh: number;
  18916. INSTANCES: boolean;
  18917. GLOSSINESS: boolean;
  18918. ROUGHNESS: boolean;
  18919. EMISSIVEASILLUMINATION: boolean;
  18920. LINKEMISSIVEWITHDIFFUSE: boolean;
  18921. REFLECTIONFRESNELFROMSPECULAR: boolean;
  18922. LIGHTMAP: boolean;
  18923. LIGHTMAPDIRECTUV: number;
  18924. OBJECTSPACE_NORMALMAP: boolean;
  18925. USELIGHTMAPASSHADOWMAP: boolean;
  18926. REFLECTIONMAP_3D: boolean;
  18927. REFLECTIONMAP_SPHERICAL: boolean;
  18928. REFLECTIONMAP_PLANAR: boolean;
  18929. REFLECTIONMAP_CUBIC: boolean;
  18930. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  18931. REFLECTIONMAP_PROJECTION: boolean;
  18932. REFLECTIONMAP_SKYBOX: boolean;
  18933. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  18934. REFLECTIONMAP_EXPLICIT: boolean;
  18935. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  18936. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  18937. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  18938. INVERTCUBICMAP: boolean;
  18939. LOGARITHMICDEPTH: boolean;
  18940. REFRACTION: boolean;
  18941. REFRACTIONMAP_3D: boolean;
  18942. REFLECTIONOVERALPHA: boolean;
  18943. TWOSIDEDLIGHTING: boolean;
  18944. SHADOWFLOAT: boolean;
  18945. MORPHTARGETS: boolean;
  18946. MORPHTARGETS_NORMAL: boolean;
  18947. MORPHTARGETS_TANGENT: boolean;
  18948. NUM_MORPH_INFLUENCERS: number;
  18949. NONUNIFORMSCALING: boolean;
  18950. PREMULTIPLYALPHA: boolean;
  18951. IMAGEPROCESSING: boolean;
  18952. VIGNETTE: boolean;
  18953. VIGNETTEBLENDMODEMULTIPLY: boolean;
  18954. VIGNETTEBLENDMODEOPAQUE: boolean;
  18955. TONEMAPPING: boolean;
  18956. TONEMAPPING_ACES: boolean;
  18957. CONTRAST: boolean;
  18958. COLORCURVES: boolean;
  18959. COLORGRADING: boolean;
  18960. COLORGRADING3D: boolean;
  18961. SAMPLER3DGREENDEPTH: boolean;
  18962. SAMPLER3DBGRMAP: boolean;
  18963. IMAGEPROCESSINGPOSTPROCESS: boolean;
  18964. /**
  18965. * If the reflection texture on this material is in linear color space
  18966. * @hidden
  18967. */
  18968. IS_REFLECTION_LINEAR: boolean;
  18969. /**
  18970. * If the refraction texture on this material is in linear color space
  18971. * @hidden
  18972. */
  18973. IS_REFRACTION_LINEAR: boolean;
  18974. EXPOSURE: boolean;
  18975. constructor();
  18976. setReflectionMode(modeToEnable: string): void;
  18977. }
  18978. /**
  18979. * This is the default material used in Babylon. It is the best trade off between quality
  18980. * and performances.
  18981. * @see http://doc.babylonjs.com/babylon101/materials
  18982. */
  18983. class StandardMaterial extends PushMaterial {
  18984. private _diffuseTexture;
  18985. /**
  18986. * The basic texture of the material as viewed under a light.
  18987. */
  18988. diffuseTexture: Nullable<BaseTexture>;
  18989. private _ambientTexture;
  18990. /**
  18991. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  18992. */
  18993. ambientTexture: Nullable<BaseTexture>;
  18994. private _opacityTexture;
  18995. /**
  18996. * Define the transparency of the material from a texture.
  18997. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  18998. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  18999. */
  19000. opacityTexture: Nullable<BaseTexture>;
  19001. private _reflectionTexture;
  19002. /**
  19003. * Define the texture used to display the reflection.
  19004. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19005. */
  19006. reflectionTexture: Nullable<BaseTexture>;
  19007. private _emissiveTexture;
  19008. /**
  19009. * Define texture of the material as if self lit.
  19010. * This will be mixed in the final result even in the absence of light.
  19011. */
  19012. emissiveTexture: Nullable<BaseTexture>;
  19013. private _specularTexture;
  19014. /**
  19015. * Define how the color and intensity of the highlight given by the light in the material.
  19016. */
  19017. specularTexture: Nullable<BaseTexture>;
  19018. private _bumpTexture;
  19019. /**
  19020. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  19021. * 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.
  19022. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  19023. */
  19024. bumpTexture: Nullable<BaseTexture>;
  19025. private _lightmapTexture;
  19026. /**
  19027. * Complex lighting can be computationally expensive to compute at runtime.
  19028. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  19029. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  19030. */
  19031. lightmapTexture: Nullable<BaseTexture>;
  19032. private _refractionTexture;
  19033. /**
  19034. * Define the texture used to display the refraction.
  19035. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19036. */
  19037. refractionTexture: Nullable<BaseTexture>;
  19038. /**
  19039. * The color of the material lit by the environmental background lighting.
  19040. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  19041. */
  19042. ambientColor: Color3;
  19043. /**
  19044. * The basic color of the material as viewed under a light.
  19045. */
  19046. diffuseColor: Color3;
  19047. /**
  19048. * Define how the color and intensity of the highlight given by the light in the material.
  19049. */
  19050. specularColor: Color3;
  19051. /**
  19052. * Define the color of the material as if self lit.
  19053. * This will be mixed in the final result even in the absence of light.
  19054. */
  19055. emissiveColor: Color3;
  19056. /**
  19057. * Defines how sharp are the highlights in the material.
  19058. * The bigger the value the sharper giving a more glossy feeling to the result.
  19059. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  19060. */
  19061. specularPower: number;
  19062. private _useAlphaFromDiffuseTexture;
  19063. /**
  19064. * Does the transparency come from the diffuse texture alpha channel.
  19065. */
  19066. useAlphaFromDiffuseTexture: boolean;
  19067. private _useEmissiveAsIllumination;
  19068. /**
  19069. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  19070. */
  19071. useEmissiveAsIllumination: boolean;
  19072. private _linkEmissiveWithDiffuse;
  19073. /**
  19074. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  19075. * the emissive level when the final color is close to one.
  19076. */
  19077. linkEmissiveWithDiffuse: boolean;
  19078. private _useSpecularOverAlpha;
  19079. /**
  19080. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  19081. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  19082. */
  19083. useSpecularOverAlpha: boolean;
  19084. private _useReflectionOverAlpha;
  19085. /**
  19086. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  19087. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  19088. */
  19089. useReflectionOverAlpha: boolean;
  19090. private _disableLighting;
  19091. /**
  19092. * Does lights from the scene impacts this material.
  19093. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  19094. */
  19095. disableLighting: boolean;
  19096. private _useObjectSpaceNormalMap;
  19097. /**
  19098. * Allows using an object space normal map (instead of tangent space).
  19099. */
  19100. useObjectSpaceNormalMap: boolean;
  19101. private _useParallax;
  19102. /**
  19103. * Is parallax enabled or not.
  19104. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  19105. */
  19106. useParallax: boolean;
  19107. private _useParallaxOcclusion;
  19108. /**
  19109. * Is parallax occlusion enabled or not.
  19110. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  19111. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  19112. */
  19113. useParallaxOcclusion: boolean;
  19114. /**
  19115. * 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.
  19116. */
  19117. parallaxScaleBias: number;
  19118. private _roughness;
  19119. /**
  19120. * Helps to define how blurry the reflections should appears in the material.
  19121. */
  19122. roughness: number;
  19123. /**
  19124. * In case of refraction, define the value of the indice of refraction.
  19125. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19126. */
  19127. indexOfRefraction: number;
  19128. /**
  19129. * Invert the refraction texture alongside the y axis.
  19130. * It can be usefull with procedural textures or probe for instance.
  19131. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19132. */
  19133. invertRefractionY: boolean;
  19134. /**
  19135. * Defines the alpha limits in alpha test mode.
  19136. */
  19137. alphaCutOff: number;
  19138. private _useLightmapAsShadowmap;
  19139. /**
  19140. * In case of light mapping, define whether the map contains light or shadow informations.
  19141. */
  19142. useLightmapAsShadowmap: boolean;
  19143. private _diffuseFresnelParameters;
  19144. /**
  19145. * Define the diffuse fresnel parameters of the material.
  19146. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19147. */
  19148. diffuseFresnelParameters: FresnelParameters;
  19149. private _opacityFresnelParameters;
  19150. /**
  19151. * Define the opacity fresnel parameters of the material.
  19152. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19153. */
  19154. opacityFresnelParameters: FresnelParameters;
  19155. private _reflectionFresnelParameters;
  19156. /**
  19157. * Define the reflection fresnel parameters of the material.
  19158. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19159. */
  19160. reflectionFresnelParameters: FresnelParameters;
  19161. private _refractionFresnelParameters;
  19162. /**
  19163. * Define the refraction fresnel parameters of the material.
  19164. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19165. */
  19166. refractionFresnelParameters: FresnelParameters;
  19167. private _emissiveFresnelParameters;
  19168. /**
  19169. * Define the emissive fresnel parameters of the material.
  19170. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19171. */
  19172. emissiveFresnelParameters: FresnelParameters;
  19173. private _useReflectionFresnelFromSpecular;
  19174. /**
  19175. * If true automatically deducts the fresnels values from the material specularity.
  19176. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19177. */
  19178. useReflectionFresnelFromSpecular: boolean;
  19179. private _useGlossinessFromSpecularMapAlpha;
  19180. /**
  19181. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  19182. */
  19183. useGlossinessFromSpecularMapAlpha: boolean;
  19184. private _maxSimultaneousLights;
  19185. /**
  19186. * Defines the maximum number of lights that can be used in the material
  19187. */
  19188. maxSimultaneousLights: number;
  19189. private _invertNormalMapX;
  19190. /**
  19191. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  19192. */
  19193. invertNormalMapX: boolean;
  19194. private _invertNormalMapY;
  19195. /**
  19196. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  19197. */
  19198. invertNormalMapY: boolean;
  19199. private _twoSidedLighting;
  19200. /**
  19201. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  19202. */
  19203. twoSidedLighting: boolean;
  19204. /**
  19205. * Default configuration related to image processing available in the standard Material.
  19206. */
  19207. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  19208. /**
  19209. * Gets the image processing configuration used either in this material.
  19210. */
  19211. /**
  19212. * Sets the Default image processing configuration used either in the this material.
  19213. *
  19214. * If sets to null, the scene one is in use.
  19215. */
  19216. imageProcessingConfiguration: ImageProcessingConfiguration;
  19217. /**
  19218. * Keep track of the image processing observer to allow dispose and replace.
  19219. */
  19220. private _imageProcessingObserver;
  19221. /**
  19222. * Attaches a new image processing configuration to the Standard Material.
  19223. * @param configuration
  19224. */
  19225. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  19226. /**
  19227. * Gets wether the color curves effect is enabled.
  19228. */
  19229. /**
  19230. * Sets wether the color curves effect is enabled.
  19231. */
  19232. cameraColorCurvesEnabled: boolean;
  19233. /**
  19234. * Gets wether the color grading effect is enabled.
  19235. */
  19236. /**
  19237. * Gets wether the color grading effect is enabled.
  19238. */
  19239. cameraColorGradingEnabled: boolean;
  19240. /**
  19241. * Gets wether tonemapping is enabled or not.
  19242. */
  19243. /**
  19244. * Sets wether tonemapping is enabled or not
  19245. */
  19246. cameraToneMappingEnabled: boolean;
  19247. /**
  19248. * The camera exposure used on this material.
  19249. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  19250. * This corresponds to a photographic exposure.
  19251. */
  19252. /**
  19253. * The camera exposure used on this material.
  19254. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  19255. * This corresponds to a photographic exposure.
  19256. */
  19257. cameraExposure: number;
  19258. /**
  19259. * Gets The camera contrast used on this material.
  19260. */
  19261. /**
  19262. * Sets The camera contrast used on this material.
  19263. */
  19264. cameraContrast: number;
  19265. /**
  19266. * Gets the Color Grading 2D Lookup Texture.
  19267. */
  19268. /**
  19269. * Sets the Color Grading 2D Lookup Texture.
  19270. */
  19271. cameraColorGradingTexture: Nullable<BaseTexture>;
  19272. /**
  19273. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  19274. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  19275. * 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;
  19276. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  19277. */
  19278. /**
  19279. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  19280. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  19281. * 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;
  19282. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  19283. */
  19284. cameraColorCurves: Nullable<ColorCurves>;
  19285. /**
  19286. * Custom callback helping to override the default shader used in the material.
  19287. */
  19288. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  19289. protected _renderTargets: SmartArray<RenderTargetTexture>;
  19290. protected _worldViewProjectionMatrix: Matrix;
  19291. protected _globalAmbientColor: Color3;
  19292. protected _useLogarithmicDepth: boolean;
  19293. /**
  19294. * Instantiates a new standard material.
  19295. * This is the default material used in Babylon. It is the best trade off between quality
  19296. * and performances.
  19297. * @see http://doc.babylonjs.com/babylon101/materials
  19298. * @param name Define the name of the material in the scene
  19299. * @param scene Define the scene the material belong to
  19300. */
  19301. constructor(name: string, scene: Scene);
  19302. /**
  19303. * Gets a boolean indicating that current material needs to register RTT
  19304. */
  19305. readonly hasRenderTargetTextures: boolean;
  19306. /**
  19307. * Gets the current class name of the material e.g. "StandardMaterial"
  19308. * Mainly use in serialization.
  19309. * @returns the class name
  19310. */
  19311. getClassName(): string;
  19312. /**
  19313. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  19314. * You can try switching to logarithmic depth.
  19315. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  19316. */
  19317. useLogarithmicDepth: boolean;
  19318. /**
  19319. * Specifies if the material will require alpha blending
  19320. * @returns a boolean specifying if alpha blending is needed
  19321. */
  19322. needAlphaBlending(): boolean;
  19323. /**
  19324. * Specifies if this material should be rendered in alpha test mode
  19325. * @returns a boolean specifying if an alpha test is needed.
  19326. */
  19327. needAlphaTesting(): boolean;
  19328. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  19329. /**
  19330. * Get the texture used for alpha test purpose.
  19331. * @returns the diffuse texture in case of the standard material.
  19332. */
  19333. getAlphaTestTexture(): Nullable<BaseTexture>;
  19334. /**
  19335. * Get if the submesh is ready to be used and all its information available.
  19336. * Child classes can use it to update shaders
  19337. * @param mesh defines the mesh to check
  19338. * @param subMesh defines which submesh to check
  19339. * @param useInstances specifies that instances should be used
  19340. * @returns a boolean indicating that the submesh is ready or not
  19341. */
  19342. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  19343. /**
  19344. * Builds the material UBO layouts.
  19345. * Used internally during the effect preparation.
  19346. */
  19347. buildUniformLayout(): void;
  19348. /**
  19349. * Unbinds the material from the mesh
  19350. */
  19351. unbind(): void;
  19352. /**
  19353. * Binds the submesh to this material by preparing the effect and shader to draw
  19354. * @param world defines the world transformation matrix
  19355. * @param mesh defines the mesh containing the submesh
  19356. * @param subMesh defines the submesh to bind the material to
  19357. */
  19358. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  19359. /**
  19360. * Get the list of animatables in the material.
  19361. * @returns the list of animatables object used in the material
  19362. */
  19363. getAnimatables(): IAnimatable[];
  19364. /**
  19365. * Gets the active textures from the material
  19366. * @returns an array of textures
  19367. */
  19368. getActiveTextures(): BaseTexture[];
  19369. /**
  19370. * Specifies if the material uses a texture
  19371. * @param texture defines the texture to check against the material
  19372. * @returns a boolean specifying if the material uses the texture
  19373. */
  19374. hasTexture(texture: BaseTexture): boolean;
  19375. /**
  19376. * Disposes the material
  19377. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19378. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19379. */
  19380. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  19381. /**
  19382. * Makes a duplicate of the material, and gives it a new name
  19383. * @param name defines the new name for the duplicated material
  19384. * @returns the cloned material
  19385. */
  19386. clone(name: string): StandardMaterial;
  19387. /**
  19388. * Serializes this material in a JSON representation
  19389. * @returns the serialized material object
  19390. */
  19391. serialize(): any;
  19392. /**
  19393. * Creates a standard material from parsed material data
  19394. * @param source defines the JSON represnetation of the material
  19395. * @param scene defines the hosting scene
  19396. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19397. * @returns a new material
  19398. */
  19399. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  19400. private static _DiffuseTextureEnabled;
  19401. /**
  19402. * Are diffuse textures enabled in the application.
  19403. */
  19404. static DiffuseTextureEnabled: boolean;
  19405. private static _AmbientTextureEnabled;
  19406. /**
  19407. * Are ambient textures enabled in the application.
  19408. */
  19409. static AmbientTextureEnabled: boolean;
  19410. private static _OpacityTextureEnabled;
  19411. /**
  19412. * Are opacity textures enabled in the application.
  19413. */
  19414. static OpacityTextureEnabled: boolean;
  19415. private static _ReflectionTextureEnabled;
  19416. /**
  19417. * Are reflection textures enabled in the application.
  19418. */
  19419. static ReflectionTextureEnabled: boolean;
  19420. private static _EmissiveTextureEnabled;
  19421. /**
  19422. * Are emissive textures enabled in the application.
  19423. */
  19424. static EmissiveTextureEnabled: boolean;
  19425. private static _SpecularTextureEnabled;
  19426. /**
  19427. * Are specular textures enabled in the application.
  19428. */
  19429. static SpecularTextureEnabled: boolean;
  19430. private static _BumpTextureEnabled;
  19431. /**
  19432. * Are bump textures enabled in the application.
  19433. */
  19434. static BumpTextureEnabled: boolean;
  19435. private static _LightmapTextureEnabled;
  19436. /**
  19437. * Are lightmap textures enabled in the application.
  19438. */
  19439. static LightmapTextureEnabled: boolean;
  19440. private static _RefractionTextureEnabled;
  19441. /**
  19442. * Are refraction textures enabled in the application.
  19443. */
  19444. static RefractionTextureEnabled: boolean;
  19445. private static _ColorGradingTextureEnabled;
  19446. /**
  19447. * Are color grading textures enabled in the application.
  19448. */
  19449. static ColorGradingTextureEnabled: boolean;
  19450. private static _FresnelEnabled;
  19451. /**
  19452. * Are fresnels enabled in the application.
  19453. */
  19454. static FresnelEnabled: boolean;
  19455. }
  19456. }
  19457. declare module BABYLON {
  19458. /**
  19459. * Uniform buffer objects.
  19460. *
  19461. * Handles blocks of uniform on the GPU.
  19462. *
  19463. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  19464. *
  19465. * For more information, please refer to :
  19466. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  19467. */
  19468. class UniformBuffer {
  19469. private _engine;
  19470. private _buffer;
  19471. private _data;
  19472. private _bufferData;
  19473. private _dynamic?;
  19474. private _uniformLocations;
  19475. private _uniformSizes;
  19476. private _uniformLocationPointer;
  19477. private _needSync;
  19478. private _noUBO;
  19479. private _currentEffect;
  19480. private static _MAX_UNIFORM_SIZE;
  19481. private static _tempBuffer;
  19482. /**
  19483. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  19484. * This is dynamic to allow compat with webgl 1 and 2.
  19485. * You will need to pass the name of the uniform as well as the value.
  19486. */
  19487. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  19488. /**
  19489. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  19490. * This is dynamic to allow compat with webgl 1 and 2.
  19491. * You will need to pass the name of the uniform as well as the value.
  19492. */
  19493. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  19494. /**
  19495. * Lambda to Update a single float in a uniform buffer.
  19496. * This is dynamic to allow compat with webgl 1 and 2.
  19497. * You will need to pass the name of the uniform as well as the value.
  19498. */
  19499. updateFloat: (name: string, x: number) => void;
  19500. /**
  19501. * Lambda to Update a vec2 of float in a uniform buffer.
  19502. * This is dynamic to allow compat with webgl 1 and 2.
  19503. * You will need to pass the name of the uniform as well as the value.
  19504. */
  19505. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  19506. /**
  19507. * Lambda to Update a vec3 of float in a uniform buffer.
  19508. * This is dynamic to allow compat with webgl 1 and 2.
  19509. * You will need to pass the name of the uniform as well as the value.
  19510. */
  19511. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  19512. /**
  19513. * Lambda to Update a vec4 of float in a uniform buffer.
  19514. * This is dynamic to allow compat with webgl 1 and 2.
  19515. * You will need to pass the name of the uniform as well as the value.
  19516. */
  19517. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  19518. /**
  19519. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  19520. * This is dynamic to allow compat with webgl 1 and 2.
  19521. * You will need to pass the name of the uniform as well as the value.
  19522. */
  19523. updateMatrix: (name: string, mat: Matrix) => void;
  19524. /**
  19525. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  19526. * This is dynamic to allow compat with webgl 1 and 2.
  19527. * You will need to pass the name of the uniform as well as the value.
  19528. */
  19529. updateVector3: (name: string, vector: Vector3) => void;
  19530. /**
  19531. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  19532. * This is dynamic to allow compat with webgl 1 and 2.
  19533. * You will need to pass the name of the uniform as well as the value.
  19534. */
  19535. updateVector4: (name: string, vector: Vector4) => void;
  19536. /**
  19537. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  19538. * This is dynamic to allow compat with webgl 1 and 2.
  19539. * You will need to pass the name of the uniform as well as the value.
  19540. */
  19541. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  19542. /**
  19543. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  19544. * This is dynamic to allow compat with webgl 1 and 2.
  19545. * You will need to pass the name of the uniform as well as the value.
  19546. */
  19547. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  19548. /**
  19549. * Instantiates a new Uniform buffer objects.
  19550. *
  19551. * Handles blocks of uniform on the GPU.
  19552. *
  19553. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  19554. *
  19555. * For more information, please refer to :
  19556. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  19557. * @param engine Define the engine the buffer is associated with
  19558. * @param data Define the data contained in the buffer
  19559. * @param dynamic Define if the buffer is updatable
  19560. */
  19561. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  19562. /**
  19563. * Indicates if the buffer is using the WebGL2 UBO implementation,
  19564. * or just falling back on setUniformXXX calls.
  19565. */
  19566. readonly useUbo: boolean;
  19567. /**
  19568. * Indicates if the WebGL underlying uniform buffer is in sync
  19569. * with the javascript cache data.
  19570. */
  19571. readonly isSync: boolean;
  19572. /**
  19573. * Indicates if the WebGL underlying uniform buffer is dynamic.
  19574. * Also, a dynamic UniformBuffer will disable cache verification and always
  19575. * update the underlying WebGL uniform buffer to the GPU.
  19576. * @returns if Dynamic, otherwise false
  19577. */
  19578. isDynamic(): boolean;
  19579. /**
  19580. * The data cache on JS side.
  19581. * @returns the underlying data as a float array
  19582. */
  19583. getData(): Float32Array;
  19584. /**
  19585. * The underlying WebGL Uniform buffer.
  19586. * @returns the webgl buffer
  19587. */
  19588. getBuffer(): Nullable<WebGLBuffer>;
  19589. /**
  19590. * std140 layout specifies how to align data within an UBO structure.
  19591. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  19592. * for specs.
  19593. */
  19594. private _fillAlignment;
  19595. /**
  19596. * Adds an uniform in the buffer.
  19597. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  19598. * for the layout to be correct !
  19599. * @param name Name of the uniform, as used in the uniform block in the shader.
  19600. * @param size Data size, or data directly.
  19601. */
  19602. addUniform(name: string, size: number | number[]): void;
  19603. /**
  19604. * Adds a Matrix 4x4 to the uniform buffer.
  19605. * @param name Name of the uniform, as used in the uniform block in the shader.
  19606. * @param mat A 4x4 matrix.
  19607. */
  19608. addMatrix(name: string, mat: Matrix): void;
  19609. /**
  19610. * Adds a vec2 to the uniform buffer.
  19611. * @param name Name of the uniform, as used in the uniform block in the shader.
  19612. * @param x Define the x component value of the vec2
  19613. * @param y Define the y component value of the vec2
  19614. */
  19615. addFloat2(name: string, x: number, y: number): void;
  19616. /**
  19617. * Adds a vec3 to the uniform buffer.
  19618. * @param name Name of the uniform, as used in the uniform block in the shader.
  19619. * @param x Define the x component value of the vec3
  19620. * @param y Define the y component value of the vec3
  19621. * @param z Define the z component value of the vec3
  19622. */
  19623. addFloat3(name: string, x: number, y: number, z: number): void;
  19624. /**
  19625. * Adds a vec3 to the uniform buffer.
  19626. * @param name Name of the uniform, as used in the uniform block in the shader.
  19627. * @param color Define the vec3 from a Color
  19628. */
  19629. addColor3(name: string, color: Color3): void;
  19630. /**
  19631. * Adds a vec4 to the uniform buffer.
  19632. * @param name Name of the uniform, as used in the uniform block in the shader.
  19633. * @param color Define the rgb components from a Color
  19634. * @param alpha Define the a component of the vec4
  19635. */
  19636. addColor4(name: string, color: Color3, alpha: number): void;
  19637. /**
  19638. * Adds a vec3 to the uniform buffer.
  19639. * @param name Name of the uniform, as used in the uniform block in the shader.
  19640. * @param vector Define the vec3 components from a Vector
  19641. */
  19642. addVector3(name: string, vector: Vector3): void;
  19643. /**
  19644. * Adds a Matrix 3x3 to the uniform buffer.
  19645. * @param name Name of the uniform, as used in the uniform block in the shader.
  19646. */
  19647. addMatrix3x3(name: string): void;
  19648. /**
  19649. * Adds a Matrix 2x2 to the uniform buffer.
  19650. * @param name Name of the uniform, as used in the uniform block in the shader.
  19651. */
  19652. addMatrix2x2(name: string): void;
  19653. /**
  19654. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  19655. */
  19656. create(): void;
  19657. /** @hidden */
  19658. _rebuild(): void;
  19659. /**
  19660. * Updates the WebGL Uniform Buffer on the GPU.
  19661. * If the `dynamic` flag is set to true, no cache comparison is done.
  19662. * Otherwise, the buffer will be updated only if the cache differs.
  19663. */
  19664. update(): void;
  19665. /**
  19666. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  19667. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  19668. * @param data Define the flattened data
  19669. * @param size Define the size of the data.
  19670. */
  19671. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  19672. private _updateMatrix3x3ForUniform;
  19673. private _updateMatrix3x3ForEffect;
  19674. private _updateMatrix2x2ForEffect;
  19675. private _updateMatrix2x2ForUniform;
  19676. private _updateFloatForEffect;
  19677. private _updateFloatForUniform;
  19678. private _updateFloat2ForEffect;
  19679. private _updateFloat2ForUniform;
  19680. private _updateFloat3ForEffect;
  19681. private _updateFloat3ForUniform;
  19682. private _updateFloat4ForEffect;
  19683. private _updateFloat4ForUniform;
  19684. private _updateMatrixForEffect;
  19685. private _updateMatrixForUniform;
  19686. private _updateVector3ForEffect;
  19687. private _updateVector3ForUniform;
  19688. private _updateVector4ForEffect;
  19689. private _updateVector4ForUniform;
  19690. private _updateColor3ForEffect;
  19691. private _updateColor3ForUniform;
  19692. private _updateColor4ForEffect;
  19693. private _updateColor4ForUniform;
  19694. /**
  19695. * Sets a sampler uniform on the effect.
  19696. * @param name Define the name of the sampler.
  19697. * @param texture Define the texture to set in the sampler
  19698. */
  19699. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  19700. /**
  19701. * Directly updates the value of the uniform in the cache AND on the GPU.
  19702. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  19703. * @param data Define the flattened data
  19704. */
  19705. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  19706. /**
  19707. * Binds this uniform buffer to an effect.
  19708. * @param effect Define the effect to bind the buffer to
  19709. * @param name Name of the uniform block in the shader.
  19710. */
  19711. bindToEffect(effect: Effect, name: string): void;
  19712. /**
  19713. * Disposes the uniform buffer.
  19714. */
  19715. dispose(): void;
  19716. }
  19717. }
  19718. declare module BABYLON {
  19719. /**
  19720. * Scalar computation library
  19721. */
  19722. class Scalar {
  19723. /**
  19724. * Two pi constants convenient for computation.
  19725. */
  19726. static TwoPi: number;
  19727. /**
  19728. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  19729. * @param a number
  19730. * @param b number
  19731. * @param epsilon (default = 1.401298E-45)
  19732. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  19733. */
  19734. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  19735. /**
  19736. * Returns a string : the upper case translation of the number i to hexadecimal.
  19737. * @param i number
  19738. * @returns the upper case translation of the number i to hexadecimal.
  19739. */
  19740. static ToHex(i: number): string;
  19741. /**
  19742. * Returns -1 if value is negative and +1 is value is positive.
  19743. * @param value the value
  19744. * @returns the value itself if it's equal to zero.
  19745. */
  19746. static Sign(value: number): number;
  19747. /**
  19748. * Returns the value itself if it's between min and max.
  19749. * Returns min if the value is lower than min.
  19750. * Returns max if the value is greater than max.
  19751. * @param value the value to clmap
  19752. * @param min the min value to clamp to (default: 0)
  19753. * @param max the max value to clamp to (default: 1)
  19754. * @returns the clamped value
  19755. */
  19756. static Clamp(value: number, min?: number, max?: number): number;
  19757. /**
  19758. * the log2 of value.
  19759. * @param value the value to compute log2 of
  19760. * @returns the log2 of value.
  19761. */
  19762. static Log2(value: number): number;
  19763. /**
  19764. * Loops the value, so that it is never larger than length and never smaller than 0.
  19765. *
  19766. * This is similar to the modulo operator but it works with floating point numbers.
  19767. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  19768. * With t = 5 and length = 2.5, the result would be 0.0.
  19769. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  19770. * @param value the value
  19771. * @param length the length
  19772. * @returns the looped value
  19773. */
  19774. static Repeat(value: number, length: number): number;
  19775. /**
  19776. * Normalize the value between 0.0 and 1.0 using min and max values
  19777. * @param value value to normalize
  19778. * @param min max to normalize between
  19779. * @param max min to normalize between
  19780. * @returns the normalized value
  19781. */
  19782. static Normalize(value: number, min: number, max: number): number;
  19783. /**
  19784. * Denormalize the value from 0.0 and 1.0 using min and max values
  19785. * @param normalized value to denormalize
  19786. * @param min max to denormalize between
  19787. * @param max min to denormalize between
  19788. * @returns the denormalized value
  19789. */
  19790. static Denormalize(normalized: number, min: number, max: number): number;
  19791. /**
  19792. * Calculates the shortest difference between two given angles given in degrees.
  19793. * @param current current angle in degrees
  19794. * @param target target angle in degrees
  19795. * @returns the delta
  19796. */
  19797. static DeltaAngle(current: number, target: number): number;
  19798. /**
  19799. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  19800. * @param tx value
  19801. * @param length length
  19802. * @returns The returned value will move back and forth between 0 and length
  19803. */
  19804. static PingPong(tx: number, length: number): number;
  19805. /**
  19806. * Interpolates between min and max with smoothing at the limits.
  19807. *
  19808. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  19809. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  19810. * @param from from
  19811. * @param to to
  19812. * @param tx value
  19813. * @returns the smooth stepped value
  19814. */
  19815. static SmoothStep(from: number, to: number, tx: number): number;
  19816. /**
  19817. * Moves a value current towards target.
  19818. *
  19819. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  19820. * Negative values of maxDelta pushes the value away from target.
  19821. * @param current current value
  19822. * @param target target value
  19823. * @param maxDelta max distance to move
  19824. * @returns resulting value
  19825. */
  19826. static MoveTowards(current: number, target: number, maxDelta: number): number;
  19827. /**
  19828. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  19829. *
  19830. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  19831. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  19832. * @param current current value
  19833. * @param target target value
  19834. * @param maxDelta max distance to move
  19835. * @returns resulting angle
  19836. */
  19837. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  19838. /**
  19839. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  19840. * @param start start value
  19841. * @param end target value
  19842. * @param amount amount to lerp between
  19843. * @returns the lerped value
  19844. */
  19845. static Lerp(start: number, end: number, amount: number): number;
  19846. /**
  19847. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  19848. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  19849. * @param start start value
  19850. * @param end target value
  19851. * @param amount amount to lerp between
  19852. * @returns the lerped value
  19853. */
  19854. static LerpAngle(start: number, end: number, amount: number): number;
  19855. /**
  19856. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  19857. * @param a start value
  19858. * @param b target value
  19859. * @param value value between a and b
  19860. * @returns the inverseLerp value
  19861. */
  19862. static InverseLerp(a: number, b: number, value: number): number;
  19863. /**
  19864. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  19865. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  19866. * @param value1 spline value
  19867. * @param tangent1 spline value
  19868. * @param value2 spline value
  19869. * @param tangent2 spline value
  19870. * @param amount input value
  19871. * @returns hermite result
  19872. */
  19873. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  19874. /**
  19875. * Returns a random float number between and min and max values
  19876. * @param min min value of random
  19877. * @param max max value of random
  19878. * @returns random value
  19879. */
  19880. static RandomRange(min: number, max: number): number;
  19881. /**
  19882. * This function returns percentage of a number in a given range.
  19883. *
  19884. * RangeToPercent(40,20,60) will return 0.5 (50%)
  19885. * RangeToPercent(34,0,100) will return 0.34 (34%)
  19886. * @param number to convert to percentage
  19887. * @param min min range
  19888. * @param max max range
  19889. * @returns the percentage
  19890. */
  19891. static RangeToPercent(number: number, min: number, max: number): number;
  19892. /**
  19893. * This function returns number that corresponds to the percentage in a given range.
  19894. *
  19895. * PercentToRange(0.34,0,100) will return 34.
  19896. * @param percent to convert to number
  19897. * @param min min range
  19898. * @param max max range
  19899. * @returns the number
  19900. */
  19901. static PercentToRange(percent: number, min: number, max: number): number;
  19902. /**
  19903. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  19904. * @param angle The angle to normalize in radian.
  19905. * @return The converted angle.
  19906. */
  19907. static NormalizeRadians(angle: number): number;
  19908. }
  19909. }
  19910. declare module BABYLON {
  19911. /**
  19912. * Constant used to convert a value to gamma space
  19913. * @ignorenaming
  19914. */
  19915. const ToGammaSpace: number;
  19916. /**
  19917. * Constant used to convert a value to linear space
  19918. * @ignorenaming
  19919. */
  19920. const ToLinearSpace = 2.2;
  19921. /**
  19922. * Constant used to define the minimal number value in Babylon.js
  19923. * @ignorenaming
  19924. */
  19925. const Epsilon = 0.001;
  19926. /**
  19927. * Class used to hold a RBG color
  19928. */
  19929. class Color3 {
  19930. /**
  19931. * Defines the red component (between 0 and 1, default is 0)
  19932. */
  19933. r: number;
  19934. /**
  19935. * Defines the green component (between 0 and 1, default is 0)
  19936. */
  19937. g: number;
  19938. /**
  19939. * Defines the blue component (between 0 and 1, default is 0)
  19940. */
  19941. b: number;
  19942. /**
  19943. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  19944. * @param r defines the red component (between 0 and 1, default is 0)
  19945. * @param g defines the green component (between 0 and 1, default is 0)
  19946. * @param b defines the blue component (between 0 and 1, default is 0)
  19947. */
  19948. constructor(
  19949. /**
  19950. * Defines the red component (between 0 and 1, default is 0)
  19951. */
  19952. r?: number,
  19953. /**
  19954. * Defines the green component (between 0 and 1, default is 0)
  19955. */
  19956. g?: number,
  19957. /**
  19958. * Defines the blue component (between 0 and 1, default is 0)
  19959. */
  19960. b?: number);
  19961. /**
  19962. * Creates a string with the Color3 current values
  19963. * @returns the string representation of the Color3 object
  19964. */
  19965. toString(): string;
  19966. /**
  19967. * Returns the string "Color3"
  19968. * @returns "Color3"
  19969. */
  19970. getClassName(): string;
  19971. /**
  19972. * Compute the Color3 hash code
  19973. * @returns an unique number that can be used to hash Color3 objects
  19974. */
  19975. getHashCode(): number;
  19976. /**
  19977. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  19978. * @param array defines the array where to store the r,g,b components
  19979. * @param index defines an optional index in the target array to define where to start storing values
  19980. * @returns the current Color3 object
  19981. */
  19982. toArray(array: FloatArray, index?: number): Color3;
  19983. /**
  19984. * Returns a new Color4 object from the current Color3 and the given alpha
  19985. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  19986. * @returns a new Color4 object
  19987. */
  19988. toColor4(alpha?: number): Color4;
  19989. /**
  19990. * Returns a new array populated with 3 numeric elements : red, green and blue values
  19991. * @returns the new array
  19992. */
  19993. asArray(): number[];
  19994. /**
  19995. * Returns the luminance value
  19996. * @returns a float value
  19997. */
  19998. toLuminance(): number;
  19999. /**
  20000. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  20001. * @param otherColor defines the second operand
  20002. * @returns the new Color3 object
  20003. */
  20004. multiply(otherColor: Color3): Color3;
  20005. /**
  20006. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  20007. * @param otherColor defines the second operand
  20008. * @param result defines the Color3 object where to store the result
  20009. * @returns the current Color3
  20010. */
  20011. multiplyToRef(otherColor: Color3, result: Color3): Color3;
  20012. /**
  20013. * Determines equality between Color3 objects
  20014. * @param otherColor defines the second operand
  20015. * @returns true if the rgb values are equal to the given ones
  20016. */
  20017. equals(otherColor: Color3): boolean;
  20018. /**
  20019. * Determines equality between the current Color3 object and a set of r,b,g values
  20020. * @param r defines the red component to check
  20021. * @param g defines the green component to check
  20022. * @param b defines the blue component to check
  20023. * @returns true if the rgb values are equal to the given ones
  20024. */
  20025. equalsFloats(r: number, g: number, b: number): boolean;
  20026. /**
  20027. * Multiplies in place each rgb value by scale
  20028. * @param scale defines the scaling factor
  20029. * @returns the updated Color3
  20030. */
  20031. scale(scale: number): Color3;
  20032. /**
  20033. * Multiplies the rgb values by scale and stores the result into "result"
  20034. * @param scale defines the scaling factor
  20035. * @param result defines the Color3 object where to store the result
  20036. * @returns the unmodified current Color3
  20037. */
  20038. scaleToRef(scale: number, result: Color3): Color3;
  20039. /**
  20040. * Scale the current Color3 values by a factor and add the result to a given Color3
  20041. * @param scale defines the scale factor
  20042. * @param result defines color to store the result into
  20043. * @returns the unmodified current Color3
  20044. */
  20045. scaleAndAddToRef(scale: number, result: Color3): Color3;
  20046. /**
  20047. * Clamps the rgb values by the min and max values and stores the result into "result"
  20048. * @param min defines minimum clamping value (default is 0)
  20049. * @param max defines maximum clamping value (default is 1)
  20050. * @param result defines color to store the result into
  20051. * @returns the original Color3
  20052. */
  20053. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  20054. /**
  20055. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  20056. * @param otherColor defines the second operand
  20057. * @returns the new Color3
  20058. */
  20059. add(otherColor: Color3): Color3;
  20060. /**
  20061. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  20062. * @param otherColor defines the second operand
  20063. * @param result defines Color3 object to store the result into
  20064. * @returns the unmodified current Color3
  20065. */
  20066. addToRef(otherColor: Color3, result: Color3): Color3;
  20067. /**
  20068. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  20069. * @param otherColor defines the second operand
  20070. * @returns the new Color3
  20071. */
  20072. subtract(otherColor: Color3): Color3;
  20073. /**
  20074. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  20075. * @param otherColor defines the second operand
  20076. * @param result defines Color3 object to store the result into
  20077. * @returns the unmodified current Color3
  20078. */
  20079. subtractToRef(otherColor: Color3, result: Color3): Color3;
  20080. /**
  20081. * Copy the current object
  20082. * @returns a new Color3 copied the current one
  20083. */
  20084. clone(): Color3;
  20085. /**
  20086. * Copies the rgb values from the source in the current Color3
  20087. * @param source defines the source Color3 object
  20088. * @returns the updated Color3 object
  20089. */
  20090. copyFrom(source: Color3): Color3;
  20091. /**
  20092. * Updates the Color3 rgb values from the given floats
  20093. * @param r defines the red component to read from
  20094. * @param g defines the green component to read from
  20095. * @param b defines the blue component to read from
  20096. * @returns the current Color3 object
  20097. */
  20098. copyFromFloats(r: number, g: number, b: number): Color3;
  20099. /**
  20100. * Updates the Color3 rgb values from the given floats
  20101. * @param r defines the red component to read from
  20102. * @param g defines the green component to read from
  20103. * @param b defines the blue component to read from
  20104. * @returns the current Color3 object
  20105. */
  20106. set(r: number, g: number, b: number): Color3;
  20107. /**
  20108. * Compute the Color3 hexadecimal code as a string
  20109. * @returns a string containing the hexadecimal representation of the Color3 object
  20110. */
  20111. toHexString(): string;
  20112. /**
  20113. * Computes a new Color3 converted from the current one to linear space
  20114. * @returns a new Color3 object
  20115. */
  20116. toLinearSpace(): Color3;
  20117. /**
  20118. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  20119. * @param convertedColor defines the Color3 object where to store the linear space version
  20120. * @returns the unmodified Color3
  20121. */
  20122. toLinearSpaceToRef(convertedColor: Color3): Color3;
  20123. /**
  20124. * Computes a new Color3 converted from the current one to gamma space
  20125. * @returns a new Color3 object
  20126. */
  20127. toGammaSpace(): Color3;
  20128. /**
  20129. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  20130. * @param convertedColor defines the Color3 object where to store the gamma space version
  20131. * @returns the unmodified Color3
  20132. */
  20133. toGammaSpaceToRef(convertedColor: Color3): Color3;
  20134. /**
  20135. * Creates a new Color3 from the string containing valid hexadecimal values
  20136. * @param hex defines a string containing valid hexadecimal values
  20137. * @returns a new Color3 object
  20138. */
  20139. static FromHexString(hex: string): Color3;
  20140. /**
  20141. * Creates a new Vector3 from the starting index of the given array
  20142. * @param array defines the source array
  20143. * @param offset defines an offset in the source array
  20144. * @returns a new Color3 object
  20145. */
  20146. static FromArray(array: ArrayLike<number>, offset?: number): Color3;
  20147. /**
  20148. * Creates a new Color3 from integer values (< 256)
  20149. * @param r defines the red component to read from (value between 0 and 255)
  20150. * @param g defines the green component to read from (value between 0 and 255)
  20151. * @param b defines the blue component to read from (value between 0 and 255)
  20152. * @returns a new Color3 object
  20153. */
  20154. static FromInts(r: number, g: number, b: number): Color3;
  20155. /**
  20156. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  20157. * @param start defines the start Color3 value
  20158. * @param end defines the end Color3 value
  20159. * @param amount defines the gradient value between start and end
  20160. * @returns a new Color3 object
  20161. */
  20162. static Lerp(start: Color3, end: Color3, amount: number): Color3;
  20163. /**
  20164. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  20165. * @param left defines the start value
  20166. * @param right defines the end value
  20167. * @param amount defines the gradient factor
  20168. * @param result defines the Color3 object where to store the result
  20169. */
  20170. static LerpToRef(left: Color3, right: Color3, amount: number, result: Color3): void;
  20171. /**
  20172. * Returns a Color3 value containing a red color
  20173. * @returns a new Color3 object
  20174. */
  20175. static Red(): Color3;
  20176. /**
  20177. * Returns a Color3 value containing a green color
  20178. * @returns a new Color3 object
  20179. */
  20180. static Green(): Color3;
  20181. /**
  20182. * Returns a Color3 value containing a blue color
  20183. * @returns a new Color3 object
  20184. */
  20185. static Blue(): Color3;
  20186. /**
  20187. * Returns a Color3 value containing a black color
  20188. * @returns a new Color3 object
  20189. */
  20190. static Black(): Color3;
  20191. /**
  20192. * Returns a Color3 value containing a white color
  20193. * @returns a new Color3 object
  20194. */
  20195. static White(): Color3;
  20196. /**
  20197. * Returns a Color3 value containing a purple color
  20198. * @returns a new Color3 object
  20199. */
  20200. static Purple(): Color3;
  20201. /**
  20202. * Returns a Color3 value containing a magenta color
  20203. * @returns a new Color3 object
  20204. */
  20205. static Magenta(): Color3;
  20206. /**
  20207. * Returns a Color3 value containing a yellow color
  20208. * @returns a new Color3 object
  20209. */
  20210. static Yellow(): Color3;
  20211. /**
  20212. * Returns a Color3 value containing a gray color
  20213. * @returns a new Color3 object
  20214. */
  20215. static Gray(): Color3;
  20216. /**
  20217. * Returns a Color3 value containing a teal color
  20218. * @returns a new Color3 object
  20219. */
  20220. static Teal(): Color3;
  20221. /**
  20222. * Returns a Color3 value containing a random color
  20223. * @returns a new Color3 object
  20224. */
  20225. static Random(): Color3;
  20226. }
  20227. /**
  20228. * Class used to hold a RBGA color
  20229. */
  20230. class Color4 {
  20231. /**
  20232. * Defines the red component (between 0 and 1, default is 0)
  20233. */
  20234. r: number;
  20235. /**
  20236. * Defines the green component (between 0 and 1, default is 0)
  20237. */
  20238. g: number;
  20239. /**
  20240. * Defines the blue component (between 0 and 1, default is 0)
  20241. */
  20242. b: number;
  20243. /**
  20244. * Defines the alpha component (between 0 and 1, default is 1)
  20245. */
  20246. a: number;
  20247. /**
  20248. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  20249. * @param r defines the red component (between 0 and 1, default is 0)
  20250. * @param g defines the green component (between 0 and 1, default is 0)
  20251. * @param b defines the blue component (between 0 and 1, default is 0)
  20252. * @param a defines the alpha component (between 0 and 1, default is 1)
  20253. */
  20254. constructor(
  20255. /**
  20256. * Defines the red component (between 0 and 1, default is 0)
  20257. */
  20258. r?: number,
  20259. /**
  20260. * Defines the green component (between 0 and 1, default is 0)
  20261. */
  20262. g?: number,
  20263. /**
  20264. * Defines the blue component (between 0 and 1, default is 0)
  20265. */
  20266. b?: number,
  20267. /**
  20268. * Defines the alpha component (between 0 and 1, default is 1)
  20269. */
  20270. a?: number);
  20271. /**
  20272. * Adds in place the given Color4 values to the current Color4 object
  20273. * @param right defines the second operand
  20274. * @returns the current updated Color4 object
  20275. */
  20276. addInPlace(right: Color4): Color4;
  20277. /**
  20278. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  20279. * @returns the new array
  20280. */
  20281. asArray(): number[];
  20282. /**
  20283. * Stores from the starting index in the given array the Color4 successive values
  20284. * @param array defines the array where to store the r,g,b components
  20285. * @param index defines an optional index in the target array to define where to start storing values
  20286. * @returns the current Color4 object
  20287. */
  20288. toArray(array: number[], index?: number): Color4;
  20289. /**
  20290. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  20291. * @param right defines the second operand
  20292. * @returns a new Color4 object
  20293. */
  20294. add(right: Color4): Color4;
  20295. /**
  20296. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  20297. * @param right defines the second operand
  20298. * @returns a new Color4 object
  20299. */
  20300. subtract(right: Color4): Color4;
  20301. /**
  20302. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  20303. * @param right defines the second operand
  20304. * @param result defines the Color4 object where to store the result
  20305. * @returns the current Color4 object
  20306. */
  20307. subtractToRef(right: Color4, result: Color4): Color4;
  20308. /**
  20309. * Creates a new Color4 with the current Color4 values multiplied by scale
  20310. * @param scale defines the scaling factor to apply
  20311. * @returns a new Color4 object
  20312. */
  20313. scale(scale: number): Color4;
  20314. /**
  20315. * Multiplies the current Color4 values by scale and stores the result in "result"
  20316. * @param scale defines the scaling factor to apply
  20317. * @param result defines the Color4 object where to store the result
  20318. * @returns the current unmodified Color4
  20319. */
  20320. scaleToRef(scale: number, result: Color4): Color4;
  20321. /**
  20322. * Scale the current Color4 values by a factor and add the result to a given Color4
  20323. * @param scale defines the scale factor
  20324. * @param result defines the Color4 object where to store the result
  20325. * @returns the unmodified current Color4
  20326. */
  20327. scaleAndAddToRef(scale: number, result: Color4): Color4;
  20328. /**
  20329. * Clamps the rgb values by the min and max values and stores the result into "result"
  20330. * @param min defines minimum clamping value (default is 0)
  20331. * @param max defines maximum clamping value (default is 1)
  20332. * @param result defines color to store the result into.
  20333. * @returns the cuurent Color4
  20334. */
  20335. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  20336. /**
  20337. * Multipy an Color4 value by another and return a new Color4 object
  20338. * @param color defines the Color4 value to multiply by
  20339. * @returns a new Color4 object
  20340. */
  20341. multiply(color: Color4): Color4;
  20342. /**
  20343. * Multipy a Color4 value by another and push the result in a reference value
  20344. * @param color defines the Color4 value to multiply by
  20345. * @param result defines the Color4 to fill the result in
  20346. * @returns the result Color4
  20347. */
  20348. multiplyToRef(color: Color4, result: Color4): Color4;
  20349. /**
  20350. * Creates a string with the Color4 current values
  20351. * @returns the string representation of the Color4 object
  20352. */
  20353. toString(): string;
  20354. /**
  20355. * Returns the string "Color4"
  20356. * @returns "Color4"
  20357. */
  20358. getClassName(): string;
  20359. /**
  20360. * Compute the Color4 hash code
  20361. * @returns an unique number that can be used to hash Color4 objects
  20362. */
  20363. getHashCode(): number;
  20364. /**
  20365. * Creates a new Color4 copied from the current one
  20366. * @returns a new Color4 object
  20367. */
  20368. clone(): Color4;
  20369. /**
  20370. * Copies the given Color4 values into the current one
  20371. * @param source defines the source Color4 object
  20372. * @returns the current updated Color4 object
  20373. */
  20374. copyFrom(source: Color4): Color4;
  20375. /**
  20376. * Copies the given float values into the current one
  20377. * @param r defines the red component to read from
  20378. * @param g defines the green component to read from
  20379. * @param b defines the blue component to read from
  20380. * @param a defines the alpha component to read from
  20381. * @returns the current updated Color4 object
  20382. */
  20383. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  20384. /**
  20385. * Copies the given float values into the current one
  20386. * @param r defines the red component to read from
  20387. * @param g defines the green component to read from
  20388. * @param b defines the blue component to read from
  20389. * @param a defines the alpha component to read from
  20390. * @returns the current updated Color4 object
  20391. */
  20392. set(r: number, g: number, b: number, a: number): Color4;
  20393. /**
  20394. * Compute the Color4 hexadecimal code as a string
  20395. * @returns a string containing the hexadecimal representation of the Color4 object
  20396. */
  20397. toHexString(): string;
  20398. /**
  20399. * Computes a new Color4 converted from the current one to linear space
  20400. * @returns a new Color4 object
  20401. */
  20402. toLinearSpace(): Color4;
  20403. /**
  20404. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  20405. * @param convertedColor defines the Color4 object where to store the linear space version
  20406. * @returns the unmodified Color4
  20407. */
  20408. toLinearSpaceToRef(convertedColor: Color4): Color4;
  20409. /**
  20410. * Computes a new Color4 converted from the current one to gamma space
  20411. * @returns a new Color4 object
  20412. */
  20413. toGammaSpace(): Color4;
  20414. /**
  20415. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  20416. * @param convertedColor defines the Color4 object where to store the gamma space version
  20417. * @returns the unmodified Color4
  20418. */
  20419. toGammaSpaceToRef(convertedColor: Color4): Color4;
  20420. /**
  20421. * Creates a new Color4 from the string containing valid hexadecimal values
  20422. * @param hex defines a string containing valid hexadecimal values
  20423. * @returns a new Color4 object
  20424. */
  20425. static FromHexString(hex: string): Color4;
  20426. /**
  20427. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  20428. * @param left defines the start value
  20429. * @param right defines the end value
  20430. * @param amount defines the gradient factor
  20431. * @returns a new Color4 object
  20432. */
  20433. static Lerp(left: Color4, right: Color4, amount: number): Color4;
  20434. /**
  20435. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  20436. * @param left defines the start value
  20437. * @param right defines the end value
  20438. * @param amount defines the gradient factor
  20439. * @param result defines the Color4 object where to store data
  20440. */
  20441. static LerpToRef(left: Color4, right: Color4, amount: number, result: Color4): void;
  20442. /**
  20443. * Creates a new Color4 from a Color3 and an alpha value
  20444. * @param color3 defines the source Color3 to read from
  20445. * @param alpha defines the alpha component (1.0 by default)
  20446. * @returns a new Color4 object
  20447. */
  20448. static FromColor3(color3: Color3, alpha?: number): Color4;
  20449. /**
  20450. * Creates a new Color4 from the starting index element of the given array
  20451. * @param array defines the source array to read from
  20452. * @param offset defines the offset in the source array
  20453. * @returns a new Color4 object
  20454. */
  20455. static FromArray(array: ArrayLike<number>, offset?: number): Color4;
  20456. /**
  20457. * Creates a new Color3 from integer values (< 256)
  20458. * @param r defines the red component to read from (value between 0 and 255)
  20459. * @param g defines the green component to read from (value between 0 and 255)
  20460. * @param b defines the blue component to read from (value between 0 and 255)
  20461. * @param a defines the alpha component to read from (value between 0 and 255)
  20462. * @returns a new Color3 object
  20463. */
  20464. static FromInts(r: number, g: number, b: number, a: number): Color4;
  20465. /**
  20466. * Check the content of a given array and convert it to an array containing RGBA data
  20467. * If the original array was already containing count * 4 values then it is returned directly
  20468. * @param colors defines the array to check
  20469. * @param count defines the number of RGBA data to expect
  20470. * @returns an array containing count * 4 values (RGBA)
  20471. */
  20472. static CheckColors4(colors: number[], count: number): number[];
  20473. }
  20474. /**
  20475. * Class representing a vector containing 2 coordinates
  20476. */
  20477. class Vector2 {
  20478. /** defines the first coordinate */
  20479. x: number;
  20480. /** defines the second coordinate */
  20481. y: number;
  20482. /**
  20483. * Creates a new Vector2 from the given x and y coordinates
  20484. * @param x defines the first coordinate
  20485. * @param y defines the second coordinate
  20486. */
  20487. constructor(
  20488. /** defines the first coordinate */
  20489. x?: number,
  20490. /** defines the second coordinate */
  20491. y?: number);
  20492. /**
  20493. * Gets a string with the Vector2 coordinates
  20494. * @returns a string with the Vector2 coordinates
  20495. */
  20496. toString(): string;
  20497. /**
  20498. * Gets class name
  20499. * @returns the string "Vector2"
  20500. */
  20501. getClassName(): string;
  20502. /**
  20503. * Gets current vector hash code
  20504. * @returns the Vector2 hash code as a number
  20505. */
  20506. getHashCode(): number;
  20507. /**
  20508. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  20509. * @param array defines the source array
  20510. * @param index defines the offset in source array
  20511. * @returns the current Vector2
  20512. */
  20513. toArray(array: FloatArray, index?: number): Vector2;
  20514. /**
  20515. * Copy the current vector to an array
  20516. * @returns a new array with 2 elements: the Vector2 coordinates.
  20517. */
  20518. asArray(): number[];
  20519. /**
  20520. * Sets the Vector2 coordinates with the given Vector2 coordinates
  20521. * @param source defines the source Vector2
  20522. * @returns the current updated Vector2
  20523. */
  20524. copyFrom(source: Vector2): Vector2;
  20525. /**
  20526. * Sets the Vector2 coordinates with the given floats
  20527. * @param x defines the first coordinate
  20528. * @param y defines the second coordinate
  20529. * @returns the current updated Vector2
  20530. */
  20531. copyFromFloats(x: number, y: number): Vector2;
  20532. /**
  20533. * Sets the Vector2 coordinates with the given floats
  20534. * @param x defines the first coordinate
  20535. * @param y defines the second coordinate
  20536. * @returns the current updated Vector2
  20537. */
  20538. set(x: number, y: number): Vector2;
  20539. /**
  20540. * Add another vector with the current one
  20541. * @param otherVector defines the other vector
  20542. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  20543. */
  20544. add(otherVector: Vector2): Vector2;
  20545. /**
  20546. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  20547. * @param otherVector defines the other vector
  20548. * @param result defines the target vector
  20549. * @returns the unmodified current Vector2
  20550. */
  20551. addToRef(otherVector: Vector2, result: Vector2): Vector2;
  20552. /**
  20553. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  20554. * @param otherVector defines the other vector
  20555. * @returns the current updated Vector2
  20556. */
  20557. addInPlace(otherVector: Vector2): Vector2;
  20558. /**
  20559. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  20560. * @param otherVector defines the other vector
  20561. * @returns a new Vector2
  20562. */
  20563. addVector3(otherVector: Vector3): Vector2;
  20564. /**
  20565. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  20566. * @param otherVector defines the other vector
  20567. * @returns a new Vector2
  20568. */
  20569. subtract(otherVector: Vector2): Vector2;
  20570. /**
  20571. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  20572. * @param otherVector defines the other vector
  20573. * @param result defines the target vector
  20574. * @returns the unmodified current Vector2
  20575. */
  20576. subtractToRef(otherVector: Vector2, result: Vector2): Vector2;
  20577. /**
  20578. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  20579. * @param otherVector defines the other vector
  20580. * @returns the current updated Vector2
  20581. */
  20582. subtractInPlace(otherVector: Vector2): Vector2;
  20583. /**
  20584. * Multiplies in place the current Vector2 coordinates by the given ones
  20585. * @param otherVector defines the other vector
  20586. * @returns the current updated Vector2
  20587. */
  20588. multiplyInPlace(otherVector: Vector2): Vector2;
  20589. /**
  20590. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  20591. * @param otherVector defines the other vector
  20592. * @returns a new Vector2
  20593. */
  20594. multiply(otherVector: Vector2): Vector2;
  20595. /**
  20596. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  20597. * @param otherVector defines the other vector
  20598. * @param result defines the target vector
  20599. * @returns the unmodified current Vector2
  20600. */
  20601. multiplyToRef(otherVector: Vector2, result: Vector2): Vector2;
  20602. /**
  20603. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  20604. * @param x defines the first coordinate
  20605. * @param y defines the second coordinate
  20606. * @returns a new Vector2
  20607. */
  20608. multiplyByFloats(x: number, y: number): Vector2;
  20609. /**
  20610. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  20611. * @param otherVector defines the other vector
  20612. * @returns a new Vector2
  20613. */
  20614. divide(otherVector: Vector2): Vector2;
  20615. /**
  20616. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  20617. * @param otherVector defines the other vector
  20618. * @param result defines the target vector
  20619. * @returns the unmodified current Vector2
  20620. */
  20621. divideToRef(otherVector: Vector2, result: Vector2): Vector2;
  20622. /**
  20623. * Divides the current Vector2 coordinates by the given ones
  20624. * @param otherVector defines the other vector
  20625. * @returns the current updated Vector2
  20626. */
  20627. divideInPlace(otherVector: Vector2): Vector2;
  20628. /**
  20629. * Gets a new Vector2 with current Vector2 negated coordinates
  20630. * @returns a new Vector2
  20631. */
  20632. negate(): Vector2;
  20633. /**
  20634. * Multiply the Vector2 coordinates by scale
  20635. * @param scale defines the scaling factor
  20636. * @returns the current updated Vector2
  20637. */
  20638. scaleInPlace(scale: number): Vector2;
  20639. /**
  20640. * Returns a new Vector2 scaled by "scale" from the current Vector2
  20641. * @param scale defines the scaling factor
  20642. * @returns a new Vector2
  20643. */
  20644. scale(scale: number): Vector2;
  20645. /**
  20646. * Scale the current Vector2 values by a factor to a given Vector2
  20647. * @param scale defines the scale factor
  20648. * @param result defines the Vector2 object where to store the result
  20649. * @returns the unmodified current Vector2
  20650. */
  20651. scaleToRef(scale: number, result: Vector2): Vector2;
  20652. /**
  20653. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  20654. * @param scale defines the scale factor
  20655. * @param result defines the Vector2 object where to store the result
  20656. * @returns the unmodified current Vector2
  20657. */
  20658. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  20659. /**
  20660. * Gets a boolean if two vectors are equals
  20661. * @param otherVector defines the other vector
  20662. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  20663. */
  20664. equals(otherVector: Vector2): boolean;
  20665. /**
  20666. * Gets a boolean if two vectors are equals (using an epsilon value)
  20667. * @param otherVector defines the other vector
  20668. * @param epsilon defines the minimal distance to consider equality
  20669. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  20670. */
  20671. equalsWithEpsilon(otherVector: Vector2, epsilon?: number): boolean;
  20672. /**
  20673. * Gets a new Vector2 from current Vector2 floored values
  20674. * @returns a new Vector2
  20675. */
  20676. floor(): Vector2;
  20677. /**
  20678. * Gets a new Vector2 from current Vector2 floored values
  20679. * @returns a new Vector2
  20680. */
  20681. fract(): Vector2;
  20682. /**
  20683. * Gets the length of the vector
  20684. * @returns the vector length (float)
  20685. */
  20686. length(): number;
  20687. /**
  20688. * Gets the vector squared length
  20689. * @returns the vector squared length (float)
  20690. */
  20691. lengthSquared(): number;
  20692. /**
  20693. * Normalize the vector
  20694. * @returns the current updated Vector2
  20695. */
  20696. normalize(): Vector2;
  20697. /**
  20698. * Gets a new Vector2 copied from the Vector2
  20699. * @returns a new Vector2
  20700. */
  20701. clone(): Vector2;
  20702. /**
  20703. * Gets a new Vector2(0, 0)
  20704. * @returns a new Vector2
  20705. */
  20706. static Zero(): Vector2;
  20707. /**
  20708. * Gets a new Vector2(1, 1)
  20709. * @returns a new Vector2
  20710. */
  20711. static One(): Vector2;
  20712. /**
  20713. * Gets a new Vector2 set from the given index element of the given array
  20714. * @param array defines the data source
  20715. * @param offset defines the offset in the data source
  20716. * @returns a new Vector2
  20717. */
  20718. static FromArray(array: ArrayLike<number>, offset?: number): Vector2;
  20719. /**
  20720. * Sets "result" from the given index element of the given array
  20721. * @param array defines the data source
  20722. * @param offset defines the offset in the data source
  20723. * @param result defines the target vector
  20724. */
  20725. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector2): void;
  20726. /**
  20727. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  20728. * @param value1 defines 1st point of control
  20729. * @param value2 defines 2nd point of control
  20730. * @param value3 defines 3rd point of control
  20731. * @param value4 defines 4th point of control
  20732. * @param amount defines the interpolation factor
  20733. * @returns a new Vector2
  20734. */
  20735. static CatmullRom(value1: Vector2, value2: Vector2, value3: Vector2, value4: Vector2, amount: number): Vector2;
  20736. /**
  20737. * 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".
  20738. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  20739. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  20740. * @param value defines the value to clamp
  20741. * @param min defines the lower limit
  20742. * @param max defines the upper limit
  20743. * @returns a new Vector2
  20744. */
  20745. static Clamp(value: Vector2, min: Vector2, max: Vector2): Vector2;
  20746. /**
  20747. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  20748. * @param value1 defines the 1st control point
  20749. * @param tangent1 defines the outgoing tangent
  20750. * @param value2 defines the 2nd control point
  20751. * @param tangent2 defines the incoming tangent
  20752. * @param amount defines the interpolation factor
  20753. * @returns a new Vector2
  20754. */
  20755. static Hermite(value1: Vector2, tangent1: Vector2, value2: Vector2, tangent2: Vector2, amount: number): Vector2;
  20756. /**
  20757. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  20758. * @param start defines the start vector
  20759. * @param end defines the end vector
  20760. * @param amount defines the interpolation factor
  20761. * @returns a new Vector2
  20762. */
  20763. static Lerp(start: Vector2, end: Vector2, amount: number): Vector2;
  20764. /**
  20765. * Gets the dot product of the vector "left" and the vector "right"
  20766. * @param left defines first vector
  20767. * @param right defines second vector
  20768. * @returns the dot product (float)
  20769. */
  20770. static Dot(left: Vector2, right: Vector2): number;
  20771. /**
  20772. * Returns a new Vector2 equal to the normalized given vector
  20773. * @param vector defines the vector to normalize
  20774. * @returns a new Vector2
  20775. */
  20776. static Normalize(vector: Vector2): Vector2;
  20777. /**
  20778. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  20779. * @param left defines 1st vector
  20780. * @param right defines 2nd vector
  20781. * @returns a new Vector2
  20782. */
  20783. static Minimize(left: Vector2, right: Vector2): Vector2;
  20784. /**
  20785. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  20786. * @param left defines 1st vector
  20787. * @param right defines 2nd vector
  20788. * @returns a new Vector2
  20789. */
  20790. static Maximize(left: Vector2, right: Vector2): Vector2;
  20791. /**
  20792. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  20793. * @param vector defines the vector to transform
  20794. * @param transformation defines the matrix to apply
  20795. * @returns a new Vector2
  20796. */
  20797. static Transform(vector: Vector2, transformation: Matrix): Vector2;
  20798. /**
  20799. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  20800. * @param vector defines the vector to transform
  20801. * @param transformation defines the matrix to apply
  20802. * @param result defines the target vector
  20803. */
  20804. static TransformToRef(vector: Vector2, transformation: Matrix, result: Vector2): void;
  20805. /**
  20806. * Determines if a given vector is included in a triangle
  20807. * @param p defines the vector to test
  20808. * @param p0 defines 1st triangle point
  20809. * @param p1 defines 2nd triangle point
  20810. * @param p2 defines 3rd triangle point
  20811. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  20812. */
  20813. static PointInTriangle(p: Vector2, p0: Vector2, p1: Vector2, p2: Vector2): boolean;
  20814. /**
  20815. * Gets the distance between the vectors "value1" and "value2"
  20816. * @param value1 defines first vector
  20817. * @param value2 defines second vector
  20818. * @returns the distance between vectors
  20819. */
  20820. static Distance(value1: Vector2, value2: Vector2): number;
  20821. /**
  20822. * Returns the squared distance between the vectors "value1" and "value2"
  20823. * @param value1 defines first vector
  20824. * @param value2 defines second vector
  20825. * @returns the squared distance between vectors
  20826. */
  20827. static DistanceSquared(value1: Vector2, value2: Vector2): number;
  20828. /**
  20829. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  20830. * @param value1 defines first vector
  20831. * @param value2 defines second vector
  20832. * @returns a new Vector2
  20833. */
  20834. static Center(value1: Vector2, value2: Vector2): Vector2;
  20835. /**
  20836. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  20837. * @param p defines the middle point
  20838. * @param segA defines one point of the segment
  20839. * @param segB defines the other point of the segment
  20840. * @returns the shortest distance
  20841. */
  20842. static DistanceOfPointFromSegment(p: Vector2, segA: Vector2, segB: Vector2): number;
  20843. }
  20844. /**
  20845. * Classed used to store (x,y,z) vector representation
  20846. * A Vector3 is the main object used in 3D geometry
  20847. * It can represent etiher the coordinates of a point the space, either a direction
  20848. * Reminder: Babylon.js uses a left handed forward facing system
  20849. */
  20850. class Vector3 {
  20851. /**
  20852. * Defines the first coordinates (on X axis)
  20853. */
  20854. x: number;
  20855. /**
  20856. * Defines the second coordinates (on Y axis)
  20857. */
  20858. y: number;
  20859. /**
  20860. * Defines the third coordinates (on Z axis)
  20861. */
  20862. z: number;
  20863. /**
  20864. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  20865. * @param x defines the first coordinates (on X axis)
  20866. * @param y defines the second coordinates (on Y axis)
  20867. * @param z defines the third coordinates (on Z axis)
  20868. */
  20869. constructor(
  20870. /**
  20871. * Defines the first coordinates (on X axis)
  20872. */
  20873. x?: number,
  20874. /**
  20875. * Defines the second coordinates (on Y axis)
  20876. */
  20877. y?: number,
  20878. /**
  20879. * Defines the third coordinates (on Z axis)
  20880. */
  20881. z?: number);
  20882. /**
  20883. * Creates a string representation of the Vector3
  20884. * @returns a string with the Vector3 coordinates.
  20885. */
  20886. toString(): string;
  20887. /**
  20888. * Gets the class name
  20889. * @returns the string "Vector3"
  20890. */
  20891. getClassName(): string;
  20892. /**
  20893. * Creates the Vector3 hash code
  20894. * @returns a number which tends to be unique between Vector3 instances
  20895. */
  20896. getHashCode(): number;
  20897. /**
  20898. * Creates an array containing three elements : the coordinates of the Vector3
  20899. * @returns a new array of numbers
  20900. */
  20901. asArray(): number[];
  20902. /**
  20903. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  20904. * @param array defines the destination array
  20905. * @param index defines the offset in the destination array
  20906. * @returns the current Vector3
  20907. */
  20908. toArray(array: FloatArray, index?: number): Vector3;
  20909. /**
  20910. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  20911. * @returns a new Quaternion object, computed from the Vector3 coordinates
  20912. */
  20913. toQuaternion(): Quaternion;
  20914. /**
  20915. * Adds the given vector to the current Vector3
  20916. * @param otherVector defines the second operand
  20917. * @returns the current updated Vector3
  20918. */
  20919. addInPlace(otherVector: Vector3): Vector3;
  20920. /**
  20921. * Adds the given coordinates to the current Vector3
  20922. * @param x defines the x coordinate of the operand
  20923. * @param y defines the y coordinate of the operand
  20924. * @param z defines the z coordinate of the operand
  20925. * @returns the current updated Vector3
  20926. */
  20927. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  20928. /**
  20929. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  20930. * @param otherVector defines the second operand
  20931. * @returns the resulting Vector3
  20932. */
  20933. add(otherVector: Vector3): Vector3;
  20934. /**
  20935. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  20936. * @param otherVector defines the second operand
  20937. * @param result defines the Vector3 object where to store the result
  20938. * @returns the current Vector3
  20939. */
  20940. addToRef(otherVector: Vector3, result: Vector3): Vector3;
  20941. /**
  20942. * Subtract the given vector from the current Vector3
  20943. * @param otherVector defines the second operand
  20944. * @returns the current updated Vector3
  20945. */
  20946. subtractInPlace(otherVector: Vector3): Vector3;
  20947. /**
  20948. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  20949. * @param otherVector defines the second operand
  20950. * @returns the resulting Vector3
  20951. */
  20952. subtract(otherVector: Vector3): Vector3;
  20953. /**
  20954. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  20955. * @param otherVector defines the second operand
  20956. * @param result defines the Vector3 object where to store the result
  20957. * @returns the current Vector3
  20958. */
  20959. subtractToRef(otherVector: Vector3, result: Vector3): Vector3;
  20960. /**
  20961. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  20962. * @param x defines the x coordinate of the operand
  20963. * @param y defines the y coordinate of the operand
  20964. * @param z defines the z coordinate of the operand
  20965. * @returns the resulting Vector3
  20966. */
  20967. subtractFromFloats(x: number, y: number, z: number): Vector3;
  20968. /**
  20969. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  20970. * @param x defines the x coordinate of the operand
  20971. * @param y defines the y coordinate of the operand
  20972. * @param z defines the z coordinate of the operand
  20973. * @param result defines the Vector3 object where to store the result
  20974. * @returns the current Vector3
  20975. */
  20976. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  20977. /**
  20978. * Gets a new Vector3 set with the current Vector3 negated coordinates
  20979. * @returns a new Vector3
  20980. */
  20981. negate(): Vector3;
  20982. /**
  20983. * Multiplies the Vector3 coordinates by the float "scale"
  20984. * @param scale defines the multiplier factor
  20985. * @returns the current updated Vector3
  20986. */
  20987. scaleInPlace(scale: number): Vector3;
  20988. /**
  20989. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  20990. * @param scale defines the multiplier factor
  20991. * @returns a new Vector3
  20992. */
  20993. scale(scale: number): Vector3;
  20994. /**
  20995. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  20996. * @param scale defines the multiplier factor
  20997. * @param result defines the Vector3 object where to store the result
  20998. * @returns the current Vector3
  20999. */
  21000. scaleToRef(scale: number, result: Vector3): Vector3;
  21001. /**
  21002. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  21003. * @param scale defines the scale factor
  21004. * @param result defines the Vector3 object where to store the result
  21005. * @returns the unmodified current Vector3
  21006. */
  21007. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  21008. /**
  21009. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  21010. * @param otherVector defines the second operand
  21011. * @returns true if both vectors are equals
  21012. */
  21013. equals(otherVector: Vector3): boolean;
  21014. /**
  21015. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  21016. * @param otherVector defines the second operand
  21017. * @param epsilon defines the minimal distance to define values as equals
  21018. * @returns true if both vectors are distant less than epsilon
  21019. */
  21020. equalsWithEpsilon(otherVector: Vector3, epsilon?: number): boolean;
  21021. /**
  21022. * Returns true if the current Vector3 coordinates equals the given floats
  21023. * @param x defines the x coordinate of the operand
  21024. * @param y defines the y coordinate of the operand
  21025. * @param z defines the z coordinate of the operand
  21026. * @returns true if both vectors are equals
  21027. */
  21028. equalsToFloats(x: number, y: number, z: number): boolean;
  21029. /**
  21030. * Multiplies the current Vector3 coordinates by the given ones
  21031. * @param otherVector defines the second operand
  21032. * @returns the current updated Vector3
  21033. */
  21034. multiplyInPlace(otherVector: Vector3): Vector3;
  21035. /**
  21036. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  21037. * @param otherVector defines the second operand
  21038. * @returns the new Vector3
  21039. */
  21040. multiply(otherVector: Vector3): Vector3;
  21041. /**
  21042. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  21043. * @param otherVector defines the second operand
  21044. * @param result defines the Vector3 object where to store the result
  21045. * @returns the current Vector3
  21046. */
  21047. multiplyToRef(otherVector: Vector3, result: Vector3): Vector3;
  21048. /**
  21049. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  21050. * @param x defines the x coordinate of the operand
  21051. * @param y defines the y coordinate of the operand
  21052. * @param z defines the z coordinate of the operand
  21053. * @returns the new Vector3
  21054. */
  21055. multiplyByFloats(x: number, y: number, z: number): Vector3;
  21056. /**
  21057. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  21058. * @param otherVector defines the second operand
  21059. * @returns the new Vector3
  21060. */
  21061. divide(otherVector: Vector3): Vector3;
  21062. /**
  21063. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  21064. * @param otherVector defines the second operand
  21065. * @param result defines the Vector3 object where to store the result
  21066. * @returns the current Vector3
  21067. */
  21068. divideToRef(otherVector: Vector3, result: Vector3): Vector3;
  21069. /**
  21070. * Divides the current Vector3 coordinates by the given ones.
  21071. * @param otherVector defines the second operand
  21072. * @returns the current updated Vector3
  21073. */
  21074. divideInPlace(otherVector: Vector3): Vector3;
  21075. /**
  21076. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  21077. * @param other defines the second operand
  21078. * @returns the current updated Vector3
  21079. */
  21080. minimizeInPlace(other: Vector3): Vector3;
  21081. /**
  21082. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  21083. * @param other defines the second operand
  21084. * @returns the current updated Vector3
  21085. */
  21086. maximizeInPlace(other: Vector3): Vector3;
  21087. /**
  21088. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  21089. * @param x defines the x coordinate of the operand
  21090. * @param y defines the y coordinate of the operand
  21091. * @param z defines the z coordinate of the operand
  21092. * @returns the current updated Vector3
  21093. */
  21094. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  21095. /**
  21096. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  21097. * @param x defines the x coordinate of the operand
  21098. * @param y defines the y coordinate of the operand
  21099. * @param z defines the z coordinate of the operand
  21100. * @returns the current updated Vector3
  21101. */
  21102. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  21103. /**
  21104. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  21105. */
  21106. readonly isNonUniform: boolean;
  21107. /**
  21108. * Gets a new Vector3 from current Vector3 floored values
  21109. * @returns a new Vector3
  21110. */
  21111. floor(): Vector3;
  21112. /**
  21113. * Gets a new Vector3 from current Vector3 floored values
  21114. * @returns a new Vector3
  21115. */
  21116. fract(): Vector3;
  21117. /**
  21118. * Gets the length of the Vector3
  21119. * @returns the length of the Vecto3
  21120. */
  21121. length(): number;
  21122. /**
  21123. * Gets the squared length of the Vector3
  21124. * @returns squared length of the Vector3
  21125. */
  21126. lengthSquared(): number;
  21127. /**
  21128. * Normalize the current Vector3.
  21129. * Please note that this is an in place operation.
  21130. * @returns the current updated Vector3
  21131. */
  21132. normalize(): Vector3;
  21133. /**
  21134. * Normalize the current Vector3 with the given input length.
  21135. * Please note that this is an in place operation.
  21136. * @param len the length of the vector
  21137. * @returns the current updated Vector3
  21138. */
  21139. normalizeFromLength(len: number): Vector3;
  21140. /**
  21141. * Normalize the current Vector3 to a new vector
  21142. * @returns the new Vector3
  21143. */
  21144. normalizeToNew(): Vector3;
  21145. /**
  21146. * Normalize the current Vector3 to the reference
  21147. * @param reference define the Vector3 to update
  21148. * @returns the updated Vector3
  21149. */
  21150. normalizeToRef(reference: Vector3): Vector3;
  21151. /**
  21152. * Creates a new Vector3 copied from the current Vector3
  21153. * @returns the new Vector3
  21154. */
  21155. clone(): Vector3;
  21156. /**
  21157. * Copies the given vector coordinates to the current Vector3 ones
  21158. * @param source defines the source Vector3
  21159. * @returns the current updated Vector3
  21160. */
  21161. copyFrom(source: Vector3): Vector3;
  21162. /**
  21163. * Copies the given floats to the current Vector3 coordinates
  21164. * @param x defines the x coordinate of the operand
  21165. * @param y defines the y coordinate of the operand
  21166. * @param z defines the z coordinate of the operand
  21167. * @returns the current updated Vector3
  21168. */
  21169. copyFromFloats(x: number, y: number, z: number): Vector3;
  21170. /**
  21171. * Copies the given floats to the current Vector3 coordinates
  21172. * @param x defines the x coordinate of the operand
  21173. * @param y defines the y coordinate of the operand
  21174. * @param z defines the z coordinate of the operand
  21175. * @returns the current updated Vector3
  21176. */
  21177. set(x: number, y: number, z: number): Vector3;
  21178. /**
  21179. * Copies the given float to the current Vector3 coordinates
  21180. * @param v defines the x, y and z coordinates of the operand
  21181. * @returns the current updated Vector3
  21182. */
  21183. setAll(v: number): Vector3;
  21184. /**
  21185. * Get the clip factor between two vectors
  21186. * @param vector0 defines the first operand
  21187. * @param vector1 defines the second operand
  21188. * @param axis defines the axis to use
  21189. * @param size defines the size along the axis
  21190. * @returns the clip factor
  21191. */
  21192. static GetClipFactor(vector0: Vector3, vector1: Vector3, axis: Vector3, size: number): number;
  21193. /**
  21194. * Get angle between two vectors
  21195. * @param vector0 angle between vector0 and vector1
  21196. * @param vector1 angle between vector0 and vector1
  21197. * @param normal direction of the normal
  21198. * @return the angle between vector0 and vector1
  21199. */
  21200. static GetAngleBetweenVectors(vector0: Vector3, vector1: Vector3, normal: Vector3): number;
  21201. /**
  21202. * Returns a new Vector3 set from the index "offset" of the given array
  21203. * @param array defines the source array
  21204. * @param offset defines the offset in the source array
  21205. * @returns the new Vector3
  21206. */
  21207. static FromArray(array: ArrayLike<number>, offset?: number): Vector3;
  21208. /**
  21209. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  21210. * This function is deprecated. Use FromArray instead
  21211. * @param array defines the source array
  21212. * @param offset defines the offset in the source array
  21213. * @returns the new Vector3
  21214. */
  21215. static FromFloatArray(array: Float32Array, offset?: number): Vector3;
  21216. /**
  21217. * Sets the given vector "result" with the element values from the index "offset" of the given array
  21218. * @param array defines the source array
  21219. * @param offset defines the offset in the source array
  21220. * @param result defines the Vector3 where to store the result
  21221. */
  21222. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector3): void;
  21223. /**
  21224. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  21225. * This function is deprecated. Use FromArrayToRef instead.
  21226. * @param array defines the source array
  21227. * @param offset defines the offset in the source array
  21228. * @param result defines the Vector3 where to store the result
  21229. */
  21230. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector3): void;
  21231. /**
  21232. * Sets the given vector "result" with the given floats.
  21233. * @param x defines the x coordinate of the source
  21234. * @param y defines the y coordinate of the source
  21235. * @param z defines the z coordinate of the source
  21236. * @param result defines the Vector3 where to store the result
  21237. */
  21238. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  21239. /**
  21240. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  21241. * @returns a new empty Vector3
  21242. */
  21243. static Zero(): Vector3;
  21244. /**
  21245. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  21246. * @returns a new unit Vector3
  21247. */
  21248. static One(): Vector3;
  21249. /**
  21250. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  21251. * @returns a new up Vector3
  21252. */
  21253. static Up(): Vector3;
  21254. /**
  21255. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  21256. * @returns a new down Vector3
  21257. */
  21258. static Down(): Vector3;
  21259. /**
  21260. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  21261. * @returns a new forward Vector3
  21262. */
  21263. static Forward(): Vector3;
  21264. /**
  21265. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  21266. * @returns a new forward Vector3
  21267. */
  21268. static Backward(): Vector3;
  21269. /**
  21270. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  21271. * @returns a new right Vector3
  21272. */
  21273. static Right(): Vector3;
  21274. /**
  21275. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  21276. * @returns a new left Vector3
  21277. */
  21278. static Left(): Vector3;
  21279. /**
  21280. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  21281. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  21282. * @param vector defines the Vector3 to transform
  21283. * @param transformation defines the transformation matrix
  21284. * @returns the transformed Vector3
  21285. */
  21286. static TransformCoordinates(vector: Vector3, transformation: Matrix): Vector3;
  21287. /**
  21288. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  21289. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  21290. * @param vector defines the Vector3 to transform
  21291. * @param transformation defines the transformation matrix
  21292. * @param result defines the Vector3 where to store the result
  21293. */
  21294. static TransformCoordinatesToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  21295. /**
  21296. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  21297. * This method computes tranformed coordinates only, not transformed direction vectors
  21298. * @param x define the x coordinate of the source vector
  21299. * @param y define the y coordinate of the source vector
  21300. * @param z define the z coordinate of the source vector
  21301. * @param transformation defines the transformation matrix
  21302. * @param result defines the Vector3 where to store the result
  21303. */
  21304. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  21305. /**
  21306. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  21307. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  21308. * @param vector defines the Vector3 to transform
  21309. * @param transformation defines the transformation matrix
  21310. * @returns the new Vector3
  21311. */
  21312. static TransformNormal(vector: Vector3, transformation: Matrix): Vector3;
  21313. /**
  21314. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  21315. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  21316. * @param vector defines the Vector3 to transform
  21317. * @param transformation defines the transformation matrix
  21318. * @param result defines the Vector3 where to store the result
  21319. */
  21320. static TransformNormalToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  21321. /**
  21322. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  21323. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  21324. * @param x define the x coordinate of the source vector
  21325. * @param y define the y coordinate of the source vector
  21326. * @param z define the z coordinate of the source vector
  21327. * @param transformation defines the transformation matrix
  21328. * @param result defines the Vector3 where to store the result
  21329. */
  21330. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  21331. /**
  21332. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  21333. * @param value1 defines the first control point
  21334. * @param value2 defines the second control point
  21335. * @param value3 defines the third control point
  21336. * @param value4 defines the fourth control point
  21337. * @param amount defines the amount on the spline to use
  21338. * @returns the new Vector3
  21339. */
  21340. static CatmullRom(value1: Vector3, value2: Vector3, value3: Vector3, value4: Vector3, amount: number): Vector3;
  21341. /**
  21342. * 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"
  21343. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  21344. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  21345. * @param value defines the current value
  21346. * @param min defines the lower range value
  21347. * @param max defines the upper range value
  21348. * @returns the new Vector3
  21349. */
  21350. static Clamp(value: Vector3, min: Vector3, max: Vector3): Vector3;
  21351. /**
  21352. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  21353. * @param value1 defines the first control point
  21354. * @param tangent1 defines the first tangent vector
  21355. * @param value2 defines the second control point
  21356. * @param tangent2 defines the second tangent vector
  21357. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  21358. * @returns the new Vector3
  21359. */
  21360. static Hermite(value1: Vector3, tangent1: Vector3, value2: Vector3, tangent2: Vector3, amount: number): Vector3;
  21361. /**
  21362. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  21363. * @param start defines the start value
  21364. * @param end defines the end value
  21365. * @param amount max defines amount between both (between 0 and 1)
  21366. * @returns the new Vector3
  21367. */
  21368. static Lerp(start: Vector3, end: Vector3, amount: number): Vector3;
  21369. /**
  21370. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  21371. * @param start defines the start value
  21372. * @param end defines the end value
  21373. * @param amount max defines amount between both (between 0 and 1)
  21374. * @param result defines the Vector3 where to store the result
  21375. */
  21376. static LerpToRef(start: Vector3, end: Vector3, amount: number, result: Vector3): void;
  21377. /**
  21378. * Returns the dot product (float) between the vectors "left" and "right"
  21379. * @param left defines the left operand
  21380. * @param right defines the right operand
  21381. * @returns the dot product
  21382. */
  21383. static Dot(left: Vector3, right: Vector3): number;
  21384. /**
  21385. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  21386. * The cross product is then orthogonal to both "left" and "right"
  21387. * @param left defines the left operand
  21388. * @param right defines the right operand
  21389. * @returns the cross product
  21390. */
  21391. static Cross(left: Vector3, right: Vector3): Vector3;
  21392. /**
  21393. * Sets the given vector "result" with the cross product of "left" and "right"
  21394. * The cross product is then orthogonal to both "left" and "right"
  21395. * @param left defines the left operand
  21396. * @param right defines the right operand
  21397. * @param result defines the Vector3 where to store the result
  21398. */
  21399. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  21400. /**
  21401. * Returns a new Vector3 as the normalization of the given vector
  21402. * @param vector defines the Vector3 to normalize
  21403. * @returns the new Vector3
  21404. */
  21405. static Normalize(vector: Vector3): Vector3;
  21406. /**
  21407. * Sets the given vector "result" with the normalization of the given first vector
  21408. * @param vector defines the Vector3 to normalize
  21409. * @param result defines the Vector3 where to store the result
  21410. */
  21411. static NormalizeToRef(vector: Vector3, result: Vector3): void;
  21412. private static _viewportMatrixCache;
  21413. /**
  21414. * Project a Vector3 onto screen space
  21415. * @param vector defines the Vector3 to project
  21416. * @param world defines the world matrix to use
  21417. * @param transform defines the transform (view x projection) matrix to use
  21418. * @param viewport defines the screen viewport to use
  21419. * @returns the new Vector3
  21420. */
  21421. static Project(vector: Vector3, world: Matrix, transform: Matrix, viewport: Viewport): Vector3;
  21422. /**
  21423. * Unproject from screen space to object space
  21424. * @param source defines the screen space Vector3 to use
  21425. * @param viewportWidth defines the current width of the viewport
  21426. * @param viewportHeight defines the current height of the viewport
  21427. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21428. * @param transform defines the transform (view x projection) matrix to use
  21429. * @returns the new Vector3
  21430. */
  21431. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, transform: Matrix): Vector3;
  21432. /**
  21433. * Unproject from screen space to object space
  21434. * @param source defines the screen space Vector3 to use
  21435. * @param viewportWidth defines the current width of the viewport
  21436. * @param viewportHeight defines the current height of the viewport
  21437. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21438. * @param view defines the view matrix to use
  21439. * @param projection defines the projection matrix to use
  21440. * @returns the new Vector3
  21441. */
  21442. static Unproject(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Vector3;
  21443. /**
  21444. * Unproject from screen space to object space
  21445. * @param source defines the screen space Vector3 to use
  21446. * @param viewportWidth defines the current width of the viewport
  21447. * @param viewportHeight defines the current height of the viewport
  21448. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21449. * @param view defines the view matrix to use
  21450. * @param projection defines the projection matrix to use
  21451. * @param result defines the Vector3 where to store the result
  21452. */
  21453. static UnprojectToRef(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  21454. /**
  21455. * Unproject from screen space to object space
  21456. * @param sourceX defines the screen space x coordinate to use
  21457. * @param sourceY defines the screen space y coordinate to use
  21458. * @param sourceZ defines the screen space z coordinate to use
  21459. * @param viewportWidth defines the current width of the viewport
  21460. * @param viewportHeight defines the current height of the viewport
  21461. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21462. * @param view defines the view matrix to use
  21463. * @param projection defines the projection matrix to use
  21464. * @param result defines the Vector3 where to store the result
  21465. */
  21466. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  21467. /**
  21468. * Gets the minimal coordinate values between two Vector3
  21469. * @param left defines the first operand
  21470. * @param right defines the second operand
  21471. * @returns the new Vector3
  21472. */
  21473. static Minimize(left: Vector3, right: Vector3): Vector3;
  21474. /**
  21475. * Gets the maximal coordinate values between two Vector3
  21476. * @param left defines the first operand
  21477. * @param right defines the second operand
  21478. * @returns the new Vector3
  21479. */
  21480. static Maximize(left: Vector3, right: Vector3): Vector3;
  21481. /**
  21482. * Returns the distance between the vectors "value1" and "value2"
  21483. * @param value1 defines the first operand
  21484. * @param value2 defines the second operand
  21485. * @returns the distance
  21486. */
  21487. static Distance(value1: Vector3, value2: Vector3): number;
  21488. /**
  21489. * Returns the squared distance between the vectors "value1" and "value2"
  21490. * @param value1 defines the first operand
  21491. * @param value2 defines the second operand
  21492. * @returns the squared distance
  21493. */
  21494. static DistanceSquared(value1: Vector3, value2: Vector3): number;
  21495. /**
  21496. * Returns a new Vector3 located at the center between "value1" and "value2"
  21497. * @param value1 defines the first operand
  21498. * @param value2 defines the second operand
  21499. * @returns the new Vector3
  21500. */
  21501. static Center(value1: Vector3, value2: Vector3): Vector3;
  21502. /**
  21503. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  21504. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  21505. * to something in order to rotate it from its local system to the given target system
  21506. * Note: axis1, axis2 and axis3 are normalized during this operation
  21507. * @param axis1 defines the first axis
  21508. * @param axis2 defines the second axis
  21509. * @param axis3 defines the third axis
  21510. * @returns a new Vector3
  21511. */
  21512. static RotationFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Vector3;
  21513. /**
  21514. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  21515. * @param axis1 defines the first axis
  21516. * @param axis2 defines the second axis
  21517. * @param axis3 defines the third axis
  21518. * @param ref defines the Vector3 where to store the result
  21519. */
  21520. static RotationFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Vector3): void;
  21521. }
  21522. /**
  21523. * Vector4 class created for EulerAngle class conversion to Quaternion
  21524. */
  21525. class Vector4 {
  21526. /** x value of the vector */
  21527. x: number;
  21528. /** y value of the vector */
  21529. y: number;
  21530. /** z value of the vector */
  21531. z: number;
  21532. /** w value of the vector */
  21533. w: number;
  21534. /**
  21535. * Creates a Vector4 object from the given floats.
  21536. * @param x x value of the vector
  21537. * @param y y value of the vector
  21538. * @param z z value of the vector
  21539. * @param w w value of the vector
  21540. */
  21541. constructor(
  21542. /** x value of the vector */
  21543. x: number,
  21544. /** y value of the vector */
  21545. y: number,
  21546. /** z value of the vector */
  21547. z: number,
  21548. /** w value of the vector */
  21549. w: number);
  21550. /**
  21551. * Returns the string with the Vector4 coordinates.
  21552. * @returns a string containing all the vector values
  21553. */
  21554. toString(): string;
  21555. /**
  21556. * Returns the string "Vector4".
  21557. * @returns "Vector4"
  21558. */
  21559. getClassName(): string;
  21560. /**
  21561. * Returns the Vector4 hash code.
  21562. * @returns a unique hash code
  21563. */
  21564. getHashCode(): number;
  21565. /**
  21566. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  21567. * @returns the resulting array
  21568. */
  21569. asArray(): number[];
  21570. /**
  21571. * Populates the given array from the given index with the Vector4 coordinates.
  21572. * @param array array to populate
  21573. * @param index index of the array to start at (default: 0)
  21574. * @returns the Vector4.
  21575. */
  21576. toArray(array: FloatArray, index?: number): Vector4;
  21577. /**
  21578. * Adds the given vector to the current Vector4.
  21579. * @param otherVector the vector to add
  21580. * @returns the updated Vector4.
  21581. */
  21582. addInPlace(otherVector: Vector4): Vector4;
  21583. /**
  21584. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  21585. * @param otherVector the vector to add
  21586. * @returns the resulting vector
  21587. */
  21588. add(otherVector: Vector4): Vector4;
  21589. /**
  21590. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  21591. * @param otherVector the vector to add
  21592. * @param result the vector to store the result
  21593. * @returns the current Vector4.
  21594. */
  21595. addToRef(otherVector: Vector4, result: Vector4): Vector4;
  21596. /**
  21597. * Subtract in place the given vector from the current Vector4.
  21598. * @param otherVector the vector to subtract
  21599. * @returns the updated Vector4.
  21600. */
  21601. subtractInPlace(otherVector: Vector4): Vector4;
  21602. /**
  21603. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  21604. * @param otherVector the vector to add
  21605. * @returns the new vector with the result
  21606. */
  21607. subtract(otherVector: Vector4): Vector4;
  21608. /**
  21609. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  21610. * @param otherVector the vector to subtract
  21611. * @param result the vector to store the result
  21612. * @returns the current Vector4.
  21613. */
  21614. subtractToRef(otherVector: Vector4, result: Vector4): Vector4;
  21615. /**
  21616. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  21617. */
  21618. /**
  21619. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  21620. * @param x value to subtract
  21621. * @param y value to subtract
  21622. * @param z value to subtract
  21623. * @param w value to subtract
  21624. * @returns new vector containing the result
  21625. */
  21626. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  21627. /**
  21628. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  21629. * @param x value to subtract
  21630. * @param y value to subtract
  21631. * @param z value to subtract
  21632. * @param w value to subtract
  21633. * @param result the vector to store the result in
  21634. * @returns the current Vector4.
  21635. */
  21636. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  21637. /**
  21638. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  21639. * @returns a new vector with the negated values
  21640. */
  21641. negate(): Vector4;
  21642. /**
  21643. * Multiplies the current Vector4 coordinates by scale (float).
  21644. * @param scale the number to scale with
  21645. * @returns the updated Vector4.
  21646. */
  21647. scaleInPlace(scale: number): Vector4;
  21648. /**
  21649. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  21650. * @param scale the number to scale with
  21651. * @returns a new vector with the result
  21652. */
  21653. scale(scale: number): Vector4;
  21654. /**
  21655. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  21656. * @param scale the number to scale with
  21657. * @param result a vector to store the result in
  21658. * @returns the current Vector4.
  21659. */
  21660. scaleToRef(scale: number, result: Vector4): Vector4;
  21661. /**
  21662. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  21663. * @param scale defines the scale factor
  21664. * @param result defines the Vector4 object where to store the result
  21665. * @returns the unmodified current Vector4
  21666. */
  21667. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  21668. /**
  21669. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  21670. * @param otherVector the vector to compare against
  21671. * @returns true if they are equal
  21672. */
  21673. equals(otherVector: Vector4): boolean;
  21674. /**
  21675. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  21676. * @param otherVector vector to compare against
  21677. * @param epsilon (Default: very small number)
  21678. * @returns true if they are equal
  21679. */
  21680. equalsWithEpsilon(otherVector: Vector4, epsilon?: number): boolean;
  21681. /**
  21682. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  21683. * @param x x value to compare against
  21684. * @param y y value to compare against
  21685. * @param z z value to compare against
  21686. * @param w w value to compare against
  21687. * @returns true if equal
  21688. */
  21689. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  21690. /**
  21691. * Multiplies in place the current Vector4 by the given one.
  21692. * @param otherVector vector to multiple with
  21693. * @returns the updated Vector4.
  21694. */
  21695. multiplyInPlace(otherVector: Vector4): Vector4;
  21696. /**
  21697. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  21698. * @param otherVector vector to multiple with
  21699. * @returns resulting new vector
  21700. */
  21701. multiply(otherVector: Vector4): Vector4;
  21702. /**
  21703. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  21704. * @param otherVector vector to multiple with
  21705. * @param result vector to store the result
  21706. * @returns the current Vector4.
  21707. */
  21708. multiplyToRef(otherVector: Vector4, result: Vector4): Vector4;
  21709. /**
  21710. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  21711. * @param x x value multiply with
  21712. * @param y y value multiply with
  21713. * @param z z value multiply with
  21714. * @param w w value multiply with
  21715. * @returns resulting new vector
  21716. */
  21717. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  21718. /**
  21719. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  21720. * @param otherVector vector to devide with
  21721. * @returns resulting new vector
  21722. */
  21723. divide(otherVector: Vector4): Vector4;
  21724. /**
  21725. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  21726. * @param otherVector vector to devide with
  21727. * @param result vector to store the result
  21728. * @returns the current Vector4.
  21729. */
  21730. divideToRef(otherVector: Vector4, result: Vector4): Vector4;
  21731. /**
  21732. * Divides the current Vector3 coordinates by the given ones.
  21733. * @param otherVector vector to devide with
  21734. * @returns the updated Vector3.
  21735. */
  21736. divideInPlace(otherVector: Vector4): Vector4;
  21737. /**
  21738. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  21739. * @param other defines the second operand
  21740. * @returns the current updated Vector4
  21741. */
  21742. minimizeInPlace(other: Vector4): Vector4;
  21743. /**
  21744. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  21745. * @param other defines the second operand
  21746. * @returns the current updated Vector4
  21747. */
  21748. maximizeInPlace(other: Vector4): Vector4;
  21749. /**
  21750. * Gets a new Vector4 from current Vector4 floored values
  21751. * @returns a new Vector4
  21752. */
  21753. floor(): Vector4;
  21754. /**
  21755. * Gets a new Vector4 from current Vector3 floored values
  21756. * @returns a new Vector4
  21757. */
  21758. fract(): Vector4;
  21759. /**
  21760. * Returns the Vector4 length (float).
  21761. * @returns the length
  21762. */
  21763. length(): number;
  21764. /**
  21765. * Returns the Vector4 squared length (float).
  21766. * @returns the length squared
  21767. */
  21768. lengthSquared(): number;
  21769. /**
  21770. * Normalizes in place the Vector4.
  21771. * @returns the updated Vector4.
  21772. */
  21773. normalize(): Vector4;
  21774. /**
  21775. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  21776. * @returns this converted to a new vector3
  21777. */
  21778. toVector3(): Vector3;
  21779. /**
  21780. * Returns a new Vector4 copied from the current one.
  21781. * @returns the new cloned vector
  21782. */
  21783. clone(): Vector4;
  21784. /**
  21785. * Updates the current Vector4 with the given one coordinates.
  21786. * @param source the source vector to copy from
  21787. * @returns the updated Vector4.
  21788. */
  21789. copyFrom(source: Vector4): Vector4;
  21790. /**
  21791. * Updates the current Vector4 coordinates with the given floats.
  21792. * @param x float to copy from
  21793. * @param y float to copy from
  21794. * @param z float to copy from
  21795. * @param w float to copy from
  21796. * @returns the updated Vector4.
  21797. */
  21798. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  21799. /**
  21800. * Updates the current Vector4 coordinates with the given floats.
  21801. * @param x float to set from
  21802. * @param y float to set from
  21803. * @param z float to set from
  21804. * @param w float to set from
  21805. * @returns the updated Vector4.
  21806. */
  21807. set(x: number, y: number, z: number, w: number): Vector4;
  21808. /**
  21809. * Copies the given float to the current Vector3 coordinates
  21810. * @param v defines the x, y, z and w coordinates of the operand
  21811. * @returns the current updated Vector3
  21812. */
  21813. setAll(v: number): Vector4;
  21814. /**
  21815. * Returns a new Vector4 set from the starting index of the given array.
  21816. * @param array the array to pull values from
  21817. * @param offset the offset into the array to start at
  21818. * @returns the new vector
  21819. */
  21820. static FromArray(array: ArrayLike<number>, offset?: number): Vector4;
  21821. /**
  21822. * Updates the given vector "result" from the starting index of the given array.
  21823. * @param array the array to pull values from
  21824. * @param offset the offset into the array to start at
  21825. * @param result the vector to store the result in
  21826. */
  21827. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector4): void;
  21828. /**
  21829. * Updates the given vector "result" from the starting index of the given Float32Array.
  21830. * @param array the array to pull values from
  21831. * @param offset the offset into the array to start at
  21832. * @param result the vector to store the result in
  21833. */
  21834. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector4): void;
  21835. /**
  21836. * Updates the given vector "result" coordinates from the given floats.
  21837. * @param x float to set from
  21838. * @param y float to set from
  21839. * @param z float to set from
  21840. * @param w float to set from
  21841. * @param result the vector to the floats in
  21842. */
  21843. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  21844. /**
  21845. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  21846. * @returns the new vector
  21847. */
  21848. static Zero(): Vector4;
  21849. /**
  21850. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  21851. * @returns the new vector
  21852. */
  21853. static One(): Vector4;
  21854. /**
  21855. * Returns a new normalized Vector4 from the given one.
  21856. * @param vector the vector to normalize
  21857. * @returns the vector
  21858. */
  21859. static Normalize(vector: Vector4): Vector4;
  21860. /**
  21861. * Updates the given vector "result" from the normalization of the given one.
  21862. * @param vector the vector to normalize
  21863. * @param result the vector to store the result in
  21864. */
  21865. static NormalizeToRef(vector: Vector4, result: Vector4): void;
  21866. /**
  21867. * Returns a vector with the minimum values from the left and right vectors
  21868. * @param left left vector to minimize
  21869. * @param right right vector to minimize
  21870. * @returns a new vector with the minimum of the left and right vector values
  21871. */
  21872. static Minimize(left: Vector4, right: Vector4): Vector4;
  21873. /**
  21874. * Returns a vector with the maximum values from the left and right vectors
  21875. * @param left left vector to maximize
  21876. * @param right right vector to maximize
  21877. * @returns a new vector with the maximum of the left and right vector values
  21878. */
  21879. static Maximize(left: Vector4, right: Vector4): Vector4;
  21880. /**
  21881. * Returns the distance (float) between the vectors "value1" and "value2".
  21882. * @param value1 value to calulate the distance between
  21883. * @param value2 value to calulate the distance between
  21884. * @return the distance between the two vectors
  21885. */
  21886. static Distance(value1: Vector4, value2: Vector4): number;
  21887. /**
  21888. * Returns the squared distance (float) between the vectors "value1" and "value2".
  21889. * @param value1 value to calulate the distance between
  21890. * @param value2 value to calulate the distance between
  21891. * @return the distance between the two vectors squared
  21892. */
  21893. static DistanceSquared(value1: Vector4, value2: Vector4): number;
  21894. /**
  21895. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  21896. * @param value1 value to calulate the center between
  21897. * @param value2 value to calulate the center between
  21898. * @return the center between the two vectors
  21899. */
  21900. static Center(value1: Vector4, value2: Vector4): Vector4;
  21901. /**
  21902. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  21903. * This methods computes transformed normalized direction vectors only.
  21904. * @param vector the vector to transform
  21905. * @param transformation the transformation matrix to apply
  21906. * @returns the new vector
  21907. */
  21908. static TransformNormal(vector: Vector4, transformation: Matrix): Vector4;
  21909. /**
  21910. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  21911. * This methods computes transformed normalized direction vectors only.
  21912. * @param vector the vector to transform
  21913. * @param transformation the transformation matrix to apply
  21914. * @param result the vector to store the result in
  21915. */
  21916. static TransformNormalToRef(vector: Vector4, transformation: Matrix, result: Vector4): void;
  21917. /**
  21918. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  21919. * This methods computes transformed normalized direction vectors only.
  21920. * @param x value to transform
  21921. * @param y value to transform
  21922. * @param z value to transform
  21923. * @param w value to transform
  21924. * @param transformation the transformation matrix to apply
  21925. * @param result the vector to store the results in
  21926. */
  21927. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: Matrix, result: Vector4): void;
  21928. }
  21929. /**
  21930. * Interface for the size containing width and height
  21931. */
  21932. interface ISize {
  21933. /**
  21934. * Width
  21935. */
  21936. width: number;
  21937. /**
  21938. * Heighht
  21939. */
  21940. height: number;
  21941. }
  21942. /**
  21943. * Size containing widht and height
  21944. */
  21945. class Size implements ISize {
  21946. /**
  21947. * Width
  21948. */
  21949. width: number;
  21950. /**
  21951. * Height
  21952. */
  21953. height: number;
  21954. /**
  21955. * Creates a Size object from the given width and height (floats).
  21956. * @param width width of the new size
  21957. * @param height height of the new size
  21958. */
  21959. constructor(width: number, height: number);
  21960. /**
  21961. * Returns a string with the Size width and height
  21962. * @returns a string with the Size width and height
  21963. */
  21964. toString(): string;
  21965. /**
  21966. * "Size"
  21967. * @returns the string "Size"
  21968. */
  21969. getClassName(): string;
  21970. /**
  21971. * Returns the Size hash code.
  21972. * @returns a hash code for a unique width and height
  21973. */
  21974. getHashCode(): number;
  21975. /**
  21976. * Updates the current size from the given one.
  21977. * @param src the given size
  21978. */
  21979. copyFrom(src: Size): void;
  21980. /**
  21981. * Updates in place the current Size from the given floats.
  21982. * @param width width of the new size
  21983. * @param height height of the new size
  21984. * @returns the updated Size.
  21985. */
  21986. copyFromFloats(width: number, height: number): Size;
  21987. /**
  21988. * Updates in place the current Size from the given floats.
  21989. * @param width width to set
  21990. * @param height height to set
  21991. * @returns the updated Size.
  21992. */
  21993. set(width: number, height: number): Size;
  21994. /**
  21995. * Multiplies the width and height by numbers
  21996. * @param w factor to multiple the width by
  21997. * @param h factor to multiple the height by
  21998. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  21999. */
  22000. multiplyByFloats(w: number, h: number): Size;
  22001. /**
  22002. * Clones the size
  22003. * @returns a new Size copied from the given one.
  22004. */
  22005. clone(): Size;
  22006. /**
  22007. * True if the current Size and the given one width and height are strictly equal.
  22008. * @param other the other size to compare against
  22009. * @returns True if the current Size and the given one width and height are strictly equal.
  22010. */
  22011. equals(other: Size): boolean;
  22012. /**
  22013. * The surface of the Size : width * height (float).
  22014. */
  22015. readonly surface: number;
  22016. /**
  22017. * Create a new size of zero
  22018. * @returns a new Size set to (0.0, 0.0)
  22019. */
  22020. static Zero(): Size;
  22021. /**
  22022. * Sums the width and height of two sizes
  22023. * @param otherSize size to add to this size
  22024. * @returns a new Size set as the addition result of the current Size and the given one.
  22025. */
  22026. add(otherSize: Size): Size;
  22027. /**
  22028. * Subtracts the width and height of two
  22029. * @param otherSize size to subtract to this size
  22030. * @returns a new Size set as the subtraction result of the given one from the current Size.
  22031. */
  22032. subtract(otherSize: Size): Size;
  22033. /**
  22034. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  22035. * @param start starting size to lerp between
  22036. * @param end end size to lerp between
  22037. * @param amount amount to lerp between the start and end values
  22038. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  22039. */
  22040. static Lerp(start: Size, end: Size, amount: number): Size;
  22041. }
  22042. /**
  22043. * Class used to store quaternion data
  22044. * @see https://en.wikipedia.org/wiki/Quaternion
  22045. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  22046. */
  22047. class Quaternion {
  22048. /** defines the first component (0 by default) */
  22049. x: number;
  22050. /** defines the second component (0 by default) */
  22051. y: number;
  22052. /** defines the third component (0 by default) */
  22053. z: number;
  22054. /** defines the fourth component (1.0 by default) */
  22055. w: number;
  22056. /**
  22057. * Creates a new Quaternion from the given floats
  22058. * @param x defines the first component (0 by default)
  22059. * @param y defines the second component (0 by default)
  22060. * @param z defines the third component (0 by default)
  22061. * @param w defines the fourth component (1.0 by default)
  22062. */
  22063. constructor(
  22064. /** defines the first component (0 by default) */
  22065. x?: number,
  22066. /** defines the second component (0 by default) */
  22067. y?: number,
  22068. /** defines the third component (0 by default) */
  22069. z?: number,
  22070. /** defines the fourth component (1.0 by default) */
  22071. w?: number);
  22072. /**
  22073. * Gets a string representation for the current quaternion
  22074. * @returns a string with the Quaternion coordinates
  22075. */
  22076. toString(): string;
  22077. /**
  22078. * Gets the class name of the quaternion
  22079. * @returns the string "Quaternion"
  22080. */
  22081. getClassName(): string;
  22082. /**
  22083. * Gets a hash code for this quaternion
  22084. * @returns the quaternion hash code
  22085. */
  22086. getHashCode(): number;
  22087. /**
  22088. * Copy the quaternion to an array
  22089. * @returns a new array populated with 4 elements from the quaternion coordinates
  22090. */
  22091. asArray(): number[];
  22092. /**
  22093. * Check if two quaternions are equals
  22094. * @param otherQuaternion defines the second operand
  22095. * @return true if the current quaternion and the given one coordinates are strictly equals
  22096. */
  22097. equals(otherQuaternion: Quaternion): boolean;
  22098. /**
  22099. * Clone the current quaternion
  22100. * @returns a new quaternion copied from the current one
  22101. */
  22102. clone(): Quaternion;
  22103. /**
  22104. * Copy a quaternion to the current one
  22105. * @param other defines the other quaternion
  22106. * @returns the updated current quaternion
  22107. */
  22108. copyFrom(other: Quaternion): Quaternion;
  22109. /**
  22110. * Updates the current quaternion with the given float coordinates
  22111. * @param x defines the x coordinate
  22112. * @param y defines the y coordinate
  22113. * @param z defines the z coordinate
  22114. * @param w defines the w coordinate
  22115. * @returns the updated current quaternion
  22116. */
  22117. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  22118. /**
  22119. * Updates the current quaternion from the given float coordinates
  22120. * @param x defines the x coordinate
  22121. * @param y defines the y coordinate
  22122. * @param z defines the z coordinate
  22123. * @param w defines the w coordinate
  22124. * @returns the updated current quaternion
  22125. */
  22126. set(x: number, y: number, z: number, w: number): Quaternion;
  22127. /**
  22128. * Adds two quaternions
  22129. * @param other defines the second operand
  22130. * @returns a new quaternion as the addition result of the given one and the current quaternion
  22131. */
  22132. add(other: Quaternion): Quaternion;
  22133. /**
  22134. * Add a quaternion to the current one
  22135. * @param other defines the quaternion to add
  22136. * @returns the current quaternion
  22137. */
  22138. addInPlace(other: Quaternion): Quaternion;
  22139. /**
  22140. * Subtract two quaternions
  22141. * @param other defines the second operand
  22142. * @returns a new quaternion as the subtraction result of the given one from the current one
  22143. */
  22144. subtract(other: Quaternion): Quaternion;
  22145. /**
  22146. * Multiplies the current quaternion by a scale factor
  22147. * @param value defines the scale factor
  22148. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  22149. */
  22150. scale(value: number): Quaternion;
  22151. /**
  22152. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  22153. * @param scale defines the scale factor
  22154. * @param result defines the Quaternion object where to store the result
  22155. * @returns the unmodified current quaternion
  22156. */
  22157. scaleToRef(scale: number, result: Quaternion): Quaternion;
  22158. /**
  22159. * Multiplies in place the current quaternion by a scale factor
  22160. * @param value defines the scale factor
  22161. * @returns the current modified quaternion
  22162. */
  22163. scaleInPlace(value: number): Quaternion;
  22164. /**
  22165. * Scale the current quaternion values by a factor and add the result to a given quaternion
  22166. * @param scale defines the scale factor
  22167. * @param result defines the Quaternion object where to store the result
  22168. * @returns the unmodified current quaternion
  22169. */
  22170. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  22171. /**
  22172. * Multiplies two quaternions
  22173. * @param q1 defines the second operand
  22174. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  22175. */
  22176. multiply(q1: Quaternion): Quaternion;
  22177. /**
  22178. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  22179. * @param q1 defines the second operand
  22180. * @param result defines the target quaternion
  22181. * @returns the current quaternion
  22182. */
  22183. multiplyToRef(q1: Quaternion, result: Quaternion): Quaternion;
  22184. /**
  22185. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  22186. * @param q1 defines the second operand
  22187. * @returns the currentupdated quaternion
  22188. */
  22189. multiplyInPlace(q1: Quaternion): Quaternion;
  22190. /**
  22191. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  22192. * @param ref defines the target quaternion
  22193. * @returns the current quaternion
  22194. */
  22195. conjugateToRef(ref: Quaternion): Quaternion;
  22196. /**
  22197. * Conjugates in place (1-q) the current quaternion
  22198. * @returns the current updated quaternion
  22199. */
  22200. conjugateInPlace(): Quaternion;
  22201. /**
  22202. * Conjugates in place (1-q) the current quaternion
  22203. * @returns a new quaternion
  22204. */
  22205. conjugate(): Quaternion;
  22206. /**
  22207. * Gets length of current quaternion
  22208. * @returns the quaternion length (float)
  22209. */
  22210. length(): number;
  22211. /**
  22212. * Normalize in place the current quaternion
  22213. * @returns the current updated quaternion
  22214. */
  22215. normalize(): Quaternion;
  22216. /**
  22217. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  22218. * @param order is a reserved parameter and is ignore for now
  22219. * @returns a new Vector3 containing the Euler angles
  22220. */
  22221. toEulerAngles(order?: string): Vector3;
  22222. /**
  22223. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  22224. * @param result defines the vector which will be filled with the Euler angles
  22225. * @param order is a reserved parameter and is ignore for now
  22226. * @returns the current unchanged quaternion
  22227. */
  22228. toEulerAnglesToRef(result: Vector3, order?: string): Quaternion;
  22229. /**
  22230. * Updates the given rotation matrix with the current quaternion values
  22231. * @param result defines the target matrix
  22232. * @returns the current unchanged quaternion
  22233. */
  22234. toRotationMatrix(result: Matrix): Quaternion;
  22235. /**
  22236. * Updates the current quaternion from the given rotation matrix values
  22237. * @param matrix defines the source matrix
  22238. * @returns the current updated quaternion
  22239. */
  22240. fromRotationMatrix(matrix: Matrix): Quaternion;
  22241. /**
  22242. * Creates a new quaternion from a rotation matrix
  22243. * @param matrix defines the source matrix
  22244. * @returns a new quaternion created from the given rotation matrix values
  22245. */
  22246. static FromRotationMatrix(matrix: Matrix): Quaternion;
  22247. /**
  22248. * Updates the given quaternion with the given rotation matrix values
  22249. * @param matrix defines the source matrix
  22250. * @param result defines the target quaternion
  22251. */
  22252. static FromRotationMatrixToRef(matrix: Matrix, result: Quaternion): void;
  22253. /**
  22254. * Returns the dot product (float) between the quaternions "left" and "right"
  22255. * @param left defines the left operand
  22256. * @param right defines the right operand
  22257. * @returns the dot product
  22258. */
  22259. static Dot(left: Quaternion, right: Quaternion): number;
  22260. /**
  22261. * Checks if the two quaternions are close to each other
  22262. * @param quat0 defines the first quaternion to check
  22263. * @param quat1 defines the second quaternion to check
  22264. * @returns true if the two quaternions are close to each other
  22265. */
  22266. static AreClose(quat0: Quaternion, quat1: Quaternion): boolean;
  22267. /**
  22268. * Creates an empty quaternion
  22269. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  22270. */
  22271. static Zero(): Quaternion;
  22272. /**
  22273. * Inverse a given quaternion
  22274. * @param q defines the source quaternion
  22275. * @returns a new quaternion as the inverted current quaternion
  22276. */
  22277. static Inverse(q: Quaternion): Quaternion;
  22278. /**
  22279. * Creates an identity quaternion
  22280. * @returns the identity quaternion
  22281. */
  22282. static Identity(): Quaternion;
  22283. /**
  22284. * Gets a boolean indicating if the given quaternion is identity
  22285. * @param quaternion defines the quaternion to check
  22286. * @returns true if the quaternion is identity
  22287. */
  22288. static IsIdentity(quaternion: Quaternion): boolean;
  22289. /**
  22290. * Creates a quaternion from a rotation around an axis
  22291. * @param axis defines the axis to use
  22292. * @param angle defines the angle to use
  22293. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  22294. */
  22295. static RotationAxis(axis: Vector3, angle: number): Quaternion;
  22296. /**
  22297. * Creates a rotation around an axis and stores it into the given quaternion
  22298. * @param axis defines the axis to use
  22299. * @param angle defines the angle to use
  22300. * @param result defines the target quaternion
  22301. * @returns the target quaternion
  22302. */
  22303. static RotationAxisToRef(axis: Vector3, angle: number, result: Quaternion): Quaternion;
  22304. /**
  22305. * Creates a new quaternion from data stored into an array
  22306. * @param array defines the data source
  22307. * @param offset defines the offset in the source array where the data starts
  22308. * @returns a new quaternion
  22309. */
  22310. static FromArray(array: ArrayLike<number>, offset?: number): Quaternion;
  22311. /**
  22312. * Creates a new quaternion from the given Euler float angles (y, x, z)
  22313. * @param yaw defines the rotation around Y axis
  22314. * @param pitch defines the rotation around X axis
  22315. * @param roll defines the rotation around Z axis
  22316. * @returns the new quaternion
  22317. */
  22318. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  22319. /**
  22320. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  22321. * @param yaw defines the rotation around Y axis
  22322. * @param pitch defines the rotation around X axis
  22323. * @param roll defines the rotation around Z axis
  22324. * @param result defines the target quaternion
  22325. */
  22326. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  22327. /**
  22328. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  22329. * @param alpha defines the rotation around first axis
  22330. * @param beta defines the rotation around second axis
  22331. * @param gamma defines the rotation around third axis
  22332. * @returns the new quaternion
  22333. */
  22334. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  22335. /**
  22336. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  22337. * @param alpha defines the rotation around first axis
  22338. * @param beta defines the rotation around second axis
  22339. * @param gamma defines the rotation around third axis
  22340. * @param result defines the target quaternion
  22341. */
  22342. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  22343. /**
  22344. * 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)
  22345. * @param axis1 defines the first axis
  22346. * @param axis2 defines the second axis
  22347. * @param axis3 defines the third axis
  22348. * @returns the new quaternion
  22349. */
  22350. static RotationQuaternionFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Quaternion;
  22351. /**
  22352. * 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
  22353. * @param axis1 defines the first axis
  22354. * @param axis2 defines the second axis
  22355. * @param axis3 defines the third axis
  22356. * @param ref defines the target quaternion
  22357. */
  22358. static RotationQuaternionFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Quaternion): void;
  22359. /**
  22360. * Interpolates between two quaternions
  22361. * @param left defines first quaternion
  22362. * @param right defines second quaternion
  22363. * @param amount defines the gradient to use
  22364. * @returns the new interpolated quaternion
  22365. */
  22366. static Slerp(left: Quaternion, right: Quaternion, amount: number): Quaternion;
  22367. /**
  22368. * Interpolates between two quaternions and stores it into a target quaternion
  22369. * @param left defines first quaternion
  22370. * @param right defines second quaternion
  22371. * @param amount defines the gradient to use
  22372. * @param result defines the target quaternion
  22373. */
  22374. static SlerpToRef(left: Quaternion, right: Quaternion, amount: number, result: Quaternion): void;
  22375. /**
  22376. * Interpolate between two quaternions using Hermite interpolation
  22377. * @param value1 defines first quaternion
  22378. * @param tangent1 defines the incoming tangent
  22379. * @param value2 defines second quaternion
  22380. * @param tangent2 defines the outgoing tangent
  22381. * @param amount defines the target quaternion
  22382. * @returns the new interpolated quaternion
  22383. */
  22384. static Hermite(value1: Quaternion, tangent1: Quaternion, value2: Quaternion, tangent2: Quaternion, amount: number): Quaternion;
  22385. }
  22386. /**
  22387. * Class used to store matrix data (4x4)
  22388. */
  22389. class Matrix {
  22390. private static _tempQuaternion;
  22391. private static _xAxis;
  22392. private static _yAxis;
  22393. private static _zAxis;
  22394. private static _updateFlagSeed;
  22395. private static _identityReadOnly;
  22396. private _isIdentity;
  22397. private _isIdentityDirty;
  22398. /**
  22399. * Gets the update flag of the matrix which is an unique number for the matrix.
  22400. * It will be incremented every time the matrix data change.
  22401. * You can use it to speed the comparison between two versions of the same matrix.
  22402. */
  22403. updateFlag: number;
  22404. /**
  22405. * Gets or sets the internal data of the matrix
  22406. */
  22407. m: Float32Array;
  22408. /** @hidden */
  22409. _markAsUpdated(): void;
  22410. /**
  22411. * Creates an empty matrix (filled with zeros)
  22412. */
  22413. constructor();
  22414. /**
  22415. * Check if the current matrix is indentity
  22416. * @param considerAsTextureMatrix defines if the current matrix must be considered as a texture matrix (3x2)
  22417. * @returns true is the matrix is the identity matrix
  22418. */
  22419. isIdentity(considerAsTextureMatrix?: boolean): boolean;
  22420. /**
  22421. * Gets the determinant of the matrix
  22422. * @returns the matrix determinant
  22423. */
  22424. determinant(): number;
  22425. /**
  22426. * Returns the matrix as a Float32Array
  22427. * @returns the matrix underlying array
  22428. */
  22429. toArray(): Float32Array;
  22430. /**
  22431. * Returns the matrix as a Float32Array
  22432. * @returns the matrix underlying array.
  22433. */
  22434. asArray(): Float32Array;
  22435. /**
  22436. * Inverts the current matrix in place
  22437. * @returns the current inverted matrix
  22438. */
  22439. invert(): Matrix;
  22440. /**
  22441. * Sets all the matrix elements to zero
  22442. * @returns the current matrix
  22443. */
  22444. reset(): Matrix;
  22445. /**
  22446. * Adds the current matrix with a second one
  22447. * @param other defines the matrix to add
  22448. * @returns a new matrix as the addition of the current matrix and the given one
  22449. */
  22450. add(other: Matrix): Matrix;
  22451. /**
  22452. * Sets the given matrix "result" to the addition of the current matrix and the given one
  22453. * @param other defines the matrix to add
  22454. * @param result defines the target matrix
  22455. * @returns the current matrix
  22456. */
  22457. addToRef(other: Matrix, result: Matrix): Matrix;
  22458. /**
  22459. * Adds in place the given matrix to the current matrix
  22460. * @param other defines the second operand
  22461. * @returns the current updated matrix
  22462. */
  22463. addToSelf(other: Matrix): Matrix;
  22464. /**
  22465. * Sets the given matrix to the current inverted Matrix
  22466. * @param other defines the target matrix
  22467. * @returns the unmodified current matrix
  22468. */
  22469. invertToRef(other: Matrix): Matrix;
  22470. /**
  22471. * Inserts the translation vector (using 3 floats) in the current matrix
  22472. * @param x defines the 1st component of the translation
  22473. * @param y defines the 2nd component of the translation
  22474. * @param z defines the 3rd component of the translation
  22475. * @returns the current updated matrix
  22476. */
  22477. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  22478. /**
  22479. * Inserts the translation vector in the current matrix
  22480. * @param vector3 defines the translation to insert
  22481. * @returns the current updated matrix
  22482. */
  22483. setTranslation(vector3: Vector3): Matrix;
  22484. /**
  22485. * Gets the translation value of the current matrix
  22486. * @returns a new Vector3 as the extracted translation from the matrix
  22487. */
  22488. getTranslation(): Vector3;
  22489. /**
  22490. * Fill a Vector3 with the extracted translation from the matrix
  22491. * @param result defines the Vector3 where to store the translation
  22492. * @returns the current matrix
  22493. */
  22494. getTranslationToRef(result: Vector3): Matrix;
  22495. /**
  22496. * Remove rotation and scaling part from the matrix
  22497. * @returns the updated matrix
  22498. */
  22499. removeRotationAndScaling(): Matrix;
  22500. /**
  22501. * Multiply two matrices
  22502. * @param other defines the second operand
  22503. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  22504. */
  22505. multiply(other: Matrix): Matrix;
  22506. /**
  22507. * Copy the current matrix from the given one
  22508. * @param other defines the source matrix
  22509. * @returns the current updated matrix
  22510. */
  22511. copyFrom(other: Matrix): Matrix;
  22512. /**
  22513. * Populates the given array from the starting index with the current matrix values
  22514. * @param array defines the target array
  22515. * @param offset defines the offset in the target array where to start storing values
  22516. * @returns the current matrix
  22517. */
  22518. copyToArray(array: Float32Array, offset?: number): Matrix;
  22519. /**
  22520. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  22521. * @param other defines the second operand
  22522. * @param result defines the matrix where to store the multiplication
  22523. * @returns the current matrix
  22524. */
  22525. multiplyToRef(other: Matrix, result: Matrix): Matrix;
  22526. /**
  22527. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  22528. * @param other defines the second operand
  22529. * @param result defines the array where to store the multiplication
  22530. * @param offset defines the offset in the target array where to start storing values
  22531. * @returns the current matrix
  22532. */
  22533. multiplyToArray(other: Matrix, result: Float32Array, offset: number): Matrix;
  22534. /**
  22535. * Check equality between this matrix and a second one
  22536. * @param value defines the second matrix to compare
  22537. * @returns true is the current matrix and the given one values are strictly equal
  22538. */
  22539. equals(value: Matrix): boolean;
  22540. /**
  22541. * Clone the current matrix
  22542. * @returns a new matrix from the current matrix
  22543. */
  22544. clone(): Matrix;
  22545. /**
  22546. * Returns the name of the current matrix class
  22547. * @returns the string "Matrix"
  22548. */
  22549. getClassName(): string;
  22550. /**
  22551. * Gets the hash code of the current matrix
  22552. * @returns the hash code
  22553. */
  22554. getHashCode(): number;
  22555. /**
  22556. * Decomposes the current Matrix into a translation, rotation and scaling components
  22557. * @param scale defines the scale vector3 given as a reference to update
  22558. * @param rotation defines the rotation quaternion given as a reference to update
  22559. * @param translation defines the translation vector3 given as a reference to update
  22560. * @returns true if operation was successful
  22561. */
  22562. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  22563. /**
  22564. * Gets specific row of the matrix
  22565. * @param index defines the number of the row to get
  22566. * @returns the index-th row of the current matrix as a new Vector4
  22567. */
  22568. getRow(index: number): Nullable<Vector4>;
  22569. /**
  22570. * Sets the index-th row of the current matrix to the vector4 values
  22571. * @param index defines the number of the row to set
  22572. * @param row defines the target vector4
  22573. * @returns the updated current matrix
  22574. */
  22575. setRow(index: number, row: Vector4): Matrix;
  22576. /**
  22577. * Compute the transpose of the matrix
  22578. * @returns the new transposed matrix
  22579. */
  22580. transpose(): Matrix;
  22581. /**
  22582. * Compute the transpose of the matrix and store it in a given matrix
  22583. * @param result defines the target matrix
  22584. * @returns the current matrix
  22585. */
  22586. transposeToRef(result: Matrix): Matrix;
  22587. /**
  22588. * Sets the index-th row of the current matrix with the given 4 x float values
  22589. * @param index defines the row index
  22590. * @param x defines the x component to set
  22591. * @param y defines the y component to set
  22592. * @param z defines the z component to set
  22593. * @param w defines the w component to set
  22594. * @returns the updated current matrix
  22595. */
  22596. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  22597. /**
  22598. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  22599. * @param scale defines the scale factor
  22600. * @returns a new matrix
  22601. */
  22602. scale(scale: number): Matrix;
  22603. /**
  22604. * Scale the current matrix values by a factor to a given result matrix
  22605. * @param scale defines the scale factor
  22606. * @param result defines the matrix to store the result
  22607. * @returns the current matrix
  22608. */
  22609. scaleToRef(scale: number, result: Matrix): Matrix;
  22610. /**
  22611. * Scale the current matrix values by a factor and add the result to a given matrix
  22612. * @param scale defines the scale factor
  22613. * @param result defines the Matrix to store the result
  22614. * @returns the current matrix
  22615. */
  22616. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  22617. /**
  22618. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  22619. * @param ref matrix to store the result
  22620. */
  22621. toNormalMatrix(ref: Matrix): void;
  22622. /**
  22623. * Gets only rotation part of the current matrix
  22624. * @returns a new matrix sets to the extracted rotation matrix from the current one
  22625. */
  22626. getRotationMatrix(): Matrix;
  22627. /**
  22628. * Extracts the rotation matrix from the current one and sets it as the given "result"
  22629. * @param result defines the target matrix to store data to
  22630. * @returns the current matrix
  22631. */
  22632. getRotationMatrixToRef(result: Matrix): Matrix;
  22633. /**
  22634. * Creates a matrix from an array
  22635. * @param array defines the source array
  22636. * @param offset defines an offset in the source array
  22637. * @returns a new Matrix set from the starting index of the given array
  22638. */
  22639. static FromArray(array: ArrayLike<number>, offset?: number): Matrix;
  22640. /**
  22641. * Copy the content of an array into a given matrix
  22642. * @param array defines the source array
  22643. * @param offset defines an offset in the source array
  22644. * @param result defines the target matrix
  22645. */
  22646. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Matrix): void;
  22647. /**
  22648. * Stores an array into a matrix after having multiplied each component by a given factor
  22649. * @param array defines the source array
  22650. * @param offset defines the offset in the source array
  22651. * @param scale defines the scaling factor
  22652. * @param result defines the target matrix
  22653. */
  22654. static FromFloat32ArrayToRefScaled(array: Float32Array, offset: number, scale: number, result: Matrix): void;
  22655. /**
  22656. * Stores a list of values (16) inside a given matrix
  22657. * @param initialM11 defines 1st value of 1st row
  22658. * @param initialM12 defines 2nd value of 1st row
  22659. * @param initialM13 defines 3rd value of 1st row
  22660. * @param initialM14 defines 4th value of 1st row
  22661. * @param initialM21 defines 1st value of 2nd row
  22662. * @param initialM22 defines 2nd value of 2nd row
  22663. * @param initialM23 defines 3rd value of 2nd row
  22664. * @param initialM24 defines 4th value of 2nd row
  22665. * @param initialM31 defines 1st value of 3rd row
  22666. * @param initialM32 defines 2nd value of 3rd row
  22667. * @param initialM33 defines 3rd value of 3rd row
  22668. * @param initialM34 defines 4th value of 3rd row
  22669. * @param initialM41 defines 1st value of 4th row
  22670. * @param initialM42 defines 2nd value of 4th row
  22671. * @param initialM43 defines 3rd value of 4th row
  22672. * @param initialM44 defines 4th value of 4th row
  22673. * @param result defines the target matrix
  22674. */
  22675. 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;
  22676. /**
  22677. * Gets an identity matrix that must not be updated
  22678. */
  22679. static readonly IdentityReadOnly: Matrix;
  22680. /**
  22681. * Creates new matrix from a list of values (16)
  22682. * @param initialM11 defines 1st value of 1st row
  22683. * @param initialM12 defines 2nd value of 1st row
  22684. * @param initialM13 defines 3rd value of 1st row
  22685. * @param initialM14 defines 4th value of 1st row
  22686. * @param initialM21 defines 1st value of 2nd row
  22687. * @param initialM22 defines 2nd value of 2nd row
  22688. * @param initialM23 defines 3rd value of 2nd row
  22689. * @param initialM24 defines 4th value of 2nd row
  22690. * @param initialM31 defines 1st value of 3rd row
  22691. * @param initialM32 defines 2nd value of 3rd row
  22692. * @param initialM33 defines 3rd value of 3rd row
  22693. * @param initialM34 defines 4th value of 3rd row
  22694. * @param initialM41 defines 1st value of 4th row
  22695. * @param initialM42 defines 2nd value of 4th row
  22696. * @param initialM43 defines 3rd value of 4th row
  22697. * @param initialM44 defines 4th value of 4th row
  22698. * @returns the new matrix
  22699. */
  22700. 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;
  22701. /**
  22702. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  22703. * @param scale defines the scale vector3
  22704. * @param rotation defines the rotation quaternion
  22705. * @param translation defines the translation vector3
  22706. * @returns a new matrix
  22707. */
  22708. static Compose(scale: Vector3, rotation: Quaternion, translation: Vector3): Matrix;
  22709. /**
  22710. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  22711. * @param scale defines the scale vector3
  22712. * @param rotation defines the rotation quaternion
  22713. * @param translation defines the translation vector3
  22714. * @param result defines the target matrix
  22715. */
  22716. static ComposeToRef(scale: Vector3, rotation: Quaternion, translation: Vector3, result: Matrix): void;
  22717. /**
  22718. * Creates a new identity matrix
  22719. * @returns a new identity matrix
  22720. */
  22721. static Identity(): Matrix;
  22722. /**
  22723. * Creates a new identity matrix and stores the result in a given matrix
  22724. * @param result defines the target matrix
  22725. */
  22726. static IdentityToRef(result: Matrix): void;
  22727. /**
  22728. * Creates a new zero matrix
  22729. * @returns a new zero matrix
  22730. */
  22731. static Zero(): Matrix;
  22732. /**
  22733. * Creates a new rotation matrix for "angle" radians around the X axis
  22734. * @param angle defines the angle (in radians) to use
  22735. * @return the new matrix
  22736. */
  22737. static RotationX(angle: number): Matrix;
  22738. /**
  22739. * Creates a new matrix as the invert of a given matrix
  22740. * @param source defines the source matrix
  22741. * @returns the new matrix
  22742. */
  22743. static Invert(source: Matrix): Matrix;
  22744. /**
  22745. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  22746. * @param angle defines the angle (in radians) to use
  22747. * @param result defines the target matrix
  22748. */
  22749. static RotationXToRef(angle: number, result: Matrix): void;
  22750. /**
  22751. * Creates a new rotation matrix for "angle" radians around the Y axis
  22752. * @param angle defines the angle (in radians) to use
  22753. * @return the new matrix
  22754. */
  22755. static RotationY(angle: number): Matrix;
  22756. /**
  22757. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  22758. * @param angle defines the angle (in radians) to use
  22759. * @param result defines the target matrix
  22760. */
  22761. static RotationYToRef(angle: number, result: Matrix): void;
  22762. /**
  22763. * Creates a new rotation matrix for "angle" radians around the Z axis
  22764. * @param angle defines the angle (in radians) to use
  22765. * @return the new matrix
  22766. */
  22767. static RotationZ(angle: number): Matrix;
  22768. /**
  22769. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  22770. * @param angle defines the angle (in radians) to use
  22771. * @param result defines the target matrix
  22772. */
  22773. static RotationZToRef(angle: number, result: Matrix): void;
  22774. /**
  22775. * Creates a new rotation matrix for "angle" radians around the given axis
  22776. * @param axis defines the axis to use
  22777. * @param angle defines the angle (in radians) to use
  22778. * @return the new matrix
  22779. */
  22780. static RotationAxis(axis: Vector3, angle: number): Matrix;
  22781. /**
  22782. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  22783. * @param axis defines the axis to use
  22784. * @param angle defines the angle (in radians) to use
  22785. * @param result defines the target matrix
  22786. */
  22787. static RotationAxisToRef(axis: Vector3, angle: number, result: Matrix): void;
  22788. /**
  22789. * Creates a rotation matrix
  22790. * @param yaw defines the yaw angle in radians (Y axis)
  22791. * @param pitch defines the pitch angle in radians (X axis)
  22792. * @param roll defines the roll angle in radians (X axis)
  22793. * @returns the new rotation matrix
  22794. */
  22795. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  22796. /**
  22797. * Creates a rotation matrix and stores it in a given matrix
  22798. * @param yaw defines the yaw angle in radians (Y axis)
  22799. * @param pitch defines the pitch angle in radians (X axis)
  22800. * @param roll defines the roll angle in radians (X axis)
  22801. * @param result defines the target matrix
  22802. */
  22803. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  22804. /**
  22805. * Creates a scaling matrix
  22806. * @param x defines the scale factor on X axis
  22807. * @param y defines the scale factor on Y axis
  22808. * @param z defines the scale factor on Z axis
  22809. * @returns the new matrix
  22810. */
  22811. static Scaling(x: number, y: number, z: number): Matrix;
  22812. /**
  22813. * Creates a scaling matrix and stores it in a given matrix
  22814. * @param x defines the scale factor on X axis
  22815. * @param y defines the scale factor on Y axis
  22816. * @param z defines the scale factor on Z axis
  22817. * @param result defines the target matrix
  22818. */
  22819. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  22820. /**
  22821. * Creates a translation matrix
  22822. * @param x defines the translation on X axis
  22823. * @param y defines the translation on Y axis
  22824. * @param z defines the translationon Z axis
  22825. * @returns the new matrix
  22826. */
  22827. static Translation(x: number, y: number, z: number): Matrix;
  22828. /**
  22829. * Creates a translation matrix and stores it in a given matrix
  22830. * @param x defines the translation on X axis
  22831. * @param y defines the translation on Y axis
  22832. * @param z defines the translationon Z axis
  22833. * @param result defines the target matrix
  22834. */
  22835. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  22836. /**
  22837. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  22838. * @param startValue defines the start value
  22839. * @param endValue defines the end value
  22840. * @param gradient defines the gradient factor
  22841. * @returns the new matrix
  22842. */
  22843. static Lerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  22844. /**
  22845. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  22846. * @param startValue defines the start value
  22847. * @param endValue defines the end value
  22848. * @param gradient defines the gradient factor
  22849. * @param result defines the Matrix object where to store data
  22850. */
  22851. static LerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void;
  22852. /**
  22853. * Builds a new matrix whose values are computed by:
  22854. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  22855. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  22856. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  22857. * @param startValue defines the first matrix
  22858. * @param endValue defines the second matrix
  22859. * @param gradient defines the gradient between the two matrices
  22860. * @returns the new matrix
  22861. */
  22862. static DecomposeLerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  22863. /**
  22864. * Update a matrix to values which are computed by:
  22865. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  22866. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  22867. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  22868. * @param startValue defines the first matrix
  22869. * @param endValue defines the second matrix
  22870. * @param gradient defines the gradient between the two matrices
  22871. * @param result defines the target matrix
  22872. */
  22873. static DecomposeLerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void;
  22874. /**
  22875. * 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"
  22876. * This function works in left handed mode
  22877. * @param eye defines the final position of the entity
  22878. * @param target defines where the entity should look at
  22879. * @param up defines the up vector for the entity
  22880. * @returns the new matrix
  22881. */
  22882. static LookAtLH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  22883. /**
  22884. * 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".
  22885. * This function works in left handed mode
  22886. * @param eye defines the final position of the entity
  22887. * @param target defines where the entity should look at
  22888. * @param up defines the up vector for the entity
  22889. * @param result defines the target matrix
  22890. */
  22891. static LookAtLHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  22892. /**
  22893. * 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"
  22894. * This function works in right handed mode
  22895. * @param eye defines the final position of the entity
  22896. * @param target defines where the entity should look at
  22897. * @param up defines the up vector for the entity
  22898. * @returns the new matrix
  22899. */
  22900. static LookAtRH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  22901. /**
  22902. * 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".
  22903. * This function works in right handed mode
  22904. * @param eye defines the final position of the entity
  22905. * @param target defines where the entity should look at
  22906. * @param up defines the up vector for the entity
  22907. * @param result defines the target matrix
  22908. */
  22909. static LookAtRHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  22910. /**
  22911. * Create a left-handed orthographic projection matrix
  22912. * @param width defines the viewport width
  22913. * @param height defines the viewport height
  22914. * @param znear defines the near clip plane
  22915. * @param zfar defines the far clip plane
  22916. * @returns a new matrix as a left-handed orthographic projection matrix
  22917. */
  22918. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  22919. /**
  22920. * Store a left-handed orthographic projection to a given matrix
  22921. * @param width defines the viewport width
  22922. * @param height defines the viewport height
  22923. * @param znear defines the near clip plane
  22924. * @param zfar defines the far clip plane
  22925. * @param result defines the target matrix
  22926. */
  22927. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  22928. /**
  22929. * Create a left-handed orthographic projection matrix
  22930. * @param left defines the viewport left coordinate
  22931. * @param right defines the viewport right coordinate
  22932. * @param bottom defines the viewport bottom coordinate
  22933. * @param top defines the viewport top coordinate
  22934. * @param znear defines the near clip plane
  22935. * @param zfar defines the far clip plane
  22936. * @returns a new matrix as a left-handed orthographic projection matrix
  22937. */
  22938. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  22939. /**
  22940. * Stores a left-handed orthographic projection into a given matrix
  22941. * @param left defines the viewport left coordinate
  22942. * @param right defines the viewport right coordinate
  22943. * @param bottom defines the viewport bottom coordinate
  22944. * @param top defines the viewport top coordinate
  22945. * @param znear defines the near clip plane
  22946. * @param zfar defines the far clip plane
  22947. * @param result defines the target matrix
  22948. */
  22949. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  22950. /**
  22951. * Creates a right-handed orthographic projection matrix
  22952. * @param left defines the viewport left coordinate
  22953. * @param right defines the viewport right coordinate
  22954. * @param bottom defines the viewport bottom coordinate
  22955. * @param top defines the viewport top coordinate
  22956. * @param znear defines the near clip plane
  22957. * @param zfar defines the far clip plane
  22958. * @returns a new matrix as a right-handed orthographic projection matrix
  22959. */
  22960. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  22961. /**
  22962. * Stores a right-handed orthographic projection into a given matrix
  22963. * @param left defines the viewport left coordinate
  22964. * @param right defines the viewport right coordinate
  22965. * @param bottom defines the viewport bottom coordinate
  22966. * @param top defines the viewport top coordinate
  22967. * @param znear defines the near clip plane
  22968. * @param zfar defines the far clip plane
  22969. * @param result defines the target matrix
  22970. */
  22971. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  22972. /**
  22973. * Creates a left-handed perspective projection matrix
  22974. * @param width defines the viewport width
  22975. * @param height defines the viewport height
  22976. * @param znear defines the near clip plane
  22977. * @param zfar defines the far clip plane
  22978. * @returns a new matrix as a left-handed perspective projection matrix
  22979. */
  22980. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  22981. /**
  22982. * Creates a left-handed perspective projection matrix
  22983. * @param fov defines the horizontal field of view
  22984. * @param aspect defines the aspect ratio
  22985. * @param znear defines the near clip plane
  22986. * @param zfar defines the far clip plane
  22987. * @returns a new matrix as a left-handed perspective projection matrix
  22988. */
  22989. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  22990. /**
  22991. * Stores a left-handed perspective projection into a given matrix
  22992. * @param fov defines the horizontal field of view
  22993. * @param aspect defines the aspect ratio
  22994. * @param znear defines the near clip plane
  22995. * @param zfar defines the far clip plane
  22996. * @param result defines the target matrix
  22997. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  22998. */
  22999. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  23000. /**
  23001. * Creates a right-handed perspective projection matrix
  23002. * @param fov defines the horizontal field of view
  23003. * @param aspect defines the aspect ratio
  23004. * @param znear defines the near clip plane
  23005. * @param zfar defines the far clip plane
  23006. * @returns a new matrix as a right-handed perspective projection matrix
  23007. */
  23008. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  23009. /**
  23010. * Stores a right-handed perspective projection into a given matrix
  23011. * @param fov defines the horizontal field of view
  23012. * @param aspect defines the aspect ratio
  23013. * @param znear defines the near clip plane
  23014. * @param zfar defines the far clip plane
  23015. * @param result defines the target matrix
  23016. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  23017. */
  23018. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  23019. /**
  23020. * Stores a perspective projection for WebVR info a given matrix
  23021. * @param fov defines the field of view
  23022. * @param znear defines the near clip plane
  23023. * @param zfar defines the far clip plane
  23024. * @param result defines the target matrix
  23025. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  23026. */
  23027. static PerspectiveFovWebVRToRef(fov: {
  23028. upDegrees: number;
  23029. downDegrees: number;
  23030. leftDegrees: number;
  23031. rightDegrees: number;
  23032. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  23033. /**
  23034. * Computes a complete transformation matrix
  23035. * @param viewport defines the viewport to use
  23036. * @param world defines the world matrix
  23037. * @param view defines the view matrix
  23038. * @param projection defines the projection matrix
  23039. * @param zmin defines the near clip plane
  23040. * @param zmax defines the far clip plane
  23041. * @returns the transformation matrix
  23042. */
  23043. static GetFinalMatrix(viewport: Viewport, world: Matrix, view: Matrix, projection: Matrix, zmin: number, zmax: number): Matrix;
  23044. /**
  23045. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  23046. * @param matrix defines the matrix to use
  23047. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  23048. */
  23049. static GetAsMatrix2x2(matrix: Matrix): Float32Array;
  23050. /**
  23051. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  23052. * @param matrix defines the matrix to use
  23053. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  23054. */
  23055. static GetAsMatrix3x3(matrix: Matrix): Float32Array;
  23056. /**
  23057. * Compute the transpose of a given matrix
  23058. * @param matrix defines the matrix to transpose
  23059. * @returns the new matrix
  23060. */
  23061. static Transpose(matrix: Matrix): Matrix;
  23062. /**
  23063. * Compute the transpose of a matrix and store it in a target matrix
  23064. * @param matrix defines the matrix to transpose
  23065. * @param result defines the target matrix
  23066. */
  23067. static TransposeToRef(matrix: Matrix, result: Matrix): void;
  23068. /**
  23069. * Computes a reflection matrix from a plane
  23070. * @param plane defines the reflection plane
  23071. * @returns a new matrix
  23072. */
  23073. static Reflection(plane: Plane): Matrix;
  23074. /**
  23075. * Computes a reflection matrix from a plane
  23076. * @param plane defines the reflection plane
  23077. * @param result defines the target matrix
  23078. */
  23079. static ReflectionToRef(plane: Plane, result: Matrix): void;
  23080. /**
  23081. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  23082. * @param xaxis defines the value of the 1st axis
  23083. * @param yaxis defines the value of the 2nd axis
  23084. * @param zaxis defines the value of the 3rd axis
  23085. * @param result defines the target matrix
  23086. */
  23087. static FromXYZAxesToRef(xaxis: Vector3, yaxis: Vector3, zaxis: Vector3, result: Matrix): void;
  23088. /**
  23089. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  23090. * @param quat defines the quaternion to use
  23091. * @param result defines the target matrix
  23092. */
  23093. static FromQuaternionToRef(quat: Quaternion, result: Matrix): void;
  23094. }
  23095. /**
  23096. * Represens a plane by the equation ax + by + cz + d = 0
  23097. */
  23098. class Plane {
  23099. /**
  23100. * Normal of the plane (a,b,c)
  23101. */
  23102. normal: Vector3;
  23103. /**
  23104. * d component of the plane
  23105. */
  23106. d: number;
  23107. /**
  23108. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  23109. * @param a a component of the plane
  23110. * @param b b component of the plane
  23111. * @param c c component of the plane
  23112. * @param d d component of the plane
  23113. */
  23114. constructor(a: number, b: number, c: number, d: number);
  23115. /**
  23116. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  23117. */
  23118. asArray(): number[];
  23119. /**
  23120. * @returns a new plane copied from the current Plane.
  23121. */
  23122. clone(): Plane;
  23123. /**
  23124. * @returns the string "Plane".
  23125. */
  23126. getClassName(): string;
  23127. /**
  23128. * @returns the Plane hash code.
  23129. */
  23130. getHashCode(): number;
  23131. /**
  23132. * Normalize the current Plane in place.
  23133. * @returns the updated Plane.
  23134. */
  23135. normalize(): Plane;
  23136. /**
  23137. * Applies a transformation the plane and returns the result
  23138. * @param transformation the transformation matrix to be applied to the plane
  23139. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  23140. */
  23141. transform(transformation: Matrix): Plane;
  23142. /**
  23143. * Calcualtte the dot product between the point and the plane normal
  23144. * @param point point to calculate the dot product with
  23145. * @returns the dot product (float) of the point coordinates and the plane normal.
  23146. */
  23147. dotCoordinate(point: Vector3): number;
  23148. /**
  23149. * Updates the current Plane from the plane defined by the three given points.
  23150. * @param point1 one of the points used to contruct the plane
  23151. * @param point2 one of the points used to contruct the plane
  23152. * @param point3 one of the points used to contruct the plane
  23153. * @returns the updated Plane.
  23154. */
  23155. copyFromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  23156. /**
  23157. * Checks if the plane is facing a given direction
  23158. * @param direction the direction to check if the plane is facing
  23159. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  23160. * @returns True is the vector "direction" is the same side than the plane normal.
  23161. */
  23162. isFrontFacingTo(direction: Vector3, epsilon: number): boolean;
  23163. /**
  23164. * Calculates the distance to a point
  23165. * @param point point to calculate distance to
  23166. * @returns the signed distance (float) from the given point to the Plane.
  23167. */
  23168. signedDistanceTo(point: Vector3): number;
  23169. /**
  23170. * Creates a plane from an array
  23171. * @param array the array to create a plane from
  23172. * @returns a new Plane from the given array.
  23173. */
  23174. static FromArray(array: ArrayLike<number>): Plane;
  23175. /**
  23176. * Creates a plane from three points
  23177. * @param point1 point used to create the plane
  23178. * @param point2 point used to create the plane
  23179. * @param point3 point used to create the plane
  23180. * @returns a new Plane defined by the three given points.
  23181. */
  23182. static FromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  23183. /**
  23184. * Creates a plane from an origin point and a normal
  23185. * @param origin origin of the plane to be constructed
  23186. * @param normal normal of the plane to be constructed
  23187. * @returns a new Plane the normal vector to this plane at the given origin point.
  23188. * Note : the vector "normal" is updated because normalized.
  23189. */
  23190. static FromPositionAndNormal(origin: Vector3, normal: Vector3): Plane;
  23191. /**
  23192. * Calculates the distance from a plane and a point
  23193. * @param origin origin of the plane to be constructed
  23194. * @param normal normal of the plane to be constructed
  23195. * @param point point to calculate distance to
  23196. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  23197. */
  23198. static SignedDistanceToPlaneFromPositionAndNormal(origin: Vector3, normal: Vector3, point: Vector3): number;
  23199. }
  23200. /**
  23201. * Class used to represent a viewport on screen
  23202. */
  23203. class Viewport {
  23204. /** viewport left coordinate */
  23205. x: number;
  23206. /** viewport top coordinate */
  23207. y: number;
  23208. /**viewport width */
  23209. width: number;
  23210. /** viewport height */
  23211. height: number;
  23212. /**
  23213. * Creates a Viewport object located at (x, y) and sized (width, height)
  23214. * @param x defines viewport left coordinate
  23215. * @param y defines viewport top coordinate
  23216. * @param width defines the viewport width
  23217. * @param height defines the viewport height
  23218. */
  23219. constructor(
  23220. /** viewport left coordinate */
  23221. x: number,
  23222. /** viewport top coordinate */
  23223. y: number,
  23224. /**viewport width */
  23225. width: number,
  23226. /** viewport height */
  23227. height: number);
  23228. /**
  23229. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  23230. * @param renderWidthOrEngine defines either an engine or the rendering width
  23231. * @param renderHeight defines the rendering height
  23232. * @returns a new Viewport
  23233. */
  23234. toGlobal(renderWidthOrEngine: number | Engine, renderHeight: number): Viewport;
  23235. /**
  23236. * Returns a new Viewport copied from the current one
  23237. * @returns a new Viewport
  23238. */
  23239. clone(): Viewport;
  23240. }
  23241. /**
  23242. * Reprasents a camera frustum
  23243. */
  23244. class Frustum {
  23245. /**
  23246. * Gets the planes representing the frustum
  23247. * @param transform matrix to be applied to the returned planes
  23248. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  23249. */
  23250. static GetPlanes(transform: Matrix): Plane[];
  23251. /**
  23252. * Gets the near frustum plane transformed by the transform matrix
  23253. * @param transform transformation matrix to be applied to the resulting frustum plane
  23254. * @param frustumPlane the resuling frustum plane
  23255. */
  23256. static GetNearPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  23257. /**
  23258. * Gets the far frustum plane transformed by the transform matrix
  23259. * @param transform transformation matrix to be applied to the resulting frustum plane
  23260. * @param frustumPlane the resuling frustum plane
  23261. */
  23262. static GetFarPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  23263. /**
  23264. * Gets the left frustum plane transformed by the transform matrix
  23265. * @param transform transformation matrix to be applied to the resulting frustum plane
  23266. * @param frustumPlane the resuling frustum plane
  23267. */
  23268. static GetLeftPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  23269. /**
  23270. * Gets the right frustum plane transformed by the transform matrix
  23271. * @param transform transformation matrix to be applied to the resulting frustum plane
  23272. * @param frustumPlane the resuling frustum plane
  23273. */
  23274. static GetRightPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  23275. /**
  23276. * Gets the top frustum plane transformed by the transform matrix
  23277. * @param transform transformation matrix to be applied to the resulting frustum plane
  23278. * @param frustumPlane the resuling frustum plane
  23279. */
  23280. static GetTopPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  23281. /**
  23282. * Gets the bottom frustum plane transformed by the transform matrix
  23283. * @param transform transformation matrix to be applied to the resulting frustum plane
  23284. * @param frustumPlane the resuling frustum plane
  23285. */
  23286. static GetBottomPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  23287. /**
  23288. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  23289. * @param transform transformation matrix to be applied to the resulting frustum planes
  23290. * @param frustumPlanes the resuling frustum planes
  23291. */
  23292. static GetPlanesToRef(transform: Matrix, frustumPlanes: Plane[]): void;
  23293. }
  23294. /** Defines supported spaces */
  23295. enum Space {
  23296. /** Local (object) space */
  23297. LOCAL = 0,
  23298. /** World space */
  23299. WORLD = 1,
  23300. /** Bone space */
  23301. BONE = 2
  23302. }
  23303. /** Defines the 3 main axes */
  23304. class Axis {
  23305. /** X axis */
  23306. static X: Vector3;
  23307. /** Y axis */
  23308. static Y: Vector3;
  23309. /** Z axis */
  23310. static Z: Vector3;
  23311. }
  23312. /** Class used to represent a Bezier curve */
  23313. class BezierCurve {
  23314. /**
  23315. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  23316. * @param t defines the time
  23317. * @param x1 defines the left coordinate on X axis
  23318. * @param y1 defines the left coordinate on Y axis
  23319. * @param x2 defines the right coordinate on X axis
  23320. * @param y2 defines the right coordinate on Y axis
  23321. * @returns the interpolated value
  23322. */
  23323. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  23324. }
  23325. /**
  23326. * Defines potential orientation for back face culling
  23327. */
  23328. enum Orientation {
  23329. /**
  23330. * Clockwise
  23331. */
  23332. CW = 0,
  23333. /** Counter clockwise */
  23334. CCW = 1
  23335. }
  23336. /**
  23337. * Defines angle representation
  23338. */
  23339. class Angle {
  23340. private _radians;
  23341. /**
  23342. * Creates an Angle object of "radians" radians (float).
  23343. */
  23344. constructor(radians: number);
  23345. /**
  23346. * Get value in degrees
  23347. * @returns the Angle value in degrees (float)
  23348. */
  23349. degrees(): number;
  23350. /**
  23351. * Get value in radians
  23352. * @returns the Angle value in radians (float)
  23353. */
  23354. radians(): number;
  23355. /**
  23356. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  23357. * @param a defines first vector
  23358. * @param b defines second vector
  23359. * @returns a new Angle
  23360. */
  23361. static BetweenTwoPoints(a: Vector2, b: Vector2): Angle;
  23362. /**
  23363. * Gets a new Angle object from the given float in radians
  23364. * @param radians defines the angle value in radians
  23365. * @returns a new Angle
  23366. */
  23367. static FromRadians(radians: number): Angle;
  23368. /**
  23369. * Gets a new Angle object from the given float in degrees
  23370. * @param degrees defines the angle value in degrees
  23371. * @returns a new Angle
  23372. */
  23373. static FromDegrees(degrees: number): Angle;
  23374. }
  23375. /**
  23376. * This represents an arc in a 2d space.
  23377. */
  23378. class Arc2 {
  23379. /** Defines the start point of the arc */
  23380. startPoint: Vector2;
  23381. /** Defines the mid point of the arc */
  23382. midPoint: Vector2;
  23383. /** Defines the end point of the arc */
  23384. endPoint: Vector2;
  23385. /**
  23386. * Defines the center point of the arc.
  23387. */
  23388. centerPoint: Vector2;
  23389. /**
  23390. * Defines the radius of the arc.
  23391. */
  23392. radius: number;
  23393. /**
  23394. * Defines the angle of the arc (from mid point to end point).
  23395. */
  23396. angle: Angle;
  23397. /**
  23398. * Defines the start angle of the arc (from start point to middle point).
  23399. */
  23400. startAngle: Angle;
  23401. /**
  23402. * Defines the orientation of the arc (clock wise/counter clock wise).
  23403. */
  23404. orientation: Orientation;
  23405. /**
  23406. * Creates an Arc object from the three given points : start, middle and end.
  23407. * @param startPoint Defines the start point of the arc
  23408. * @param midPoint Defines the midlle point of the arc
  23409. * @param endPoint Defines the end point of the arc
  23410. */
  23411. constructor(
  23412. /** Defines the start point of the arc */
  23413. startPoint: Vector2,
  23414. /** Defines the mid point of the arc */
  23415. midPoint: Vector2,
  23416. /** Defines the end point of the arc */
  23417. endPoint: Vector2);
  23418. }
  23419. /**
  23420. * Represents a 2D path made up of multiple 2D points
  23421. */
  23422. class Path2 {
  23423. private _points;
  23424. private _length;
  23425. /**
  23426. * If the path start and end point are the same
  23427. */
  23428. closed: boolean;
  23429. /**
  23430. * Creates a Path2 object from the starting 2D coordinates x and y.
  23431. * @param x the starting points x value
  23432. * @param y the starting points y value
  23433. */
  23434. constructor(x: number, y: number);
  23435. /**
  23436. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  23437. * @param x the added points x value
  23438. * @param y the added points y value
  23439. * @returns the updated Path2.
  23440. */
  23441. addLineTo(x: number, y: number): Path2;
  23442. /**
  23443. * 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.
  23444. * @param midX middle point x value
  23445. * @param midY middle point y value
  23446. * @param endX end point x value
  23447. * @param endY end point y value
  23448. * @param numberOfSegments (default: 36)
  23449. * @returns the updated Path2.
  23450. */
  23451. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  23452. /**
  23453. * Closes the Path2.
  23454. * @returns the Path2.
  23455. */
  23456. close(): Path2;
  23457. /**
  23458. * Gets the sum of the distance between each sequential point in the path
  23459. * @returns the Path2 total length (float).
  23460. */
  23461. length(): number;
  23462. /**
  23463. * Gets the points which construct the path
  23464. * @returns the Path2 internal array of points.
  23465. */
  23466. getPoints(): Vector2[];
  23467. /**
  23468. * Retreives the point at the distance aways from the starting point
  23469. * @param normalizedLengthPosition the length along the path to retreive the point from
  23470. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  23471. */
  23472. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  23473. /**
  23474. * Creates a new path starting from an x and y position
  23475. * @param x starting x value
  23476. * @param y starting y value
  23477. * @returns a new Path2 starting at the coordinates (x, y).
  23478. */
  23479. static StartingAt(x: number, y: number): Path2;
  23480. }
  23481. /**
  23482. * Represents a 3D path made up of multiple 3D points
  23483. */
  23484. class Path3D {
  23485. /**
  23486. * an array of Vector3, the curve axis of the Path3D
  23487. */
  23488. path: Vector3[];
  23489. private _curve;
  23490. private _distances;
  23491. private _tangents;
  23492. private _normals;
  23493. private _binormals;
  23494. private _raw;
  23495. /**
  23496. * new Path3D(path, normal, raw)
  23497. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  23498. * please read the description in the tutorial : http://doc.babylonjs.com/tutorials/How_to_use_Path3D
  23499. * @param path an array of Vector3, the curve axis of the Path3D
  23500. * @param normal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  23501. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  23502. */
  23503. constructor(
  23504. /**
  23505. * an array of Vector3, the curve axis of the Path3D
  23506. */
  23507. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  23508. /**
  23509. * Returns the Path3D array of successive Vector3 designing its curve.
  23510. * @returns the Path3D array of successive Vector3 designing its curve.
  23511. */
  23512. getCurve(): Vector3[];
  23513. /**
  23514. * Returns an array populated with tangent vectors on each Path3D curve point.
  23515. * @returns an array populated with tangent vectors on each Path3D curve point.
  23516. */
  23517. getTangents(): Vector3[];
  23518. /**
  23519. * Returns an array populated with normal vectors on each Path3D curve point.
  23520. * @returns an array populated with normal vectors on each Path3D curve point.
  23521. */
  23522. getNormals(): Vector3[];
  23523. /**
  23524. * Returns an array populated with binormal vectors on each Path3D curve point.
  23525. * @returns an array populated with binormal vectors on each Path3D curve point.
  23526. */
  23527. getBinormals(): Vector3[];
  23528. /**
  23529. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  23530. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  23531. */
  23532. getDistances(): number[];
  23533. /**
  23534. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  23535. * @param path path which all values are copied into the curves points
  23536. * @param firstNormal which should be projected onto the curve
  23537. * @returns the same object updated.
  23538. */
  23539. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  23540. private _compute;
  23541. private _getFirstNonNullVector;
  23542. private _getLastNonNullVector;
  23543. private _normalVector;
  23544. }
  23545. /**
  23546. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  23547. * A Curve3 is designed from a series of successive Vector3.
  23548. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  23549. */
  23550. class Curve3 {
  23551. private _points;
  23552. private _length;
  23553. /**
  23554. * Returns a Curve3 object along a Quadratic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#quadratic-bezier-curve
  23555. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  23556. * @param v1 (Vector3) the control point
  23557. * @param v2 (Vector3) the end point of the Quadratic Bezier
  23558. * @param nbPoints (integer) the wanted number of points in the curve
  23559. * @returns the created Curve3
  23560. */
  23561. static CreateQuadraticBezier(v0: Vector3, v1: Vector3, v2: Vector3, nbPoints: number): Curve3;
  23562. /**
  23563. * Returns a Curve3 object along a Cubic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#cubic-bezier-curve
  23564. * @param v0 (Vector3) the origin point of the Cubic Bezier
  23565. * @param v1 (Vector3) the first control point
  23566. * @param v2 (Vector3) the second control point
  23567. * @param v3 (Vector3) the end point of the Cubic Bezier
  23568. * @param nbPoints (integer) the wanted number of points in the curve
  23569. * @returns the created Curve3
  23570. */
  23571. static CreateCubicBezier(v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, nbPoints: number): Curve3;
  23572. /**
  23573. * Returns a Curve3 object along a Hermite Spline curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#hermite-spline
  23574. * @param p1 (Vector3) the origin point of the Hermite Spline
  23575. * @param t1 (Vector3) the tangent vector at the origin point
  23576. * @param p2 (Vector3) the end point of the Hermite Spline
  23577. * @param t2 (Vector3) the tangent vector at the end point
  23578. * @param nbPoints (integer) the wanted number of points in the curve
  23579. * @returns the created Curve3
  23580. */
  23581. static CreateHermiteSpline(p1: Vector3, t1: Vector3, p2: Vector3, t2: Vector3, nbPoints: number): Curve3;
  23582. /**
  23583. * Returns a Curve3 object along a CatmullRom Spline curve :
  23584. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  23585. * @param nbPoints (integer) the wanted number of points between each curve control points
  23586. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  23587. * @returns the created Curve3
  23588. */
  23589. static CreateCatmullRomSpline(points: Vector3[], nbPoints: number, closed?: boolean): Curve3;
  23590. /**
  23591. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  23592. * A Curve3 is designed from a series of successive Vector3.
  23593. * Tuto : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#curve3-object
  23594. * @param points points which make up the curve
  23595. */
  23596. constructor(points: Vector3[]);
  23597. /**
  23598. * @returns the Curve3 stored array of successive Vector3
  23599. */
  23600. getPoints(): Vector3[];
  23601. /**
  23602. * @returns the computed length (float) of the curve.
  23603. */
  23604. length(): number;
  23605. /**
  23606. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  23607. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  23608. * curveA and curveB keep unchanged.
  23609. * @param curve the curve to continue from this curve
  23610. * @returns the newly constructed curve
  23611. */
  23612. continue(curve: Curve3): Curve3;
  23613. private _computeLength;
  23614. }
  23615. /**
  23616. * Contains position and normal vectors for a vertex
  23617. */
  23618. class PositionNormalVertex {
  23619. /** the position of the vertex (defaut: 0,0,0) */
  23620. position: Vector3;
  23621. /** the normal of the vertex (defaut: 0,1,0) */
  23622. normal: Vector3;
  23623. /**
  23624. * Creates a PositionNormalVertex
  23625. * @param position the position of the vertex (defaut: 0,0,0)
  23626. * @param normal the normal of the vertex (defaut: 0,1,0)
  23627. */
  23628. constructor(
  23629. /** the position of the vertex (defaut: 0,0,0) */
  23630. position?: Vector3,
  23631. /** the normal of the vertex (defaut: 0,1,0) */
  23632. normal?: Vector3);
  23633. /**
  23634. * Clones the PositionNormalVertex
  23635. * @returns the cloned PositionNormalVertex
  23636. */
  23637. clone(): PositionNormalVertex;
  23638. }
  23639. /**
  23640. * Contains position, normal and uv vectors for a vertex
  23641. */
  23642. class PositionNormalTextureVertex {
  23643. /** the position of the vertex (defaut: 0,0,0) */
  23644. position: Vector3;
  23645. /** the normal of the vertex (defaut: 0,1,0) */
  23646. normal: Vector3;
  23647. /** the uv of the vertex (default: 0,0) */
  23648. uv: Vector2;
  23649. /**
  23650. * Creates a PositionNormalTextureVertex
  23651. * @param position the position of the vertex (defaut: 0,0,0)
  23652. * @param normal the normal of the vertex (defaut: 0,1,0)
  23653. * @param uv the uv of the vertex (default: 0,0)
  23654. */
  23655. constructor(
  23656. /** the position of the vertex (defaut: 0,0,0) */
  23657. position?: Vector3,
  23658. /** the normal of the vertex (defaut: 0,1,0) */
  23659. normal?: Vector3,
  23660. /** the uv of the vertex (default: 0,0) */
  23661. uv?: Vector2);
  23662. /**
  23663. * Clones the PositionNormalTextureVertex
  23664. * @returns the cloned PositionNormalTextureVertex
  23665. */
  23666. clone(): PositionNormalTextureVertex;
  23667. }
  23668. /**
  23669. * @hidden
  23670. */
  23671. class Tmp {
  23672. static Color3: Color3[];
  23673. static Color4: Color4[];
  23674. static Vector2: Vector2[];
  23675. static Vector3: Vector3[];
  23676. static Vector4: Vector4[];
  23677. static Quaternion: Quaternion[];
  23678. static Matrix: Matrix[];
  23679. }
  23680. }
  23681. declare module BABYLON {
  23682. /**
  23683. * Class representing spherical polynomial coefficients to the 3rd degree
  23684. */
  23685. class SphericalPolynomial {
  23686. /**
  23687. * The x coefficients of the spherical polynomial
  23688. */
  23689. x: Vector3;
  23690. /**
  23691. * The y coefficients of the spherical polynomial
  23692. */
  23693. y: Vector3;
  23694. /**
  23695. * The z coefficients of the spherical polynomial
  23696. */
  23697. z: Vector3;
  23698. /**
  23699. * The xx coefficients of the spherical polynomial
  23700. */
  23701. xx: Vector3;
  23702. /**
  23703. * The yy coefficients of the spherical polynomial
  23704. */
  23705. yy: Vector3;
  23706. /**
  23707. * The zz coefficients of the spherical polynomial
  23708. */
  23709. zz: Vector3;
  23710. /**
  23711. * The xy coefficients of the spherical polynomial
  23712. */
  23713. xy: Vector3;
  23714. /**
  23715. * The yz coefficients of the spherical polynomial
  23716. */
  23717. yz: Vector3;
  23718. /**
  23719. * The zx coefficients of the spherical polynomial
  23720. */
  23721. zx: Vector3;
  23722. /**
  23723. * Adds an ambient color to the spherical polynomial
  23724. * @param color the color to add
  23725. */
  23726. addAmbient(color: Color3): void;
  23727. /**
  23728. * Scales the spherical polynomial by the given amount
  23729. * @param scale the amount to scale
  23730. */
  23731. scale(scale: number): void;
  23732. /**
  23733. * Gets the spherical polynomial from harmonics
  23734. * @param harmonics the spherical harmonics
  23735. * @returns the spherical polynomial
  23736. */
  23737. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  23738. /**
  23739. * Constructs a spherical polynomial from an array.
  23740. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  23741. * @returns the spherical polynomial
  23742. */
  23743. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  23744. }
  23745. /**
  23746. * Class representing spherical harmonics coefficients to the 3rd degree
  23747. */
  23748. class SphericalHarmonics {
  23749. /**
  23750. * The l0,0 coefficients of the spherical harmonics
  23751. */
  23752. l00: Vector3;
  23753. /**
  23754. * The l1,-1 coefficients of the spherical harmonics
  23755. */
  23756. l1_1: Vector3;
  23757. /**
  23758. * The l1,0 coefficients of the spherical harmonics
  23759. */
  23760. l10: Vector3;
  23761. /**
  23762. * The l1,1 coefficients of the spherical harmonics
  23763. */
  23764. l11: Vector3;
  23765. /**
  23766. * The l2,-2 coefficients of the spherical harmonics
  23767. */
  23768. l2_2: Vector3;
  23769. /**
  23770. * The l2,-1 coefficients of the spherical harmonics
  23771. */
  23772. l2_1: Vector3;
  23773. /**
  23774. * The l2,0 coefficients of the spherical harmonics
  23775. */
  23776. l20: Vector3;
  23777. /**
  23778. * The l2,1 coefficients of the spherical harmonics
  23779. */
  23780. l21: Vector3;
  23781. /**
  23782. * The l2,2 coefficients of the spherical harmonics
  23783. */
  23784. lL22: Vector3;
  23785. /**
  23786. * Adds a light to the spherical harmonics
  23787. * @param direction the direction of the light
  23788. * @param color the color of the light
  23789. * @param deltaSolidAngle the delta solid angle of the light
  23790. */
  23791. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  23792. /**
  23793. * Scales the spherical harmonics by the given amount
  23794. * @param scale the amount to scale
  23795. */
  23796. scale(scale: number): void;
  23797. /**
  23798. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  23799. *
  23800. * ```
  23801. * E_lm = A_l * L_lm
  23802. * ```
  23803. *
  23804. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  23805. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  23806. * the scaling factors are given in equation 9.
  23807. */
  23808. convertIncidentRadianceToIrradiance(): void;
  23809. /**
  23810. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  23811. *
  23812. * ```
  23813. * L = (1/pi) * E * rho
  23814. * ```
  23815. *
  23816. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  23817. */
  23818. convertIrradianceToLambertianRadiance(): void;
  23819. /**
  23820. * Gets the spherical harmonics from polynomial
  23821. * @param polynomial the spherical polynomial
  23822. * @returns the spherical harmonics
  23823. */
  23824. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  23825. /**
  23826. * Constructs a spherical harmonics from an array.
  23827. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  23828. * @returns the spherical harmonics
  23829. */
  23830. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  23831. }
  23832. }
  23833. declare module BABYLON {
  23834. /**
  23835. * Class used to store all common mesh properties
  23836. */
  23837. class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  23838. /** No occlusion */
  23839. static OCCLUSION_TYPE_NONE: number;
  23840. /** Occlusion set to optimisitic */
  23841. static OCCLUSION_TYPE_OPTIMISTIC: number;
  23842. /** Occlusion set to strict */
  23843. static OCCLUSION_TYPE_STRICT: number;
  23844. /** Use an accurante occlusion algorithm */
  23845. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  23846. /** Use a conservative occlusion algorithm */
  23847. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  23848. /** Default culling strategy with bounding box and bounding sphere and then frustum culling */
  23849. static readonly CULLINGSTRATEGY_STANDARD: number;
  23850. /** Culling strategy with bounding sphere only and then frustum culling */
  23851. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  23852. /**
  23853. * No billboard
  23854. */
  23855. static readonly BILLBOARDMODE_NONE: number;
  23856. /** Billboard on X axis */
  23857. static readonly BILLBOARDMODE_X: number;
  23858. /** Billboard on Y axis */
  23859. static readonly BILLBOARDMODE_Y: number;
  23860. /** Billboard on Z axis */
  23861. static readonly BILLBOARDMODE_Z: number;
  23862. /** Billboard on all axes */
  23863. static readonly BILLBOARDMODE_ALL: number;
  23864. private _facetData;
  23865. /** Gets ot sets the culling strategy to use to find visible meshes */
  23866. cullingStrategy: number;
  23867. /**
  23868. * Gets the number of facets in the mesh
  23869. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  23870. */
  23871. readonly facetNb: number;
  23872. /**
  23873. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  23874. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  23875. */
  23876. partitioningSubdivisions: number;
  23877. /**
  23878. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  23879. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  23880. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  23881. */
  23882. partitioningBBoxRatio: number;
  23883. /**
  23884. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  23885. * Works only for updatable meshes.
  23886. * Doesn't work with multi-materials
  23887. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  23888. */
  23889. mustDepthSortFacets: boolean;
  23890. /**
  23891. * The location (Vector3) where the facet depth sort must be computed from.
  23892. * By default, the active camera position.
  23893. * Used only when facet depth sort is enabled
  23894. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  23895. */
  23896. facetDepthSortFrom: Vector3;
  23897. /**
  23898. * gets a boolean indicating if facetData is enabled
  23899. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  23900. */
  23901. readonly isFacetDataEnabled: boolean;
  23902. /** @hidden */
  23903. _updateNonUniformScalingState(value: boolean): boolean;
  23904. /**
  23905. * An event triggered when this mesh collides with another one
  23906. */
  23907. onCollideObservable: Observable<AbstractMesh>;
  23908. private _onCollideObserver;
  23909. /** Set a function to call when this mesh collides with another one */
  23910. onCollide: () => void;
  23911. /**
  23912. * An event triggered when the collision's position changes
  23913. */
  23914. onCollisionPositionChangeObservable: Observable<Vector3>;
  23915. private _onCollisionPositionChangeObserver;
  23916. /** Set a function to call when the collision's position changes */
  23917. onCollisionPositionChange: () => void;
  23918. /**
  23919. * An event triggered when material is changed
  23920. */
  23921. onMaterialChangedObservable: Observable<AbstractMesh>;
  23922. /**
  23923. * Gets or sets the orientation for POV movement & rotation
  23924. */
  23925. definedFacingForward: boolean;
  23926. /** @hidden */
  23927. _occlusionQuery: Nullable<WebGLQuery>;
  23928. private _visibility;
  23929. /**
  23930. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  23931. */
  23932. /**
  23933. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  23934. */
  23935. visibility: number;
  23936. /** Gets or sets the alpha index used to sort transparent meshes
  23937. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  23938. */
  23939. alphaIndex: number;
  23940. /**
  23941. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  23942. */
  23943. isVisible: boolean;
  23944. /**
  23945. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  23946. */
  23947. isPickable: boolean;
  23948. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  23949. showSubMeshesBoundingBox: boolean;
  23950. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  23951. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  23952. */
  23953. isBlocker: boolean;
  23954. /**
  23955. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  23956. */
  23957. enablePointerMoveEvents: boolean;
  23958. /**
  23959. * Specifies the rendering group id for this mesh (0 by default)
  23960. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  23961. */
  23962. renderingGroupId: number;
  23963. private _material;
  23964. /** Gets or sets current material */
  23965. material: Nullable<Material>;
  23966. private _receiveShadows;
  23967. /**
  23968. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  23969. * @see http://doc.babylonjs.com/babylon101/shadows
  23970. */
  23971. receiveShadows: boolean;
  23972. /** Defines color to use when rendering outline */
  23973. outlineColor: Color3;
  23974. /** Define width to use when rendering outline */
  23975. outlineWidth: number;
  23976. /** Defines color to use when rendering overlay */
  23977. overlayColor: Color3;
  23978. /** Defines alpha to use when rendering overlay */
  23979. overlayAlpha: number;
  23980. private _hasVertexAlpha;
  23981. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  23982. hasVertexAlpha: boolean;
  23983. private _useVertexColors;
  23984. /** 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) */
  23985. useVertexColors: boolean;
  23986. private _computeBonesUsingShaders;
  23987. /**
  23988. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  23989. */
  23990. computeBonesUsingShaders: boolean;
  23991. private _numBoneInfluencers;
  23992. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  23993. numBoneInfluencers: number;
  23994. private _applyFog;
  23995. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  23996. applyFog: boolean;
  23997. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  23998. useOctreeForRenderingSelection: boolean;
  23999. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  24000. useOctreeForPicking: boolean;
  24001. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  24002. useOctreeForCollisions: boolean;
  24003. private _layerMask;
  24004. /**
  24005. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  24006. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  24007. */
  24008. layerMask: number;
  24009. /**
  24010. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  24011. */
  24012. alwaysSelectAsActiveMesh: boolean;
  24013. /**
  24014. * Gets or sets the current action manager
  24015. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24016. */
  24017. actionManager: Nullable<ActionManager>;
  24018. private _checkCollisions;
  24019. private _collisionMask;
  24020. private _collisionGroup;
  24021. /**
  24022. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  24023. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24024. */
  24025. ellipsoid: Vector3;
  24026. /**
  24027. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  24028. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24029. */
  24030. ellipsoidOffset: Vector3;
  24031. private _collider;
  24032. private _oldPositionForCollisions;
  24033. private _diffPositionForCollisions;
  24034. /**
  24035. * Gets or sets a collision mask used to mask collisions (default is -1).
  24036. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24037. */
  24038. collisionMask: number;
  24039. /**
  24040. * Gets or sets the current collision group mask (-1 by default).
  24041. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24042. */
  24043. collisionGroup: number;
  24044. /**
  24045. * Defines edge width used when edgesRenderer is enabled
  24046. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24047. */
  24048. edgesWidth: number;
  24049. /**
  24050. * Defines edge color used when edgesRenderer is enabled
  24051. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24052. */
  24053. edgesColor: Color4;
  24054. /** @hidden */
  24055. _edgesRenderer: Nullable<IEdgesRenderer>;
  24056. /** @hidden */
  24057. _masterMesh: Nullable<AbstractMesh>;
  24058. /** @hidden */
  24059. _boundingInfo: Nullable<BoundingInfo>;
  24060. /** @hidden */
  24061. _renderId: number;
  24062. /**
  24063. * Gets or sets the list of subMeshes
  24064. * @see http://doc.babylonjs.com/how_to/multi_materials
  24065. */
  24066. subMeshes: SubMesh[];
  24067. /** @hidden */
  24068. _intersectionsInProgress: AbstractMesh[];
  24069. /** @hidden */
  24070. _unIndexed: boolean;
  24071. /** @hidden */
  24072. _lightSources: Light[];
  24073. /** @hidden */
  24074. readonly _positions: Nullable<Vector3[]>;
  24075. /** @hidden */
  24076. _waitingActions: any;
  24077. /** @hidden */
  24078. _waitingFreezeWorldMatrix: Nullable<boolean>;
  24079. private _skeleton;
  24080. /** @hidden */
  24081. _bonesTransformMatrices: Nullable<Float32Array>;
  24082. /**
  24083. * Gets or sets a skeleton to apply skining transformations
  24084. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24085. */
  24086. skeleton: Nullable<Skeleton>;
  24087. /**
  24088. * An event triggered when the mesh is rebuilt.
  24089. */
  24090. onRebuildObservable: Observable<AbstractMesh>;
  24091. /**
  24092. * Creates a new AbstractMesh
  24093. * @param name defines the name of the mesh
  24094. * @param scene defines the hosting scene
  24095. */
  24096. constructor(name: string, scene?: Nullable<Scene>);
  24097. /**
  24098. * Returns the string "AbstractMesh"
  24099. * @returns "AbstractMesh"
  24100. */
  24101. getClassName(): string;
  24102. /**
  24103. * Gets a string representation of the current mesh
  24104. * @param fullDetails defines a boolean indicating if full details must be included
  24105. * @returns a string representation of the current mesh
  24106. */
  24107. toString(fullDetails?: boolean): string;
  24108. /** @hidden */
  24109. _rebuild(): void;
  24110. /** @hidden */
  24111. _resyncLightSources(): void;
  24112. /** @hidden */
  24113. _resyncLighSource(light: Light): void;
  24114. /** @hidden */
  24115. _unBindEffect(): void;
  24116. /** @hidden */
  24117. _removeLightSource(light: Light): void;
  24118. private _markSubMeshesAsDirty;
  24119. /** @hidden */
  24120. _markSubMeshesAsLightDirty(): void;
  24121. /** @hidden */
  24122. _markSubMeshesAsAttributesDirty(): void;
  24123. /** @hidden */
  24124. _markSubMeshesAsMiscDirty(): void;
  24125. /**
  24126. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  24127. */
  24128. scaling: Vector3;
  24129. /**
  24130. * Returns true if the mesh is blocked. Implemented by child classes
  24131. */
  24132. readonly isBlocked: boolean;
  24133. /**
  24134. * Returns the mesh itself by default. Implemented by child classes
  24135. * @param camera defines the camera to use to pick the right LOD level
  24136. * @returns the currentAbstractMesh
  24137. */
  24138. getLOD(camera: Camera): Nullable<AbstractMesh>;
  24139. /**
  24140. * Returns 0 by default. Implemented by child classes
  24141. * @returns an integer
  24142. */
  24143. getTotalVertices(): number;
  24144. /**
  24145. * Returns null by default. Implemented by child classes
  24146. * @returns null
  24147. */
  24148. getIndices(): Nullable<IndicesArray>;
  24149. /**
  24150. * Returns the array of the requested vertex data kind. Implemented by child classes
  24151. * @param kind defines the vertex data kind to use
  24152. * @returns null
  24153. */
  24154. getVerticesData(kind: string): Nullable<FloatArray>;
  24155. /**
  24156. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24157. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24158. * Note that a new underlying VertexBuffer object is created each call.
  24159. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24160. * @param kind defines vertex data kind:
  24161. * * BABYLON.VertexBuffer.PositionKind
  24162. * * BABYLON.VertexBuffer.UVKind
  24163. * * BABYLON.VertexBuffer.UV2Kind
  24164. * * BABYLON.VertexBuffer.UV3Kind
  24165. * * BABYLON.VertexBuffer.UV4Kind
  24166. * * BABYLON.VertexBuffer.UV5Kind
  24167. * * BABYLON.VertexBuffer.UV6Kind
  24168. * * BABYLON.VertexBuffer.ColorKind
  24169. * * BABYLON.VertexBuffer.MatricesIndicesKind
  24170. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  24171. * * BABYLON.VertexBuffer.MatricesWeightsKind
  24172. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  24173. * @param data defines the data source
  24174. * @param updatable defines if the data must be flagged as updatable (or static)
  24175. * @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
  24176. * @returns the current mesh
  24177. */
  24178. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24179. /**
  24180. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  24181. * If the mesh has no geometry, it is simply returned as it is.
  24182. * @param kind defines vertex data kind:
  24183. * * BABYLON.VertexBuffer.PositionKind
  24184. * * BABYLON.VertexBuffer.UVKind
  24185. * * BABYLON.VertexBuffer.UV2Kind
  24186. * * BABYLON.VertexBuffer.UV3Kind
  24187. * * BABYLON.VertexBuffer.UV4Kind
  24188. * * BABYLON.VertexBuffer.UV5Kind
  24189. * * BABYLON.VertexBuffer.UV6Kind
  24190. * * BABYLON.VertexBuffer.ColorKind
  24191. * * BABYLON.VertexBuffer.MatricesIndicesKind
  24192. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  24193. * * BABYLON.VertexBuffer.MatricesWeightsKind
  24194. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  24195. * @param data defines the data source
  24196. * @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
  24197. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  24198. * @returns the current mesh
  24199. */
  24200. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24201. /**
  24202. * Sets the mesh indices,
  24203. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  24204. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  24205. * @param totalVertices Defines the total number of vertices
  24206. * @returns the current mesh
  24207. */
  24208. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  24209. /**
  24210. * Gets a boolean indicating if specific vertex data is present
  24211. * @param kind defines the vertex data kind to use
  24212. * @returns true is data kind is present
  24213. */
  24214. isVerticesDataPresent(kind: string): boolean;
  24215. /**
  24216. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  24217. * @returns a BoundingInfo
  24218. */
  24219. getBoundingInfo(): BoundingInfo;
  24220. /**
  24221. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  24222. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  24223. * @returns the current mesh
  24224. */
  24225. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  24226. /**
  24227. * Overwrite the current bounding info
  24228. * @param boundingInfo defines the new bounding info
  24229. * @returns the current mesh
  24230. */
  24231. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  24232. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  24233. readonly useBones: boolean;
  24234. /** @hidden */
  24235. _preActivate(): void;
  24236. /** @hidden */
  24237. _preActivateForIntermediateRendering(renderId: number): void;
  24238. /** @hidden */
  24239. _activate(renderId: number): void;
  24240. /**
  24241. * Gets the current world matrix
  24242. * @returns a Matrix
  24243. */
  24244. getWorldMatrix(): Matrix;
  24245. /** @hidden */
  24246. _getWorldMatrixDeterminant(): number;
  24247. /**
  24248. * Perform relative position change from the point of view of behind the front of the mesh.
  24249. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24250. * Supports definition of mesh facing forward or backward
  24251. * @param amountRight defines the distance on the right axis
  24252. * @param amountUp defines the distance on the up axis
  24253. * @param amountForward defines the distance on the forward axis
  24254. * @returns the current mesh
  24255. */
  24256. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  24257. /**
  24258. * Calculate relative position change from the point of view of behind the front of the mesh.
  24259. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24260. * Supports definition of mesh facing forward or backward
  24261. * @param amountRight defines the distance on the right axis
  24262. * @param amountUp defines the distance on the up axis
  24263. * @param amountForward defines the distance on the forward axis
  24264. * @returns the new displacement vector
  24265. */
  24266. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  24267. /**
  24268. * Perform relative rotation change from the point of view of behind the front of the mesh.
  24269. * Supports definition of mesh facing forward or backward
  24270. * @param flipBack defines the flip
  24271. * @param twirlClockwise defines the twirl
  24272. * @param tiltRight defines the tilt
  24273. * @returns the current mesh
  24274. */
  24275. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  24276. /**
  24277. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  24278. * Supports definition of mesh facing forward or backward.
  24279. * @param flipBack defines the flip
  24280. * @param twirlClockwise defines the twirl
  24281. * @param tiltRight defines the tilt
  24282. * @returns the new rotation vector
  24283. */
  24284. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  24285. /**
  24286. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  24287. * @param includeDescendants Include bounding info from descendants as well (true by default)
  24288. * @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
  24289. * @returns the new bounding vectors
  24290. */
  24291. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  24292. min: Vector3;
  24293. max: Vector3;
  24294. };
  24295. /** @hidden */
  24296. _updateBoundingInfo(): AbstractMesh;
  24297. /** @hidden */
  24298. _updateSubMeshesBoundingInfo(matrix: Matrix): AbstractMesh;
  24299. /** @hidden */
  24300. protected _afterComputeWorldMatrix(): void;
  24301. /**
  24302. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24303. * A mesh is in the frustum if its bounding box intersects the frustum
  24304. * @param frustumPlanes defines the frustum to test
  24305. * @returns true if the mesh is in the frustum planes
  24306. */
  24307. isInFrustum(frustumPlanes: Plane[]): boolean;
  24308. /**
  24309. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  24310. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  24311. * @param frustumPlanes defines the frustum to test
  24312. * @returns true if the mesh is completely in the frustum planes
  24313. */
  24314. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24315. /**
  24316. * True if the mesh intersects another mesh or a SolidParticle object
  24317. * @param mesh defines a target mesh or SolidParticle to test
  24318. * @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)
  24319. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  24320. * @returns true if there is an intersection
  24321. */
  24322. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  24323. /**
  24324. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  24325. * @param point defines the point to test
  24326. * @returns true if there is an intersection
  24327. */
  24328. intersectsPoint(point: Vector3): boolean;
  24329. /**
  24330. * Gets the position of the current mesh in camera space
  24331. * @param camera defines the camera to use
  24332. * @returns a position
  24333. */
  24334. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  24335. /**
  24336. * Returns the distance from the mesh to the active camera
  24337. * @param camera defines the camera to use
  24338. * @returns the distance
  24339. */
  24340. getDistanceToCamera(camera?: Nullable<Camera>): number;
  24341. /**
  24342. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  24343. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24344. */
  24345. checkCollisions: boolean;
  24346. /**
  24347. * Gets Collider object used to compute collisions (not physics)
  24348. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24349. */
  24350. readonly collider: Collider;
  24351. /**
  24352. * Move the mesh using collision engine
  24353. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24354. * @param displacement defines the requested displacement vector
  24355. * @returns the current mesh
  24356. */
  24357. moveWithCollisions(displacement: Vector3): AbstractMesh;
  24358. private _onCollisionPositionChange;
  24359. /** @hidden */
  24360. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  24361. /** @hidden */
  24362. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  24363. /** @hidden */
  24364. _checkCollision(collider: Collider): AbstractMesh;
  24365. /** @hidden */
  24366. _generatePointsArray(): boolean;
  24367. /**
  24368. * Checks if the passed Ray intersects with the mesh
  24369. * @param ray defines the ray to use
  24370. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  24371. * @returns the picking info
  24372. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  24373. */
  24374. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  24375. /**
  24376. * Clones the current mesh
  24377. * @param name defines the mesh name
  24378. * @param newParent defines the new mesh parent
  24379. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  24380. * @returns the new mesh
  24381. */
  24382. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  24383. /**
  24384. * Disposes all the submeshes of the current meshnp
  24385. * @returns the current mesh
  24386. */
  24387. releaseSubMeshes(): AbstractMesh;
  24388. /**
  24389. * Releases resources associated with this abstract mesh.
  24390. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24391. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24392. */
  24393. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24394. /**
  24395. * Adds the passed mesh as a child to the current mesh
  24396. * @param mesh defines the child mesh
  24397. * @returns the current mesh
  24398. */
  24399. addChild(mesh: AbstractMesh): AbstractMesh;
  24400. /**
  24401. * Removes the passed mesh from the current mesh children list
  24402. * @param mesh defines the child mesh
  24403. * @returns the current mesh
  24404. */
  24405. removeChild(mesh: AbstractMesh): AbstractMesh;
  24406. /** @hidden */
  24407. private _initFacetData;
  24408. /**
  24409. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  24410. * This method can be called within the render loop.
  24411. * 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
  24412. * @returns the current mesh
  24413. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24414. */
  24415. updateFacetData(): AbstractMesh;
  24416. /**
  24417. * Returns the facetLocalNormals array.
  24418. * The normals are expressed in the mesh local spac
  24419. * @returns an array of Vector3
  24420. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24421. */
  24422. getFacetLocalNormals(): Vector3[];
  24423. /**
  24424. * Returns the facetLocalPositions array.
  24425. * The facet positions are expressed in the mesh local space
  24426. * @returns an array of Vector3
  24427. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24428. */
  24429. getFacetLocalPositions(): Vector3[];
  24430. /**
  24431. * Returns the facetLocalPartioning array
  24432. * @returns an array of array of numbers
  24433. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24434. */
  24435. getFacetLocalPartitioning(): number[][];
  24436. /**
  24437. * Returns the i-th facet position in the world system.
  24438. * This method allocates a new Vector3 per call
  24439. * @param i defines the facet index
  24440. * @returns a new Vector3
  24441. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24442. */
  24443. getFacetPosition(i: number): Vector3;
  24444. /**
  24445. * Sets the reference Vector3 with the i-th facet position in the world system
  24446. * @param i defines the facet index
  24447. * @param ref defines the target vector
  24448. * @returns the current mesh
  24449. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24450. */
  24451. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  24452. /**
  24453. * Returns the i-th facet normal in the world system.
  24454. * This method allocates a new Vector3 per call
  24455. * @param i defines the facet index
  24456. * @returns a new Vector3
  24457. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24458. */
  24459. getFacetNormal(i: number): Vector3;
  24460. /**
  24461. * Sets the reference Vector3 with the i-th facet normal in the world system
  24462. * @param i defines the facet index
  24463. * @param ref defines the target vector
  24464. * @returns the current mesh
  24465. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24466. */
  24467. getFacetNormalToRef(i: number, ref: Vector3): this;
  24468. /**
  24469. * 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)
  24470. * @param x defines x coordinate
  24471. * @param y defines y coordinate
  24472. * @param z defines z coordinate
  24473. * @returns the array of facet indexes
  24474. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24475. */
  24476. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  24477. /**
  24478. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  24479. * @param projected sets as the (x,y,z) world projection on the facet
  24480. * @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
  24481. * @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
  24482. * @param x defines x coordinate
  24483. * @param y defines y coordinate
  24484. * @param z defines z coordinate
  24485. * @returns the face index if found (or null instead)
  24486. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24487. */
  24488. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24489. /**
  24490. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  24491. * @param projected sets as the (x,y,z) local projection on the facet
  24492. * @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
  24493. * @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
  24494. * @param x defines x coordinate
  24495. * @param y defines y coordinate
  24496. * @param z defines z coordinate
  24497. * @returns the face index if found (or null instead)
  24498. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24499. */
  24500. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24501. /**
  24502. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  24503. * @returns the parameters
  24504. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24505. */
  24506. getFacetDataParameters(): any;
  24507. /**
  24508. * Disables the feature FacetData and frees the related memory
  24509. * @returns the current mesh
  24510. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24511. */
  24512. disableFacetData(): AbstractMesh;
  24513. /**
  24514. * Updates the AbstractMesh indices array
  24515. * @param indices defines the data source
  24516. * @returns the current mesh
  24517. */
  24518. updateIndices(indices: IndicesArray): AbstractMesh;
  24519. /**
  24520. * Creates new normals data for the mesh
  24521. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  24522. * @returns the current mesh
  24523. */
  24524. createNormals(updatable: boolean): AbstractMesh;
  24525. /**
  24526. * Align the mesh with a normal
  24527. * @param normal defines the normal to use
  24528. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  24529. * @returns the current mesh
  24530. */
  24531. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  24532. /** @hidden */
  24533. _checkOcclusionQuery(): boolean;
  24534. }
  24535. }
  24536. declare module BABYLON {
  24537. /**
  24538. * Class used to store data that will be store in GPU memory
  24539. */
  24540. class Buffer {
  24541. private _engine;
  24542. private _buffer;
  24543. /** @hidden */
  24544. _data: Nullable<DataArray>;
  24545. private _updatable;
  24546. private _instanced;
  24547. /**
  24548. * Gets the byte stride.
  24549. */
  24550. readonly byteStride: number;
  24551. /**
  24552. * Constructor
  24553. * @param engine the engine
  24554. * @param data the data to use for this buffer
  24555. * @param updatable whether the data is updatable
  24556. * @param stride the stride (optional)
  24557. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  24558. * @param instanced whether the buffer is instanced (optional)
  24559. * @param useBytes set to true if the stride in in bytes (optional)
  24560. */
  24561. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  24562. /**
  24563. * Create a new VertexBuffer based on the current buffer
  24564. * @param kind defines the vertex buffer kind (position, normal, etc.)
  24565. * @param offset defines offset in the buffer (0 by default)
  24566. * @param size defines the size in floats of attributes (position is 3 for instance)
  24567. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  24568. * @param instanced defines if the vertex buffer contains indexed data
  24569. * @param useBytes defines if the offset and stride are in bytes
  24570. * @returns the new vertex buffer
  24571. */
  24572. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  24573. /**
  24574. * Gets a boolean indicating if the Buffer is updatable?
  24575. * @returns true if the buffer is updatable
  24576. */
  24577. isUpdatable(): boolean;
  24578. /**
  24579. * Gets current buffer's data
  24580. * @returns a DataArray or null
  24581. */
  24582. getData(): Nullable<DataArray>;
  24583. /**
  24584. * Gets underlying native buffer
  24585. * @returns underlying native buffer
  24586. */
  24587. getBuffer(): Nullable<WebGLBuffer>;
  24588. /**
  24589. * Gets the stride in float32 units (i.e. byte stride / 4).
  24590. * May not be an integer if the byte stride is not divisible by 4.
  24591. * DEPRECATED. Use byteStride instead.
  24592. * @returns the stride in float32 units
  24593. */
  24594. getStrideSize(): number;
  24595. /**
  24596. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  24597. * @param data defines the data to store
  24598. */
  24599. create(data?: Nullable<DataArray>): void;
  24600. /** @hidden */
  24601. _rebuild(): void;
  24602. /**
  24603. * Update current buffer data
  24604. * @param data defines the data to store
  24605. */
  24606. update(data: DataArray): void;
  24607. /**
  24608. * Updates the data directly.
  24609. * @param data the new data
  24610. * @param offset the new offset
  24611. * @param vertexCount the vertex count (optional)
  24612. * @param useBytes set to true if the offset is in bytes
  24613. */
  24614. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  24615. /**
  24616. * Release all resources
  24617. */
  24618. dispose(): void;
  24619. }
  24620. }
  24621. declare module BABYLON {
  24622. /**
  24623. * Class for building Constructive Solid Geometry
  24624. */
  24625. class CSG {
  24626. private polygons;
  24627. /**
  24628. * The world matrix
  24629. */
  24630. matrix: Matrix;
  24631. /**
  24632. * Stores the position
  24633. */
  24634. position: Vector3;
  24635. /**
  24636. * Stores the rotation
  24637. */
  24638. rotation: Vector3;
  24639. /**
  24640. * Stores the rotation quaternion
  24641. */
  24642. rotationQuaternion: Nullable<Quaternion>;
  24643. /**
  24644. * Stores the scaling vector
  24645. */
  24646. scaling: Vector3;
  24647. /**
  24648. * Convert the BABYLON.Mesh to BABYLON.CSG
  24649. * @param mesh The BABYLON.Mesh to convert to BABYLON.CSG
  24650. * @returns A new BABYLON.CSG from the BABYLON.Mesh
  24651. */
  24652. static FromMesh(mesh: Mesh): CSG;
  24653. /**
  24654. * Construct a BABYLON.CSG solid from a list of `BABYLON.CSG.Polygon` instances.
  24655. * @param polygons Polygons used to construct a BABYLON.CSG solid
  24656. */
  24657. private static FromPolygons;
  24658. /**
  24659. * Clones, or makes a deep copy, of the BABYLON.CSG
  24660. * @returns A new BABYLON.CSG
  24661. */
  24662. clone(): CSG;
  24663. /**
  24664. * Unions this CSG with another CSG
  24665. * @param csg The CSG to union against this CSG
  24666. * @returns The unioned CSG
  24667. */
  24668. union(csg: CSG): CSG;
  24669. /**
  24670. * Unions this CSG with another CSG in place
  24671. * @param csg The CSG to union against this CSG
  24672. */
  24673. unionInPlace(csg: CSG): void;
  24674. /**
  24675. * Subtracts this CSG with another CSG
  24676. * @param csg The CSG to subtract against this CSG
  24677. * @returns A new BABYLON.CSG
  24678. */
  24679. subtract(csg: CSG): CSG;
  24680. /**
  24681. * Subtracts this CSG with another CSG in place
  24682. * @param csg The CSG to subtact against this CSG
  24683. */
  24684. subtractInPlace(csg: CSG): void;
  24685. /**
  24686. * Intersect this CSG with another CSG
  24687. * @param csg The CSG to intersect against this CSG
  24688. * @returns A new BABYLON.CSG
  24689. */
  24690. intersect(csg: CSG): CSG;
  24691. /**
  24692. * Intersects this CSG with another CSG in place
  24693. * @param csg The CSG to intersect against this CSG
  24694. */
  24695. intersectInPlace(csg: CSG): void;
  24696. /**
  24697. * Return a new BABYLON.CSG solid with solid and empty space switched. This solid is
  24698. * not modified.
  24699. * @returns A new BABYLON.CSG solid with solid and empty space switched
  24700. */
  24701. inverse(): CSG;
  24702. /**
  24703. * Inverses the BABYLON.CSG in place
  24704. */
  24705. inverseInPlace(): void;
  24706. /**
  24707. * This is used to keep meshes transformations so they can be restored
  24708. * when we build back a Babylon Mesh
  24709. * NB : All CSG operations are performed in world coordinates
  24710. * @param csg The BABYLON.CSG to copy the transform attributes from
  24711. * @returns This BABYLON.CSG
  24712. */
  24713. copyTransformAttributes(csg: CSG): CSG;
  24714. /**
  24715. * Build Raw mesh from CSG
  24716. * Coordinates here are in world space
  24717. * @param name The name of the mesh geometry
  24718. * @param scene The BABYLON.Scene
  24719. * @param keepSubMeshes Specifies if the submeshes should be kept
  24720. * @returns A new BABYLON.Mesh
  24721. */
  24722. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  24723. /**
  24724. * Build Mesh from CSG taking material and transforms into account
  24725. * @param name The name of the BABYLON.Mesh
  24726. * @param material The material of the BABYLON.Mesh
  24727. * @param scene The BABYLON.Scene
  24728. * @param keepSubMeshes Specifies if submeshes should be kept
  24729. * @returns The new BABYLON.Mesh
  24730. */
  24731. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  24732. }
  24733. }
  24734. declare module BABYLON {
  24735. /**
  24736. * Class used to store geometry data (vertex buffers + index buffer)
  24737. */
  24738. class Geometry implements IGetSetVerticesData {
  24739. /**
  24740. * Gets or sets the unique ID of the geometry
  24741. */
  24742. id: string;
  24743. /**
  24744. * Gets the delay loading state of the geometry (none by default which means not delayed)
  24745. */
  24746. delayLoadState: number;
  24747. /**
  24748. * Gets the file containing the data to load when running in delay load state
  24749. */
  24750. delayLoadingFile: Nullable<string>;
  24751. /**
  24752. * Callback called when the geometry is updated
  24753. */
  24754. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  24755. private _scene;
  24756. private _engine;
  24757. private _meshes;
  24758. private _totalVertices;
  24759. /** @hidden */
  24760. _indices: IndicesArray;
  24761. /** @hidden */
  24762. _vertexBuffers: {
  24763. [key: string]: VertexBuffer;
  24764. };
  24765. private _isDisposed;
  24766. private _extend;
  24767. private _boundingBias;
  24768. /** @hidden */
  24769. _delayInfo: Array<string>;
  24770. private _indexBuffer;
  24771. private _indexBufferIsUpdatable;
  24772. /** @hidden */
  24773. _boundingInfo: Nullable<BoundingInfo>;
  24774. /** @hidden */
  24775. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  24776. /** @hidden */
  24777. _softwareSkinningFrameId: number;
  24778. private _vertexArrayObjects;
  24779. private _updatable;
  24780. /** @hidden */
  24781. _positions: Nullable<Vector3[]>;
  24782. /**
  24783. * 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
  24784. */
  24785. /**
  24786. * 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
  24787. */
  24788. boundingBias: Vector2;
  24789. /**
  24790. * Static function used to attach a new empty geometry to a mesh
  24791. * @param mesh defines the mesh to attach the geometry to
  24792. * @returns the new Geometry
  24793. */
  24794. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  24795. /**
  24796. * Creates a new geometry
  24797. * @param id defines the unique ID
  24798. * @param scene defines the hosting scene
  24799. * @param vertexData defines the VertexData used to get geometry data
  24800. * @param updatable defines if geometry must be updatable (false by default)
  24801. * @param mesh defines the mesh that will be associated with the geometry
  24802. */
  24803. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  24804. /**
  24805. * Gets the current extend of the geometry
  24806. */
  24807. readonly extend: {
  24808. minimum: Vector3;
  24809. maximum: Vector3;
  24810. };
  24811. /**
  24812. * Gets the hosting scene
  24813. * @returns the hosting Scene
  24814. */
  24815. getScene(): Scene;
  24816. /**
  24817. * Gets the hosting engine
  24818. * @returns the hosting Engine
  24819. */
  24820. getEngine(): Engine;
  24821. /**
  24822. * Defines if the geometry is ready to use
  24823. * @returns true if the geometry is ready to be used
  24824. */
  24825. isReady(): boolean;
  24826. /**
  24827. * Gets a value indicating that the geometry should not be serialized
  24828. */
  24829. readonly doNotSerialize: boolean;
  24830. /** @hidden */
  24831. _rebuild(): void;
  24832. /**
  24833. * Affects all geometry data in one call
  24834. * @param vertexData defines the geometry data
  24835. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  24836. */
  24837. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  24838. /**
  24839. * Set specific vertex data
  24840. * @param kind defines the data kind (Position, normal, etc...)
  24841. * @param data defines the vertex data to use
  24842. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  24843. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  24844. */
  24845. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  24846. /**
  24847. * Removes a specific vertex data
  24848. * @param kind defines the data kind (Position, normal, etc...)
  24849. */
  24850. removeVerticesData(kind: string): void;
  24851. /**
  24852. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  24853. * @param buffer defines the vertex buffer to use
  24854. * @param totalVertices defines the total number of vertices for position kind (could be null)
  24855. */
  24856. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  24857. /**
  24858. * Update a specific vertex buffer
  24859. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  24860. * It will do nothing if the buffer is not updatable
  24861. * @param kind defines the data kind (Position, normal, etc...)
  24862. * @param data defines the data to use
  24863. * @param offset defines the offset in the target buffer where to store the data
  24864. * @param useBytes set to true if the offset is in bytes
  24865. */
  24866. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  24867. /**
  24868. * Update a specific vertex buffer
  24869. * This function will create a new buffer if the current one is not updatable
  24870. * @param kind defines the data kind (Position, normal, etc...)
  24871. * @param data defines the data to use
  24872. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  24873. */
  24874. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  24875. private _updateBoundingInfo;
  24876. /** @hidden */
  24877. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  24878. /**
  24879. * Gets total number of vertices
  24880. * @returns the total number of vertices
  24881. */
  24882. getTotalVertices(): number;
  24883. /**
  24884. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  24885. * @param kind defines the data kind (Position, normal, etc...)
  24886. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  24887. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24888. * @returns a float array containing vertex data
  24889. */
  24890. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24891. /**
  24892. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  24893. * @param kind defines the data kind (Position, normal, etc...)
  24894. * @returns true if the vertex buffer with the specified kind is updatable
  24895. */
  24896. isVertexBufferUpdatable(kind: string): boolean;
  24897. /**
  24898. * Gets a specific vertex buffer
  24899. * @param kind defines the data kind (Position, normal, etc...)
  24900. * @returns a VertexBuffer
  24901. */
  24902. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24903. /**
  24904. * Returns all vertex buffers
  24905. * @return an object holding all vertex buffers indexed by kind
  24906. */
  24907. getVertexBuffers(): Nullable<{
  24908. [key: string]: VertexBuffer;
  24909. }>;
  24910. /**
  24911. * Gets a boolean indicating if specific vertex buffer is present
  24912. * @param kind defines the data kind (Position, normal, etc...)
  24913. * @returns true if data is present
  24914. */
  24915. isVerticesDataPresent(kind: string): boolean;
  24916. /**
  24917. * Gets a list of all attached data kinds (Position, normal, etc...)
  24918. * @returns a list of string containing all kinds
  24919. */
  24920. getVerticesDataKinds(): string[];
  24921. /**
  24922. * Update index buffer
  24923. * @param indices defines the indices to store in the index buffer
  24924. * @param offset defines the offset in the target buffer where to store the data
  24925. */
  24926. updateIndices(indices: IndicesArray, offset?: number): void;
  24927. /**
  24928. * Creates a new index buffer
  24929. * @param indices defines the indices to store in the index buffer
  24930. * @param totalVertices defines the total number of vertices (could be null)
  24931. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  24932. */
  24933. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  24934. /**
  24935. * Return the total number of indices
  24936. * @returns the total number of indices
  24937. */
  24938. getTotalIndices(): number;
  24939. /**
  24940. * Gets the index buffer array
  24941. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  24942. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24943. * @returns the index buffer array
  24944. */
  24945. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24946. /**
  24947. * Gets the index buffer
  24948. * @return the index buffer
  24949. */
  24950. getIndexBuffer(): Nullable<WebGLBuffer>;
  24951. /** @hidden */
  24952. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  24953. /**
  24954. * Release the associated resources for a specific mesh
  24955. * @param mesh defines the source mesh
  24956. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  24957. */
  24958. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  24959. /**
  24960. * Apply current geometry to a given mesh
  24961. * @param mesh defines the mesh to apply geometry to
  24962. */
  24963. applyToMesh(mesh: Mesh): void;
  24964. private _updateExtend;
  24965. private _applyToMesh;
  24966. private notifyUpdate;
  24967. /**
  24968. * Load the geometry if it was flagged as delay loaded
  24969. * @param scene defines the hosting scene
  24970. * @param onLoaded defines a callback called when the geometry is loaded
  24971. */
  24972. load(scene: Scene, onLoaded?: () => void): void;
  24973. private _queueLoad;
  24974. /**
  24975. * Invert the geometry to move from a right handed system to a left handed one.
  24976. */
  24977. toLeftHanded(): void;
  24978. /** @hidden */
  24979. _resetPointsArrayCache(): void;
  24980. /** @hidden */
  24981. _generatePointsArray(): boolean;
  24982. /**
  24983. * Gets a value indicating if the geometry is disposed
  24984. * @returns true if the geometry was disposed
  24985. */
  24986. isDisposed(): boolean;
  24987. private _disposeVertexArrayObjects;
  24988. /**
  24989. * Free all associated resources
  24990. */
  24991. dispose(): void;
  24992. /**
  24993. * Clone the current geometry into a new geometry
  24994. * @param id defines the unique ID of the new geometry
  24995. * @returns a new geometry object
  24996. */
  24997. copy(id: string): Geometry;
  24998. /**
  24999. * Serialize the current geometry info (and not the vertices data) into a JSON object
  25000. * @return a JSON representation of the current geometry data (without the vertices data)
  25001. */
  25002. serialize(): any;
  25003. private toNumberArray;
  25004. /**
  25005. * Serialize all vertices data into a JSON oject
  25006. * @returns a JSON representation of the current geometry data
  25007. */
  25008. serializeVerticeData(): any;
  25009. /**
  25010. * Extracts a clone of a mesh geometry
  25011. * @param mesh defines the source mesh
  25012. * @param id defines the unique ID of the new geometry object
  25013. * @returns the new geometry object
  25014. */
  25015. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  25016. /**
  25017. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  25018. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  25019. * Be aware Math.random() could cause collisions, but:
  25020. * "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"
  25021. * @returns a string containing a new GUID
  25022. */
  25023. static RandomId(): string;
  25024. /** @hidden */
  25025. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  25026. private static _CleanMatricesWeights;
  25027. /**
  25028. * Create a new geometry from persisted data (Using .babylon file format)
  25029. * @param parsedVertexData defines the persisted data
  25030. * @param scene defines the hosting scene
  25031. * @param rootUrl defines the root url to use to load assets (like delayed data)
  25032. * @returns the new geometry object
  25033. */
  25034. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  25035. }
  25036. /**
  25037. * Abstract class used to provide common services for all typed geometries
  25038. * @hidden
  25039. */
  25040. class _PrimitiveGeometry extends Geometry {
  25041. private _canBeRegenerated;
  25042. private _beingRegenerated;
  25043. /**
  25044. * Creates a new typed geometry
  25045. * @param id defines the unique ID of the geometry
  25046. * @param scene defines the hosting scene
  25047. * @param _canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25048. * @param mesh defines the hosting mesh (can be null)
  25049. */
  25050. constructor(id: string, scene: Scene, _canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  25051. /**
  25052. * Gets a value indicating if the geometry supports being regenerated with new parameters (false by default)
  25053. * @returns true if the geometry can be regenerated
  25054. */
  25055. canBeRegenerated(): boolean;
  25056. /**
  25057. * If the geometry supports regeneration, the function will recreates the geometry with updated parameter values
  25058. */
  25059. regenerate(): void;
  25060. /**
  25061. * Clone the geometry
  25062. * @param id defines the unique ID of the new geometry
  25063. * @returns the new geometry
  25064. */
  25065. asNewGeometry(id: string): Geometry;
  25066. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  25067. setVerticesData(kind: string, data: FloatArray, updatable?: boolean): void;
  25068. /** @hidden */
  25069. _regenerateVertexData(): VertexData;
  25070. copy(id: string): Geometry;
  25071. serialize(): any;
  25072. }
  25073. /**
  25074. * Creates a ribbon geometry
  25075. * @description See http://doc.babylonjs.com/how_to/ribbon_tutorial, http://doc.babylonjs.com/resources/maths_make_ribbons
  25076. */
  25077. class RibbonGeometry extends _PrimitiveGeometry {
  25078. /**
  25079. * Defines the array of paths to use
  25080. */
  25081. pathArray: Vector3[][];
  25082. /**
  25083. * Defines if the last and first points of each path in your pathArray must be joined
  25084. */
  25085. closeArray: boolean;
  25086. /**
  25087. * Defines if the last and first points of each path in your pathArray must be joined
  25088. */
  25089. closePath: boolean;
  25090. /**
  25091. * Defines the offset between points
  25092. */
  25093. offset: number;
  25094. /**
  25095. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25096. */
  25097. side: number;
  25098. /**
  25099. * Creates a ribbon geometry
  25100. * @param id defines the unique ID of the geometry
  25101. * @param scene defines the hosting scene
  25102. * @param pathArray defines the array of paths to use
  25103. * @param closeArray defines if the last path and the first path must be joined
  25104. * @param closePath defines if the last and first points of each path in your pathArray must be joined
  25105. * @param offset defines the offset between points
  25106. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25107. * @param mesh defines the hosting mesh (can be null)
  25108. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25109. */
  25110. constructor(id: string, scene: Scene,
  25111. /**
  25112. * Defines the array of paths to use
  25113. */
  25114. pathArray: Vector3[][],
  25115. /**
  25116. * Defines if the last and first points of each path in your pathArray must be joined
  25117. */
  25118. closeArray: boolean,
  25119. /**
  25120. * Defines if the last and first points of each path in your pathArray must be joined
  25121. */
  25122. closePath: boolean,
  25123. /**
  25124. * Defines the offset between points
  25125. */
  25126. offset: number, canBeRegenerated?: boolean, mesh?: Mesh,
  25127. /**
  25128. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25129. */
  25130. side?: number);
  25131. /** @hidden */
  25132. _regenerateVertexData(): VertexData;
  25133. copy(id: string): Geometry;
  25134. }
  25135. /**
  25136. * Creates a box geometry
  25137. * @description see http://doc.babylonjs.com/how_to/set_shapes#box
  25138. */
  25139. class BoxGeometry extends _PrimitiveGeometry {
  25140. /**
  25141. * Defines the zise of the box (width, height and depth are the same)
  25142. */
  25143. size: number;
  25144. /**
  25145. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25146. */
  25147. side: number;
  25148. /**
  25149. * Creates a box geometry
  25150. * @param id defines the unique ID of the geometry
  25151. * @param scene defines the hosting scene
  25152. * @param size defines the zise of the box (width, height and depth are the same)
  25153. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25154. * @param mesh defines the hosting mesh (can be null)
  25155. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25156. */
  25157. constructor(id: string, scene: Scene,
  25158. /**
  25159. * Defines the zise of the box (width, height and depth are the same)
  25160. */
  25161. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25162. /**
  25163. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25164. */
  25165. side?: number);
  25166. /** @hidden */
  25167. _regenerateVertexData(): VertexData;
  25168. copy(id: string): Geometry;
  25169. serialize(): any;
  25170. static Parse(parsedBox: any, scene: Scene): Nullable<BoxGeometry>;
  25171. }
  25172. /**
  25173. * Creates a sphere geometry
  25174. * @description see http://doc.babylonjs.com/how_to/set_shapes#sphere
  25175. */
  25176. class SphereGeometry extends _PrimitiveGeometry {
  25177. /**
  25178. * Defines the number of segments to use to create the sphere
  25179. */
  25180. segments: number;
  25181. /**
  25182. * Defines the diameter of the sphere
  25183. */
  25184. diameter: number;
  25185. /**
  25186. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25187. */
  25188. side: number;
  25189. /**
  25190. * Create a new sphere geometry
  25191. * @param id defines the unique ID of the geometry
  25192. * @param scene defines the hosting scene
  25193. * @param segments defines the number of segments to use to create the sphere
  25194. * @param diameter defines the diameter of the sphere
  25195. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25196. * @param mesh defines the hosting mesh (can be null)
  25197. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25198. */
  25199. constructor(id: string, scene: Scene,
  25200. /**
  25201. * Defines the number of segments to use to create the sphere
  25202. */
  25203. segments: number,
  25204. /**
  25205. * Defines the diameter of the sphere
  25206. */
  25207. diameter: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25208. /**
  25209. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25210. */
  25211. side?: number);
  25212. /** @hidden */
  25213. _regenerateVertexData(): VertexData;
  25214. copy(id: string): Geometry;
  25215. serialize(): any;
  25216. static Parse(parsedSphere: any, scene: Scene): Nullable<SphereGeometry>;
  25217. }
  25218. /**
  25219. * Creates a disc geometry
  25220. * @description see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25221. */
  25222. class DiscGeometry extends _PrimitiveGeometry {
  25223. /**
  25224. * Defines the radius of the disc
  25225. */
  25226. radius: number;
  25227. /**
  25228. * Defines the tesselation factor to apply to the disc
  25229. */
  25230. tessellation: number;
  25231. /**
  25232. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25233. */
  25234. side: number;
  25235. /**
  25236. * Creates a new disc geometry
  25237. * @param id defines the unique ID of the geometry
  25238. * @param scene defines the hosting scene
  25239. * @param radius defines the radius of the disc
  25240. * @param tessellation defines the tesselation factor to apply to the disc
  25241. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25242. * @param mesh defines the hosting mesh (can be null)
  25243. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25244. */
  25245. constructor(id: string, scene: Scene,
  25246. /**
  25247. * Defines the radius of the disc
  25248. */
  25249. radius: number,
  25250. /**
  25251. * Defines the tesselation factor to apply to the disc
  25252. */
  25253. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25254. /**
  25255. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25256. */
  25257. side?: number);
  25258. /** @hidden */
  25259. _regenerateVertexData(): VertexData;
  25260. copy(id: string): Geometry;
  25261. }
  25262. /**
  25263. * Creates a new cylinder geometry
  25264. * @description see http://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  25265. */
  25266. class CylinderGeometry extends _PrimitiveGeometry {
  25267. /**
  25268. * Defines the height of the cylinder
  25269. */
  25270. height: number;
  25271. /**
  25272. * Defines the diameter of the cylinder's top cap
  25273. */
  25274. diameterTop: number;
  25275. /**
  25276. * Defines the diameter of the cylinder's bottom cap
  25277. */
  25278. diameterBottom: number;
  25279. /**
  25280. * Defines the tessellation factor to apply to the cylinder
  25281. */
  25282. tessellation: number;
  25283. /**
  25284. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  25285. */
  25286. subdivisions: number;
  25287. /**
  25288. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25289. */
  25290. side: number;
  25291. /**
  25292. * Creates a new cylinder geometry
  25293. * @param id defines the unique ID of the geometry
  25294. * @param scene defines the hosting scene
  25295. * @param height defines the height of the cylinder
  25296. * @param diameterTop defines the diameter of the cylinder's top cap
  25297. * @param diameterBottom defines the diameter of the cylinder's bottom cap
  25298. * @param tessellation defines the tessellation factor to apply to the cylinder (number of radial sides)
  25299. * @param subdivisions defines the number of subdivisions to apply to the cylinder (number of rings) (1 by default)
  25300. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25301. * @param mesh defines the hosting mesh (can be null)
  25302. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25303. */
  25304. constructor(id: string, scene: Scene,
  25305. /**
  25306. * Defines the height of the cylinder
  25307. */
  25308. height: number,
  25309. /**
  25310. * Defines the diameter of the cylinder's top cap
  25311. */
  25312. diameterTop: number,
  25313. /**
  25314. * Defines the diameter of the cylinder's bottom cap
  25315. */
  25316. diameterBottom: number,
  25317. /**
  25318. * Defines the tessellation factor to apply to the cylinder
  25319. */
  25320. tessellation: number,
  25321. /**
  25322. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  25323. */
  25324. subdivisions?: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25325. /**
  25326. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25327. */
  25328. side?: number);
  25329. /** @hidden */
  25330. _regenerateVertexData(): VertexData;
  25331. copy(id: string): Geometry;
  25332. serialize(): any;
  25333. static Parse(parsedCylinder: any, scene: Scene): Nullable<CylinderGeometry>;
  25334. }
  25335. /**
  25336. * Creates a new torus geometry
  25337. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus
  25338. */
  25339. class TorusGeometry extends _PrimitiveGeometry {
  25340. /**
  25341. * Defines the diameter of the torus
  25342. */
  25343. diameter: number;
  25344. /**
  25345. * Defines the thickness of the torus (ie. internal diameter)
  25346. */
  25347. thickness: number;
  25348. /**
  25349. * Defines the tesselation factor to apply to the torus
  25350. */
  25351. tessellation: number;
  25352. /**
  25353. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25354. */
  25355. side: number;
  25356. /**
  25357. * Creates a new torus geometry
  25358. * @param id defines the unique ID of the geometry
  25359. * @param scene defines the hosting scene
  25360. * @param diameter defines the diameter of the torus
  25361. * @param thickness defines the thickness of the torus (ie. internal diameter)
  25362. * @param tessellation defines the tesselation factor to apply to the torus (number of segments along the circle)
  25363. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25364. * @param mesh defines the hosting mesh (can be null)
  25365. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25366. */
  25367. constructor(id: string, scene: Scene,
  25368. /**
  25369. * Defines the diameter of the torus
  25370. */
  25371. diameter: number,
  25372. /**
  25373. * Defines the thickness of the torus (ie. internal diameter)
  25374. */
  25375. thickness: number,
  25376. /**
  25377. * Defines the tesselation factor to apply to the torus
  25378. */
  25379. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25380. /**
  25381. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25382. */
  25383. side?: number);
  25384. /** @hidden */
  25385. _regenerateVertexData(): VertexData;
  25386. copy(id: string): Geometry;
  25387. serialize(): any;
  25388. static Parse(parsedTorus: any, scene: Scene): Nullable<TorusGeometry>;
  25389. }
  25390. /**
  25391. * Creates a new ground geometry
  25392. * @description see http://doc.babylonjs.com/how_to/set_shapes#ground
  25393. */
  25394. class GroundGeometry extends _PrimitiveGeometry {
  25395. /**
  25396. * Defines the width of the ground
  25397. */
  25398. width: number;
  25399. /**
  25400. * Defines the height of the ground
  25401. */
  25402. height: number;
  25403. /**
  25404. * Defines the subdivisions to apply to the ground
  25405. */
  25406. subdivisions: number;
  25407. /**
  25408. * Creates a new ground geometry
  25409. * @param id defines the unique ID of the geometry
  25410. * @param scene defines the hosting scene
  25411. * @param width defines the width of the ground
  25412. * @param height defines the height of the ground
  25413. * @param subdivisions defines the subdivisions to apply to the ground
  25414. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25415. * @param mesh defines the hosting mesh (can be null)
  25416. */
  25417. constructor(id: string, scene: Scene,
  25418. /**
  25419. * Defines the width of the ground
  25420. */
  25421. width: number,
  25422. /**
  25423. * Defines the height of the ground
  25424. */
  25425. height: number,
  25426. /**
  25427. * Defines the subdivisions to apply to the ground
  25428. */
  25429. subdivisions: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  25430. /** @hidden */
  25431. _regenerateVertexData(): VertexData;
  25432. copy(id: string): Geometry;
  25433. serialize(): any;
  25434. static Parse(parsedGround: any, scene: Scene): Nullable<GroundGeometry>;
  25435. }
  25436. /**
  25437. * Creates a tiled ground geometry
  25438. * @description see http://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  25439. */
  25440. class TiledGroundGeometry extends _PrimitiveGeometry {
  25441. /**
  25442. * Defines the minimum value on X axis
  25443. */
  25444. xmin: number;
  25445. /**
  25446. * Defines the minimum value on Z axis
  25447. */
  25448. zmin: number;
  25449. /**
  25450. * Defines the maximum value on X axis
  25451. */
  25452. xmax: number;
  25453. /**
  25454. * Defines the maximum value on Z axis
  25455. */
  25456. zmax: number;
  25457. /**
  25458. * Defines the subdivisions to apply to the ground
  25459. */
  25460. subdivisions: {
  25461. w: number;
  25462. h: number;
  25463. };
  25464. /**
  25465. * Defines the precision to use when computing the tiles
  25466. */
  25467. precision: {
  25468. w: number;
  25469. h: number;
  25470. };
  25471. /**
  25472. * Creates a tiled ground geometry
  25473. * @param id defines the unique ID of the geometry
  25474. * @param scene defines the hosting scene
  25475. * @param xmin defines the minimum value on X axis
  25476. * @param zmin defines the minimum value on Z axis
  25477. * @param xmax defines the maximum value on X axis
  25478. * @param zmax defines the maximum value on Z axis
  25479. * @param subdivisions defines the subdivisions to apply to the ground (number of subdivisions (tiles) on the height and the width of the map)
  25480. * @param precision defines the precision to use when computing the tiles
  25481. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25482. * @param mesh defines the hosting mesh (can be null)
  25483. */
  25484. constructor(id: string, scene: Scene,
  25485. /**
  25486. * Defines the minimum value on X axis
  25487. */
  25488. xmin: number,
  25489. /**
  25490. * Defines the minimum value on Z axis
  25491. */
  25492. zmin: number,
  25493. /**
  25494. * Defines the maximum value on X axis
  25495. */
  25496. xmax: number,
  25497. /**
  25498. * Defines the maximum value on Z axis
  25499. */
  25500. zmax: number,
  25501. /**
  25502. * Defines the subdivisions to apply to the ground
  25503. */
  25504. subdivisions: {
  25505. w: number;
  25506. h: number;
  25507. },
  25508. /**
  25509. * Defines the precision to use when computing the tiles
  25510. */
  25511. precision: {
  25512. w: number;
  25513. h: number;
  25514. }, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  25515. /** @hidden */
  25516. _regenerateVertexData(): VertexData;
  25517. copy(id: string): Geometry;
  25518. }
  25519. /**
  25520. * Creates a plane geometry
  25521. * @description see http://doc.babylonjs.com/how_to/set_shapes#plane
  25522. */
  25523. class PlaneGeometry extends _PrimitiveGeometry {
  25524. /**
  25525. * Defines the size of the plane (width === height)
  25526. */
  25527. size: number;
  25528. /**
  25529. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25530. */
  25531. side: number;
  25532. /**
  25533. * Creates a plane geometry
  25534. * @param id defines the unique ID of the geometry
  25535. * @param scene defines the hosting scene
  25536. * @param size defines the size of the plane (width === height)
  25537. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25538. * @param mesh defines the hosting mesh (can be null)
  25539. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25540. */
  25541. constructor(id: string, scene: Scene,
  25542. /**
  25543. * Defines the size of the plane (width === height)
  25544. */
  25545. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25546. /**
  25547. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25548. */
  25549. side?: number);
  25550. /** @hidden */
  25551. _regenerateVertexData(): VertexData;
  25552. copy(id: string): Geometry;
  25553. serialize(): any;
  25554. static Parse(parsedPlane: any, scene: Scene): Nullable<PlaneGeometry>;
  25555. }
  25556. /**
  25557. * Creates a torus knot geometry
  25558. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus-knot
  25559. */
  25560. class TorusKnotGeometry extends _PrimitiveGeometry {
  25561. /**
  25562. * Defines the radius of the torus knot
  25563. */
  25564. radius: number;
  25565. /**
  25566. * Defines the thickness of the torus knot tube
  25567. */
  25568. tube: number;
  25569. /**
  25570. * Defines the number of radial segments
  25571. */
  25572. radialSegments: number;
  25573. /**
  25574. * Defines the number of tubular segments
  25575. */
  25576. tubularSegments: number;
  25577. /**
  25578. * Defines the first number of windings
  25579. */
  25580. p: number;
  25581. /**
  25582. * Defines the second number of windings
  25583. */
  25584. q: number;
  25585. /**
  25586. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25587. */
  25588. side: number;
  25589. /**
  25590. * Creates a torus knot geometry
  25591. * @param id defines the unique ID of the geometry
  25592. * @param scene defines the hosting scene
  25593. * @param radius defines the radius of the torus knot
  25594. * @param tube defines the thickness of the torus knot tube
  25595. * @param radialSegments defines the number of radial segments
  25596. * @param tubularSegments defines the number of tubular segments
  25597. * @param p defines the first number of windings
  25598. * @param q defines the second number of windings
  25599. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25600. * @param mesh defines the hosting mesh (can be null)
  25601. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25602. */
  25603. constructor(id: string, scene: Scene,
  25604. /**
  25605. * Defines the radius of the torus knot
  25606. */
  25607. radius: number,
  25608. /**
  25609. * Defines the thickness of the torus knot tube
  25610. */
  25611. tube: number,
  25612. /**
  25613. * Defines the number of radial segments
  25614. */
  25615. radialSegments: number,
  25616. /**
  25617. * Defines the number of tubular segments
  25618. */
  25619. tubularSegments: number,
  25620. /**
  25621. * Defines the first number of windings
  25622. */
  25623. p: number,
  25624. /**
  25625. * Defines the second number of windings
  25626. */
  25627. q: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25628. /**
  25629. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25630. */
  25631. side?: number);
  25632. /** @hidden */
  25633. _regenerateVertexData(): VertexData;
  25634. copy(id: string): Geometry;
  25635. serialize(): any;
  25636. static Parse(parsedTorusKnot: any, scene: Scene): Nullable<TorusKnotGeometry>;
  25637. }
  25638. }
  25639. declare module BABYLON {
  25640. /**
  25641. * Mesh representing the gorund
  25642. */
  25643. class GroundMesh extends Mesh {
  25644. /** If octree should be generated */
  25645. generateOctree: boolean;
  25646. private _heightQuads;
  25647. /** @hidden */
  25648. _subdivisionsX: number;
  25649. /** @hidden */
  25650. _subdivisionsY: number;
  25651. /** @hidden */
  25652. _width: number;
  25653. /** @hidden */
  25654. _height: number;
  25655. /** @hidden */
  25656. _minX: number;
  25657. /** @hidden */
  25658. _maxX: number;
  25659. /** @hidden */
  25660. _minZ: number;
  25661. /** @hidden */
  25662. _maxZ: number;
  25663. constructor(name: string, scene: Scene);
  25664. /**
  25665. * "GroundMesh"
  25666. * @returns "GroundMesh"
  25667. */
  25668. getClassName(): string;
  25669. /**
  25670. * The minimum of x and y subdivisions
  25671. */
  25672. readonly subdivisions: number;
  25673. /**
  25674. * X subdivisions
  25675. */
  25676. readonly subdivisionsX: number;
  25677. /**
  25678. * Y subdivisions
  25679. */
  25680. readonly subdivisionsY: number;
  25681. /**
  25682. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  25683. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  25684. * @param chunksCount the number of subdivisions for x and y
  25685. * @param octreeBlocksSize (Default: 32)
  25686. */
  25687. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  25688. /**
  25689. * Returns a height (y) value in the Worl system :
  25690. * the ground altitude at the coordinates (x, z) expressed in the World system.
  25691. * @param x x coordinate
  25692. * @param z z coordinate
  25693. * @returns the ground y position if (x, z) are outside the ground surface.
  25694. */
  25695. getHeightAtCoordinates(x: number, z: number): number;
  25696. /**
  25697. * Returns a normalized vector (Vector3) orthogonal to the ground
  25698. * at the ground coordinates (x, z) expressed in the World system.
  25699. * @param x x coordinate
  25700. * @param z z coordinate
  25701. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  25702. */
  25703. getNormalAtCoordinates(x: number, z: number): Vector3;
  25704. /**
  25705. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  25706. * at the ground coordinates (x, z) expressed in the World system.
  25707. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  25708. * @param x x coordinate
  25709. * @param z z coordinate
  25710. * @param ref vector to store the result
  25711. * @returns the GroundMesh.
  25712. */
  25713. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  25714. /**
  25715. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  25716. * if the ground has been updated.
  25717. * This can be used in the render loop.
  25718. * @returns the GroundMesh.
  25719. */
  25720. updateCoordinateHeights(): GroundMesh;
  25721. private _getFacetAt;
  25722. private _initHeightQuads;
  25723. private _computeHeightQuads;
  25724. /**
  25725. * Serializes this ground mesh
  25726. * @param serializationObject object to write serialization to
  25727. */
  25728. serialize(serializationObject: any): void;
  25729. /**
  25730. * Parses a serialized ground mesh
  25731. * @param parsedMesh the serialized mesh
  25732. * @param scene the scene to create the ground mesh in
  25733. * @returns the created ground mesh
  25734. */
  25735. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  25736. }
  25737. }
  25738. declare module BABYLON {
  25739. /**
  25740. * Creates an instance based on a source mesh.
  25741. */
  25742. class InstancedMesh extends AbstractMesh {
  25743. private _sourceMesh;
  25744. private _currentLOD;
  25745. constructor(name: string, source: Mesh);
  25746. /**
  25747. * Returns the string "InstancedMesh".
  25748. */
  25749. getClassName(): string;
  25750. /**
  25751. * If the source mesh receives shadows
  25752. */
  25753. readonly receiveShadows: boolean;
  25754. /**
  25755. * The material of the source mesh
  25756. */
  25757. readonly material: Nullable<Material>;
  25758. /**
  25759. * Visibility of the source mesh
  25760. */
  25761. readonly visibility: number;
  25762. /**
  25763. * Skeleton of the source mesh
  25764. */
  25765. readonly skeleton: Nullable<Skeleton>;
  25766. /**
  25767. * Rendering ground id of the source mesh
  25768. */
  25769. renderingGroupId: number;
  25770. /**
  25771. * Returns the total number of vertices (integer).
  25772. */
  25773. getTotalVertices(): number;
  25774. /**
  25775. * The source mesh of the instance
  25776. */
  25777. readonly sourceMesh: Mesh;
  25778. /**
  25779. * Is this node ready to be used/rendered
  25780. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25781. * @return {boolean} is it ready
  25782. */
  25783. isReady(completeCheck?: boolean): boolean;
  25784. /**
  25785. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25786. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  25787. * @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.
  25788. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  25789. */
  25790. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  25791. /**
  25792. * Sets the vertex data of the mesh geometry for the requested `kind`.
  25793. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  25794. * The `data` are either a numeric array either a Float32Array.
  25795. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  25796. * 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).
  25797. * Note that a new underlying VertexBuffer object is created each call.
  25798. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  25799. *
  25800. * Possible `kind` values :
  25801. * - BABYLON.VertexBuffer.PositionKind
  25802. * - BABYLON.VertexBuffer.UVKind
  25803. * - BABYLON.VertexBuffer.UV2Kind
  25804. * - BABYLON.VertexBuffer.UV3Kind
  25805. * - BABYLON.VertexBuffer.UV4Kind
  25806. * - BABYLON.VertexBuffer.UV5Kind
  25807. * - BABYLON.VertexBuffer.UV6Kind
  25808. * - BABYLON.VertexBuffer.ColorKind
  25809. * - BABYLON.VertexBuffer.MatricesIndicesKind
  25810. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  25811. * - BABYLON.VertexBuffer.MatricesWeightsKind
  25812. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  25813. *
  25814. * Returns the Mesh.
  25815. */
  25816. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  25817. /**
  25818. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  25819. * If the mesh has no geometry, it is simply returned as it is.
  25820. * The `data` are either a numeric array either a Float32Array.
  25821. * No new underlying VertexBuffer object is created.
  25822. * 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.
  25823. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  25824. *
  25825. * Possible `kind` values :
  25826. * - BABYLON.VertexBuffer.PositionKind
  25827. * - BABYLON.VertexBuffer.UVKind
  25828. * - BABYLON.VertexBuffer.UV2Kind
  25829. * - BABYLON.VertexBuffer.UV3Kind
  25830. * - BABYLON.VertexBuffer.UV4Kind
  25831. * - BABYLON.VertexBuffer.UV5Kind
  25832. * - BABYLON.VertexBuffer.UV6Kind
  25833. * - BABYLON.VertexBuffer.ColorKind
  25834. * - BABYLON.VertexBuffer.MatricesIndicesKind
  25835. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  25836. * - BABYLON.VertexBuffer.MatricesWeightsKind
  25837. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  25838. *
  25839. * Returns the Mesh.
  25840. */
  25841. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  25842. /**
  25843. * Sets the mesh indices.
  25844. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  25845. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  25846. * This method creates a new index buffer each call.
  25847. * Returns the Mesh.
  25848. */
  25849. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  25850. /**
  25851. * Boolean : True if the mesh owns the requested kind of data.
  25852. */
  25853. isVerticesDataPresent(kind: string): boolean;
  25854. /**
  25855. * Returns an array of indices (IndicesArray).
  25856. */
  25857. getIndices(): Nullable<IndicesArray>;
  25858. readonly _positions: Nullable<Vector3[]>;
  25859. /**
  25860. * Sets a new updated BoundingInfo to the mesh.
  25861. * @returns the mesh.
  25862. */
  25863. refreshBoundingInfo(): InstancedMesh;
  25864. /** @hidden */
  25865. _preActivate(): InstancedMesh;
  25866. /** @hidden */
  25867. _activate(renderId: number): InstancedMesh;
  25868. /**
  25869. * Returns the current associated LOD AbstractMesh.
  25870. */
  25871. getLOD(camera: Camera): AbstractMesh;
  25872. /** @hidden */
  25873. _syncSubMeshes(): InstancedMesh;
  25874. /** @hidden */
  25875. _generatePointsArray(): boolean;
  25876. /**
  25877. * Creates a new InstancedMesh from the current mesh.
  25878. * - name (string) : the cloned mesh name
  25879. * - newParent (optional Node) : the optional Node to parent the clone to.
  25880. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  25881. *
  25882. * Returns the clone.
  25883. */
  25884. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  25885. /**
  25886. * Disposes the InstancedMesh.
  25887. * Returns nothing.
  25888. */
  25889. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25890. }
  25891. }
  25892. declare module BABYLON {
  25893. /**
  25894. * Line mesh
  25895. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  25896. */
  25897. class LinesMesh extends Mesh {
  25898. /**
  25899. * If vertex color should be applied to the mesh
  25900. */
  25901. useVertexColor?: boolean | undefined;
  25902. /**
  25903. * If vertex alpha should be applied to the mesh
  25904. */
  25905. useVertexAlpha?: boolean | undefined;
  25906. /**
  25907. * Color of the line (Default: White)
  25908. */
  25909. color: Color3;
  25910. /**
  25911. * Alpha of the line (Default: 1)
  25912. */
  25913. alpha: number;
  25914. /**
  25915. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  25916. * This margin is expressed in world space coordinates, so its value may vary.
  25917. * Default value is 0.1
  25918. * @returns the intersection Threshold value.
  25919. */
  25920. /**
  25921. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  25922. * This margin is expressed in world space coordinates, so its value may vary.
  25923. */
  25924. intersectionThreshold: number;
  25925. private _intersectionThreshold;
  25926. private _colorShader;
  25927. /**
  25928. * Creates a new LinesMesh
  25929. * @param name defines the name
  25930. * @param scene defines the hosting scene
  25931. * @param parent defines the parent mesh if any
  25932. * @param source defines the optional source LinesMesh used to clone data from
  25933. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  25934. * When false, achieved by calling a clone(), also passing False.
  25935. * This will make creation of children, recursive.
  25936. * @param useVertexColor defines if this LinesMesh supports vertex color
  25937. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  25938. */
  25939. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  25940. /**
  25941. * If vertex color should be applied to the mesh
  25942. */
  25943. useVertexColor?: boolean | undefined,
  25944. /**
  25945. * If vertex alpha should be applied to the mesh
  25946. */
  25947. useVertexAlpha?: boolean | undefined);
  25948. /**
  25949. * Returns the string "LineMesh"
  25950. */
  25951. getClassName(): string;
  25952. /**
  25953. * @hidden
  25954. */
  25955. /**
  25956. * @hidden
  25957. */
  25958. material: Material;
  25959. /**
  25960. * @hidden
  25961. */
  25962. readonly checkCollisions: boolean;
  25963. /** @hidden */
  25964. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  25965. /** @hidden */
  25966. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  25967. /**
  25968. * Disposes of the line mesh
  25969. * @param doNotRecurse If children should be disposed
  25970. */
  25971. dispose(doNotRecurse?: boolean): void;
  25972. /**
  25973. * Returns a new LineMesh object cloned from the current one.
  25974. */
  25975. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  25976. }
  25977. }
  25978. declare module BABYLON {
  25979. /**
  25980. * @hidden
  25981. **/
  25982. class _CreationDataStorage {
  25983. closePath?: boolean;
  25984. closeArray?: boolean;
  25985. idx: number[];
  25986. dashSize: number;
  25987. gapSize: number;
  25988. path3D: Path3D;
  25989. pathArray: Vector3[][];
  25990. arc: number;
  25991. radius: number;
  25992. cap: number;
  25993. tessellation: number;
  25994. }
  25995. /**
  25996. * @hidden
  25997. **/
  25998. class _InstanceDataStorage {
  25999. visibleInstances: any;
  26000. renderIdForInstances: number[];
  26001. batchCache: _InstancesBatch;
  26002. instancesBufferSize: number;
  26003. instancesBuffer: Nullable<Buffer>;
  26004. instancesData: Float32Array;
  26005. overridenInstanceCount: number;
  26006. }
  26007. /**
  26008. * @hidden
  26009. **/
  26010. class _InstancesBatch {
  26011. mustReturn: boolean;
  26012. visibleInstances: Nullable<InstancedMesh[]>[];
  26013. renderSelf: boolean[];
  26014. }
  26015. /**
  26016. * Class used to represent renderable models
  26017. */
  26018. class Mesh extends AbstractMesh implements IGetSetVerticesData {
  26019. /**
  26020. * Mesh side orientation : usually the external or front surface
  26021. */
  26022. static readonly FRONTSIDE: number;
  26023. /**
  26024. * Mesh side orientation : usually the internal or back surface
  26025. */
  26026. static readonly BACKSIDE: number;
  26027. /**
  26028. * Mesh side orientation : both internal and external or front and back surfaces
  26029. */
  26030. static readonly DOUBLESIDE: number;
  26031. /**
  26032. * Mesh side orientation : by default, `FRONTSIDE`
  26033. */
  26034. static readonly DEFAULTSIDE: number;
  26035. /**
  26036. * Mesh cap setting : no cap
  26037. */
  26038. static readonly NO_CAP: number;
  26039. /**
  26040. * Mesh cap setting : one cap at the beginning of the mesh
  26041. */
  26042. static readonly CAP_START: number;
  26043. /**
  26044. * Mesh cap setting : one cap at the end of the mesh
  26045. */
  26046. static readonly CAP_END: number;
  26047. /**
  26048. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  26049. */
  26050. static readonly CAP_ALL: number;
  26051. private _onBeforeRenderObservable;
  26052. private _onAfterRenderObservable;
  26053. private _onBeforeDrawObservable;
  26054. /**
  26055. * An event triggered before rendering the mesh
  26056. */
  26057. readonly onBeforeRenderObservable: Observable<Mesh>;
  26058. /**
  26059. * An event triggered after rendering the mesh
  26060. */
  26061. readonly onAfterRenderObservable: Observable<Mesh>;
  26062. /**
  26063. * An event triggered before drawing the mesh
  26064. */
  26065. readonly onBeforeDrawObservable: Observable<Mesh>;
  26066. private _onBeforeDrawObserver;
  26067. /**
  26068. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  26069. */
  26070. onBeforeDraw: () => void;
  26071. /**
  26072. * Gets the delay loading state of the mesh (when delay loading is turned on)
  26073. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  26074. */
  26075. delayLoadState: number;
  26076. /**
  26077. * Gets the list of instances created from this mesh
  26078. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  26079. */
  26080. instances: InstancedMesh[];
  26081. /**
  26082. * Gets the file containing delay loading data for this mesh
  26083. */
  26084. delayLoadingFile: string;
  26085. /** @hidden */
  26086. _binaryInfo: any;
  26087. private _LODLevels;
  26088. /**
  26089. * User defined function used to change how LOD level selection is done
  26090. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  26091. */
  26092. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  26093. private _morphTargetManager;
  26094. /**
  26095. * Gets or sets the morph target manager
  26096. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26097. */
  26098. morphTargetManager: Nullable<MorphTargetManager>;
  26099. /** @hidden */
  26100. _creationDataStorage: Nullable<_CreationDataStorage>;
  26101. /** @hidden */
  26102. _geometry: Nullable<Geometry>;
  26103. /** @hidden */
  26104. _delayInfo: Array<string>;
  26105. /** @hidden */
  26106. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  26107. /** @hidden */
  26108. _instanceDataStorage: _InstanceDataStorage;
  26109. private _effectiveMaterial;
  26110. /** @hidden */
  26111. _shouldGenerateFlatShading: boolean;
  26112. private _preActivateId;
  26113. /** @hidden */
  26114. _originalBuilderSideOrientation: number;
  26115. /**
  26116. * Use this property to change the original side orientation defined at construction time
  26117. */
  26118. overrideMaterialSideOrientation: Nullable<number>;
  26119. private _areNormalsFrozen;
  26120. private _sourcePositions;
  26121. private _sourceNormals;
  26122. private _source;
  26123. /**
  26124. * Gets the source mesh (the one used to clone this one from)
  26125. */
  26126. readonly source: Nullable<Mesh>;
  26127. /**
  26128. * Gets or sets a boolean indicating that this mesh does not use index buffer
  26129. */
  26130. isUnIndexed: boolean;
  26131. /**
  26132. * @constructor
  26133. * @param name The value used by scene.getMeshByName() to do a lookup.
  26134. * @param scene The scene to add this mesh to.
  26135. * @param parent The parent of this mesh, if it has one
  26136. * @param source An optional Mesh from which geometry is shared, cloned.
  26137. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  26138. * When false, achieved by calling a clone(), also passing False.
  26139. * This will make creation of children, recursive.
  26140. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  26141. */
  26142. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  26143. /**
  26144. * Gets the class name
  26145. * @returns the string "Mesh".
  26146. */
  26147. getClassName(): string;
  26148. /**
  26149. * Returns a description of this mesh
  26150. * @param fullDetails define if full details about this mesh must be used
  26151. * @returns a descriptive string representing this mesh
  26152. */
  26153. toString(fullDetails?: boolean): string;
  26154. /** @hidden */
  26155. _unBindEffect(): void;
  26156. /**
  26157. * Gets a boolean indicating if this mesh has LOD
  26158. */
  26159. readonly hasLODLevels: boolean;
  26160. /**
  26161. * Gets the list of MeshLODLevel associated with the current mesh
  26162. * @returns an array of MeshLODLevel
  26163. */
  26164. getLODLevels(): MeshLODLevel[];
  26165. private _sortLODLevels;
  26166. /**
  26167. * Add a mesh as LOD level triggered at the given distance.
  26168. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26169. * @param distance The distance from the center of the object to show this level
  26170. * @param mesh The mesh to be added as LOD level (can be null)
  26171. * @return This mesh (for chaining)
  26172. */
  26173. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  26174. /**
  26175. * Returns the LOD level mesh at the passed distance or null if not found.
  26176. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26177. * @param distance The distance from the center of the object to show this level
  26178. * @returns a Mesh or `null`
  26179. */
  26180. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  26181. /**
  26182. * Remove a mesh from the LOD array
  26183. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26184. * @param mesh defines the mesh to be removed
  26185. * @return This mesh (for chaining)
  26186. */
  26187. removeLODLevel(mesh: Mesh): Mesh;
  26188. /**
  26189. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  26190. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26191. * @param camera defines the camera to use to compute distance
  26192. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  26193. * @return This mesh (for chaining)
  26194. */
  26195. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  26196. /**
  26197. * Gets the mesh internal Geometry object
  26198. */
  26199. readonly geometry: Nullable<Geometry>;
  26200. /**
  26201. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  26202. * @returns the total number of vertices
  26203. */
  26204. getTotalVertices(): number;
  26205. /**
  26206. * Returns the content of an associated vertex buffer
  26207. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  26208. * - BABYLON.VertexBuffer.PositionKind
  26209. * - BABYLON.VertexBuffer.UVKind
  26210. * - BABYLON.VertexBuffer.UV2Kind
  26211. * - BABYLON.VertexBuffer.UV3Kind
  26212. * - BABYLON.VertexBuffer.UV4Kind
  26213. * - BABYLON.VertexBuffer.UV5Kind
  26214. * - BABYLON.VertexBuffer.UV6Kind
  26215. * - BABYLON.VertexBuffer.ColorKind
  26216. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26217. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26218. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26219. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26220. * @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
  26221. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  26222. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  26223. */
  26224. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  26225. /**
  26226. * Returns the mesh VertexBuffer object from the requested `kind`
  26227. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  26228. * - BABYLON.VertexBuffer.PositionKind
  26229. * - BABYLON.VertexBuffer.UVKind
  26230. * - BABYLON.VertexBuffer.UV2Kind
  26231. * - BABYLON.VertexBuffer.UV3Kind
  26232. * - BABYLON.VertexBuffer.UV4Kind
  26233. * - BABYLON.VertexBuffer.UV5Kind
  26234. * - BABYLON.VertexBuffer.UV6Kind
  26235. * - BABYLON.VertexBuffer.ColorKind
  26236. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26237. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26238. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26239. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26240. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  26241. */
  26242. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  26243. /**
  26244. * Tests if a specific vertex buffer is associated with this mesh
  26245. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  26246. * - BABYLON.VertexBuffer.PositionKind
  26247. * - BABYLON.VertexBuffer.UVKind
  26248. * - BABYLON.VertexBuffer.UV2Kind
  26249. * - BABYLON.VertexBuffer.UV3Kind
  26250. * - BABYLON.VertexBuffer.UV4Kind
  26251. * - BABYLON.VertexBuffer.UV5Kind
  26252. * - BABYLON.VertexBuffer.UV6Kind
  26253. * - BABYLON.VertexBuffer.ColorKind
  26254. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26255. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26256. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26257. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26258. * @returns a boolean
  26259. */
  26260. isVerticesDataPresent(kind: string): boolean;
  26261. /**
  26262. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  26263. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  26264. * - BABYLON.VertexBuffer.PositionKind
  26265. * - BABYLON.VertexBuffer.UVKind
  26266. * - BABYLON.VertexBuffer.UV2Kind
  26267. * - BABYLON.VertexBuffer.UV3Kind
  26268. * - BABYLON.VertexBuffer.UV4Kind
  26269. * - BABYLON.VertexBuffer.UV5Kind
  26270. * - BABYLON.VertexBuffer.UV6Kind
  26271. * - BABYLON.VertexBuffer.ColorKind
  26272. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26273. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26274. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26275. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26276. * @returns a boolean
  26277. */
  26278. isVertexBufferUpdatable(kind: string): boolean;
  26279. /**
  26280. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  26281. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  26282. * - BABYLON.VertexBuffer.PositionKind
  26283. * - BABYLON.VertexBuffer.UVKind
  26284. * - BABYLON.VertexBuffer.UV2Kind
  26285. * - BABYLON.VertexBuffer.UV3Kind
  26286. * - BABYLON.VertexBuffer.UV4Kind
  26287. * - BABYLON.VertexBuffer.UV5Kind
  26288. * - BABYLON.VertexBuffer.UV6Kind
  26289. * - BABYLON.VertexBuffer.ColorKind
  26290. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26291. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26292. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26293. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26294. * @returns an array of strings
  26295. */
  26296. getVerticesDataKinds(): string[];
  26297. /**
  26298. * Returns a positive integer : the total number of indices in this mesh geometry.
  26299. * @returns the numner of indices or zero if the mesh has no geometry.
  26300. */
  26301. getTotalIndices(): number;
  26302. /**
  26303. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  26304. * @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.
  26305. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26306. * @returns the indices array or an empty array if the mesh has no geometry
  26307. */
  26308. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  26309. readonly isBlocked: boolean;
  26310. /**
  26311. * Determine if the current mesh is ready to be rendered
  26312. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26313. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  26314. * @returns true if all associated assets are ready (material, textures, shaders)
  26315. */
  26316. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  26317. /**
  26318. * 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.
  26319. */
  26320. readonly areNormalsFrozen: boolean;
  26321. /**
  26322. * 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.
  26323. * @returns the current mesh
  26324. */
  26325. freezeNormals(): Mesh;
  26326. /**
  26327. * 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
  26328. * @returns the current mesh
  26329. */
  26330. unfreezeNormals(): Mesh;
  26331. /**
  26332. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  26333. */
  26334. overridenInstanceCount: number;
  26335. /** @hidden */
  26336. _preActivate(): Mesh;
  26337. /** @hidden */
  26338. _preActivateForIntermediateRendering(renderId: number): Mesh;
  26339. /** @hidden */
  26340. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  26341. /**
  26342. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26343. * This means the mesh underlying bounding box and sphere are recomputed.
  26344. * @returns the current mesh
  26345. */
  26346. refreshBoundingInfo(): Mesh;
  26347. /** @hidden */
  26348. _refreshBoundingInfo(applySkeleton: boolean): Mesh;
  26349. private _getPositionData;
  26350. /** @hidden */
  26351. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  26352. /**
  26353. * This function will subdivide the mesh into multiple submeshes
  26354. * @param count defines the expected number of submeshes
  26355. */
  26356. subdivide(count: number): void;
  26357. /**
  26358. * Copy a FloatArray into a specific associated vertex buffer
  26359. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  26360. * - BABYLON.VertexBuffer.PositionKind
  26361. * - BABYLON.VertexBuffer.UVKind
  26362. * - BABYLON.VertexBuffer.UV2Kind
  26363. * - BABYLON.VertexBuffer.UV3Kind
  26364. * - BABYLON.VertexBuffer.UV4Kind
  26365. * - BABYLON.VertexBuffer.UV5Kind
  26366. * - BABYLON.VertexBuffer.UV6Kind
  26367. * - BABYLON.VertexBuffer.ColorKind
  26368. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26369. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26370. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26371. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26372. * @param data defines the data source
  26373. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  26374. * @param stride defines the data stride size (can be null)
  26375. * @returns the current mesh
  26376. */
  26377. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  26378. /**
  26379. * Flags an associated vertex buffer as updatable
  26380. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  26381. * - BABYLON.VertexBuffer.PositionKind
  26382. * - BABYLON.VertexBuffer.UVKind
  26383. * - BABYLON.VertexBuffer.UV2Kind
  26384. * - BABYLON.VertexBuffer.UV3Kind
  26385. * - BABYLON.VertexBuffer.UV4Kind
  26386. * - BABYLON.VertexBuffer.UV5Kind
  26387. * - BABYLON.VertexBuffer.UV6Kind
  26388. * - BABYLON.VertexBuffer.ColorKind
  26389. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26390. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26391. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26392. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26393. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  26394. */
  26395. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  26396. /**
  26397. * Sets the mesh global Vertex Buffer
  26398. * @param buffer defines the buffer to use
  26399. * @returns the current mesh
  26400. */
  26401. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  26402. /**
  26403. * Update a specific associated vertex buffer
  26404. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  26405. * - BABYLON.VertexBuffer.PositionKind
  26406. * - BABYLON.VertexBuffer.UVKind
  26407. * - BABYLON.VertexBuffer.UV2Kind
  26408. * - BABYLON.VertexBuffer.UV3Kind
  26409. * - BABYLON.VertexBuffer.UV4Kind
  26410. * - BABYLON.VertexBuffer.UV5Kind
  26411. * - BABYLON.VertexBuffer.UV6Kind
  26412. * - BABYLON.VertexBuffer.ColorKind
  26413. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26414. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26415. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26416. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26417. * @param data defines the data source
  26418. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  26419. * @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)
  26420. * @returns the current mesh
  26421. */
  26422. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  26423. /**
  26424. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  26425. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  26426. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  26427. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  26428. * @returns the current mesh
  26429. */
  26430. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  26431. /**
  26432. * Creates a un-shared specific occurence of the geometry for the mesh.
  26433. * @returns the current mesh
  26434. */
  26435. makeGeometryUnique(): Mesh;
  26436. /**
  26437. * Set the index buffer of this mesh
  26438. * @param indices defines the source data
  26439. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  26440. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  26441. * @returns the current mesh
  26442. */
  26443. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  26444. /**
  26445. * Update the current index buffer
  26446. * @param indices defines the source data
  26447. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  26448. * @returns the current mesh
  26449. */
  26450. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  26451. /**
  26452. * Invert the geometry to move from a right handed system to a left handed one.
  26453. * @returns the current mesh
  26454. */
  26455. toLeftHanded(): Mesh;
  26456. /** @hidden */
  26457. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  26458. /** @hidden */
  26459. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  26460. /**
  26461. * Registers for this mesh a javascript function called just before the rendering process
  26462. * @param func defines the function to call before rendering this mesh
  26463. * @returns the current mesh
  26464. */
  26465. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  26466. /**
  26467. * Disposes a previously registered javascript function called before the rendering
  26468. * @param func defines the function to remove
  26469. * @returns the current mesh
  26470. */
  26471. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  26472. /**
  26473. * Registers for this mesh a javascript function called just after the rendering is complete
  26474. * @param func defines the function to call after rendering this mesh
  26475. * @returns the current mesh
  26476. */
  26477. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  26478. /**
  26479. * Disposes a previously registered javascript function called after the rendering.
  26480. * @param func defines the function to remove
  26481. * @returns the current mesh
  26482. */
  26483. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  26484. /** @hidden */
  26485. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  26486. /** @hidden */
  26487. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  26488. /** @hidden */
  26489. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  26490. /**
  26491. * 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
  26492. * @param subMesh defines the subMesh to render
  26493. * @param enableAlphaMode defines if alpha mode can be changed
  26494. * @returns the current mesh
  26495. */
  26496. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  26497. private _onBeforeDraw;
  26498. /**
  26499. * Renormalize the mesh and patch it up if there are no weights
  26500. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  26501. * However in the case of zero weights then we set just a single influence to 1.
  26502. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  26503. */
  26504. cleanMatrixWeights(): void;
  26505. private normalizeSkinFourWeights;
  26506. private normalizeSkinWeightsAndExtra;
  26507. /**
  26508. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  26509. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  26510. * the user know there was an issue with importing the mesh
  26511. * @returns a validation object with skinned, valid and report string
  26512. */
  26513. validateSkinning(): {
  26514. skinned: boolean;
  26515. valid: boolean;
  26516. report: string;
  26517. };
  26518. /** @hidden */
  26519. _checkDelayState(): Mesh;
  26520. private _queueLoad;
  26521. /**
  26522. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  26523. * A mesh is in the frustum if its bounding box intersects the frustum
  26524. * @param frustumPlanes defines the frustum to test
  26525. * @returns true if the mesh is in the frustum planes
  26526. */
  26527. isInFrustum(frustumPlanes: Plane[]): boolean;
  26528. /**
  26529. * Sets the mesh material by the material or multiMaterial `id` property
  26530. * @param id is a string identifying the material or the multiMaterial
  26531. * @returns the current mesh
  26532. */
  26533. setMaterialByID(id: string): Mesh;
  26534. /**
  26535. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  26536. * @returns an array of IAnimatable
  26537. */
  26538. getAnimatables(): IAnimatable[];
  26539. /**
  26540. * Modifies the mesh geometry according to the passed transformation matrix.
  26541. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  26542. * The mesh normals are modified using the same transformation.
  26543. * Note that, under the hood, this method sets a new VertexBuffer each call.
  26544. * @param transform defines the transform matrix to use
  26545. * @see http://doc.babylonjs.com/resources/baking_transformations
  26546. * @returns the current mesh
  26547. */
  26548. bakeTransformIntoVertices(transform: Matrix): Mesh;
  26549. /**
  26550. * Modifies the mesh geometry according to its own current World Matrix.
  26551. * The mesh World Matrix is then reset.
  26552. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  26553. * Note that, under the hood, this method sets a new VertexBuffer each call.
  26554. * @see http://doc.babylonjs.com/resources/baking_transformations
  26555. * @returns the current mesh
  26556. */
  26557. bakeCurrentTransformIntoVertices(): Mesh;
  26558. /** @hidden */
  26559. readonly _positions: Nullable<Vector3[]>;
  26560. /** @hidden */
  26561. _resetPointsArrayCache(): Mesh;
  26562. /** @hidden */
  26563. _generatePointsArray(): boolean;
  26564. /**
  26565. * Returns a new Mesh object generated from the current mesh properties.
  26566. * This method must not get confused with createInstance()
  26567. * @param name is a string, the name given to the new mesh
  26568. * @param newParent can be any Node object (default `null`)
  26569. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  26570. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  26571. * @returns a new mesh
  26572. */
  26573. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  26574. /**
  26575. * Releases resources associated with this mesh.
  26576. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26577. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26578. */
  26579. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26580. /**
  26581. * Modifies the mesh geometry according to a displacement map.
  26582. * 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.
  26583. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  26584. * @param url is a string, the URL from the image file is to be downloaded.
  26585. * @param minHeight is the lower limit of the displacement.
  26586. * @param maxHeight is the upper limit of the displacement.
  26587. * @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.
  26588. * @param uvOffset is an optional vector2 used to offset UV.
  26589. * @param uvScale is an optional vector2 used to scale UV.
  26590. * @param forceUpdate defines whether or not to force an update of the generated buffers. This is usefull to apply on a deserialized model for instance.
  26591. * @returns the Mesh.
  26592. */
  26593. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  26594. /**
  26595. * Modifies the mesh geometry according to a displacementMap buffer.
  26596. * 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.
  26597. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  26598. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  26599. * @param heightMapWidth is the width of the buffer image.
  26600. * @param heightMapHeight is the height of the buffer image.
  26601. * @param minHeight is the lower limit of the displacement.
  26602. * @param maxHeight is the upper limit of the displacement.
  26603. * @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.
  26604. * @param uvOffset is an optional vector2 used to offset UV.
  26605. * @param uvScale is an optional vector2 used to scale UV.
  26606. * @param forceUpdate defines whether or not to force an update of the generated buffers. This is usefull to apply on a deserialized model for instance.
  26607. * @returns the Mesh.
  26608. */
  26609. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  26610. /**
  26611. * Modify the mesh to get a flat shading rendering.
  26612. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  26613. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  26614. * @returns current mesh
  26615. */
  26616. convertToFlatShadedMesh(): Mesh;
  26617. /**
  26618. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  26619. * In other words, more vertices, no more indices and a single bigger VBO.
  26620. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  26621. * @returns current mesh
  26622. */
  26623. convertToUnIndexedMesh(): Mesh;
  26624. /**
  26625. * Inverses facet orientations.
  26626. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  26627. * @param flipNormals will also inverts the normals
  26628. * @returns current mesh
  26629. */
  26630. flipFaces(flipNormals?: boolean): Mesh;
  26631. /**
  26632. * Creates a new InstancedMesh object from the mesh model.
  26633. * Warning : this method is not supported for Line mesh and LineSystem
  26634. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  26635. * @param name defines the name of the new instance
  26636. * @returns a new InstancedMesh
  26637. */
  26638. createInstance(name: string): InstancedMesh;
  26639. /**
  26640. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  26641. * After this call, all the mesh instances have the same submeshes than the current mesh.
  26642. * @returns the current mesh
  26643. */
  26644. synchronizeInstances(): Mesh;
  26645. /**
  26646. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  26647. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  26648. * This should be used together with the simplification to avoid disappearing triangles.
  26649. * @param successCallback an optional success callback to be called after the optimization finished.
  26650. * @returns the current mesh
  26651. */
  26652. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  26653. /**
  26654. * Serialize current mesh
  26655. * @param serializationObject defines the object which will receive the serialization data
  26656. */
  26657. serialize(serializationObject: any): void;
  26658. /** @hidden */
  26659. _syncGeometryWithMorphTargetManager(): void;
  26660. /**
  26661. * Returns a new Mesh object parsed from the source provided.
  26662. * @param parsedMesh is the source
  26663. * @param scene defines the hosting scene
  26664. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  26665. * @returns a new Mesh
  26666. */
  26667. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  26668. /**
  26669. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  26670. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  26671. * @param name defines the name of the mesh to create
  26672. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  26673. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  26674. * @param closePath creates a seam between the first and the last points of each path of the path array
  26675. * @param offset is taken in account only if the `pathArray` is containing a single path
  26676. * @param scene defines the hosting scene
  26677. * @param updatable defines if the mesh must be flagged as updatable
  26678. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26679. * @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)
  26680. * @returns a new Mesh
  26681. */
  26682. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean | undefined, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  26683. /**
  26684. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  26685. * @param name defines the name of the mesh to create
  26686. * @param radius sets the radius size (float) of the polygon (default 0.5)
  26687. * @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
  26688. * @param scene defines the hosting scene
  26689. * @param updatable defines if the mesh must be flagged as updatable
  26690. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26691. * @returns a new Mesh
  26692. */
  26693. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  26694. /**
  26695. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  26696. * @param name defines the name of the mesh to create
  26697. * @param size sets the size (float) of each box side (default 1)
  26698. * @param scene defines the hosting scene
  26699. * @param updatable defines if the mesh must be flagged as updatable
  26700. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26701. * @returns a new Mesh
  26702. */
  26703. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  26704. /**
  26705. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  26706. * @param name defines the name of the mesh to create
  26707. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  26708. * @param diameter sets the diameter size (float) of the sphere (default 1)
  26709. * @param scene defines the hosting scene
  26710. * @param updatable defines if the mesh must be flagged as updatable
  26711. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26712. * @returns a new Mesh
  26713. */
  26714. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26715. /**
  26716. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  26717. * @param name defines the name of the mesh to create
  26718. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  26719. * @param diameterTop set the top cap diameter (floats, default 1)
  26720. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  26721. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  26722. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  26723. * @param scene defines the hosting scene
  26724. * @param updatable defines if the mesh must be flagged as updatable
  26725. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26726. * @returns a new Mesh
  26727. */
  26728. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  26729. /**
  26730. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  26731. * @param name defines the name of the mesh to create
  26732. * @param diameter sets the diameter size (float) of the torus (default 1)
  26733. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  26734. * @param tessellation sets the number of torus sides (postive integer, default 16)
  26735. * @param scene defines the hosting scene
  26736. * @param updatable defines if the mesh must be flagged as updatable
  26737. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26738. * @returns a new Mesh
  26739. */
  26740. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26741. /**
  26742. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  26743. * @param name defines the name of the mesh to create
  26744. * @param radius sets the global radius size (float) of the torus knot (default 2)
  26745. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  26746. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  26747. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  26748. * @param p the number of windings on X axis (positive integers, default 2)
  26749. * @param q the number of windings on Y axis (positive integers, default 3)
  26750. * @param scene defines the hosting scene
  26751. * @param updatable defines if the mesh must be flagged as updatable
  26752. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26753. * @returns a new Mesh
  26754. */
  26755. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26756. /**
  26757. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  26758. * @param name defines the name of the mesh to create
  26759. * @param points is an array successive Vector3
  26760. * @param scene defines the hosting scene
  26761. * @param updatable defines if the mesh must be flagged as updatable
  26762. * @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).
  26763. * @returns a new Mesh
  26764. */
  26765. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  26766. /**
  26767. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  26768. * @param name defines the name of the mesh to create
  26769. * @param points is an array successive Vector3
  26770. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  26771. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  26772. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  26773. * @param scene defines the hosting scene
  26774. * @param updatable defines if the mesh must be flagged as updatable
  26775. * @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)
  26776. * @returns a new Mesh
  26777. */
  26778. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  26779. /**
  26780. * Creates a polygon mesh.
  26781. * Please consider using the same method from the MeshBuilder class instead.
  26782. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  26783. * 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.
  26784. * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26785. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  26786. * Remember you can only change the shape positions, not their number when updating a polygon.
  26787. */
  26788. /**
  26789. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  26790. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  26791. * @param name defines the name of the mesh to create
  26792. * @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
  26793. * @param scene defines the hosting scene
  26794. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  26795. * @param updatable defines if the mesh must be flagged as updatable
  26796. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26797. * @returns a new Mesh
  26798. */
  26799. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  26800. /**
  26801. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  26802. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  26803. * @param name defines the name of the mesh to create
  26804. * @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
  26805. * @param depth defines the height of extrusion
  26806. * @param scene defines the hosting scene
  26807. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  26808. * @param updatable defines if the mesh must be flagged as updatable
  26809. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26810. * @returns a new Mesh
  26811. */
  26812. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  26813. /**
  26814. * Creates an extruded shape mesh.
  26815. * 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
  26816. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  26817. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  26818. * @param name defines the name of the mesh to create
  26819. * @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
  26820. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  26821. * @param scale is the value to scale the shape
  26822. * @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
  26823. * @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
  26824. * @param scene defines the hosting scene
  26825. * @param updatable defines if the mesh must be flagged as updatable
  26826. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26827. * @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)
  26828. * @returns a new Mesh
  26829. */
  26830. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  26831. /**
  26832. * Creates an custom extruded shape mesh.
  26833. * The custom extrusion is a parametric shape.
  26834. * It has no predefined shape. Its final shape will depend on the input parameters.
  26835. * Please consider using the same method from the MeshBuilder class instead
  26836. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  26837. * @param name defines the name of the mesh to create
  26838. * @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
  26839. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  26840. * @param scaleFunction is a custom Javascript function called on each path point
  26841. * @param rotationFunction is a custom Javascript function called on each path point
  26842. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  26843. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  26844. * @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
  26845. * @param scene defines the hosting scene
  26846. * @param updatable defines if the mesh must be flagged as updatable
  26847. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26848. * @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)
  26849. * @returns a new Mesh
  26850. */
  26851. 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;
  26852. /**
  26853. * Creates lathe mesh.
  26854. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  26855. * Please consider using the same method from the MeshBuilder class instead
  26856. * @param name defines the name of the mesh to create
  26857. * @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
  26858. * @param radius is the radius value of the lathe
  26859. * @param tessellation is the side number of the lathe.
  26860. * @param scene defines the hosting scene
  26861. * @param updatable defines if the mesh must be flagged as updatable
  26862. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26863. * @returns a new Mesh
  26864. */
  26865. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26866. /**
  26867. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  26868. * @param name defines the name of the mesh to create
  26869. * @param size sets the size (float) of both sides of the plane at once (default 1)
  26870. * @param scene defines the hosting scene
  26871. * @param updatable defines if the mesh must be flagged as updatable
  26872. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26873. * @returns a new Mesh
  26874. */
  26875. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26876. /**
  26877. * Creates a ground mesh.
  26878. * Please consider using the same method from the MeshBuilder class instead
  26879. * @param name defines the name of the mesh to create
  26880. * @param width set the width of the ground
  26881. * @param height set the height of the ground
  26882. * @param subdivisions sets the number of subdivisions per side
  26883. * @param scene defines the hosting scene
  26884. * @param updatable defines if the mesh must be flagged as updatable
  26885. * @returns a new Mesh
  26886. */
  26887. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  26888. /**
  26889. * Creates a tiled ground mesh.
  26890. * Please consider using the same method from the MeshBuilder class instead
  26891. * @param name defines the name of the mesh to create
  26892. * @param xmin set the ground minimum X coordinate
  26893. * @param zmin set the ground minimum Y coordinate
  26894. * @param xmax set the ground maximum X coordinate
  26895. * @param zmax set the ground maximum Z coordinate
  26896. * @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
  26897. * @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
  26898. * @param scene defines the hosting scene
  26899. * @param updatable defines if the mesh must be flagged as updatable
  26900. * @returns a new Mesh
  26901. */
  26902. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  26903. w: number;
  26904. h: number;
  26905. }, precision: {
  26906. w: number;
  26907. h: number;
  26908. }, scene: Scene, updatable?: boolean): Mesh;
  26909. /**
  26910. * Creates a ground mesh from a height map.
  26911. * Please consider using the same method from the MeshBuilder class instead
  26912. * @see http://doc.babylonjs.com/babylon101/height_map
  26913. * @param name defines the name of the mesh to create
  26914. * @param url sets the URL of the height map image resource
  26915. * @param width set the ground width size
  26916. * @param height set the ground height size
  26917. * @param subdivisions sets the number of subdivision per side
  26918. * @param minHeight is the minimum altitude on the ground
  26919. * @param maxHeight is the maximum altitude on the ground
  26920. * @param scene defines the hosting scene
  26921. * @param updatable defines if the mesh must be flagged as updatable
  26922. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  26923. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  26924. * @returns a new Mesh
  26925. */
  26926. 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;
  26927. /**
  26928. * Creates a tube mesh.
  26929. * The tube is a parametric shape.
  26930. * It has no predefined shape. Its final shape will depend on the input parameters.
  26931. * Please consider using the same method from the MeshBuilder class instead
  26932. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  26933. * @param name defines the name of the mesh to create
  26934. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  26935. * @param radius sets the tube radius size
  26936. * @param tessellation is the number of sides on the tubular surface
  26937. * @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
  26938. * @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
  26939. * @param scene defines the hosting scene
  26940. * @param updatable defines if the mesh must be flagged as updatable
  26941. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26942. * @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)
  26943. * @returns a new Mesh
  26944. */
  26945. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  26946. (i: number, distance: number): number;
  26947. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  26948. /**
  26949. * Creates a polyhedron mesh.
  26950. * Please consider using the same method from the MeshBuilder class instead.
  26951. * * 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
  26952. * * The parameter `size` (positive float, default 1) sets the polygon size
  26953. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  26954. * * 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`
  26955. * * 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
  26956. * * 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)`)
  26957. * * To understand how to set `faceUV` or `faceColors`, please read this by considering the right number of faces of your polyhedron, instead of only 6 for the box : http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  26958. * * 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
  26959. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26960. * * 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
  26961. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26962. * @param name defines the name of the mesh to create
  26963. * @param options defines the options used to create the mesh
  26964. * @param scene defines the hosting scene
  26965. * @returns a new Mesh
  26966. */
  26967. static CreatePolyhedron(name: string, options: {
  26968. type?: number;
  26969. size?: number;
  26970. sizeX?: number;
  26971. sizeY?: number;
  26972. sizeZ?: number;
  26973. custom?: any;
  26974. faceUV?: Vector4[];
  26975. faceColors?: Color4[];
  26976. updatable?: boolean;
  26977. sideOrientation?: number;
  26978. }, scene: Scene): Mesh;
  26979. /**
  26980. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  26981. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  26982. * * 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`)
  26983. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  26984. * * 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
  26985. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26986. * * 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
  26987. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26988. * @param name defines the name of the mesh
  26989. * @param options defines the options used to create the mesh
  26990. * @param scene defines the hosting scene
  26991. * @returns a new Mesh
  26992. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  26993. */
  26994. static CreateIcoSphere(name: string, options: {
  26995. radius?: number;
  26996. flat?: boolean;
  26997. subdivisions?: number;
  26998. sideOrientation?: number;
  26999. updatable?: boolean;
  27000. }, scene: Scene): Mesh;
  27001. /**
  27002. * Creates a decal mesh.
  27003. * Please consider using the same method from the MeshBuilder class instead.
  27004. * A decal is a mesh usually applied as a model onto the surface of another mesh
  27005. * @param name defines the name of the mesh
  27006. * @param sourceMesh defines the mesh receiving the decal
  27007. * @param position sets the position of the decal in world coordinates
  27008. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  27009. * @param size sets the decal scaling
  27010. * @param angle sets the angle to rotate the decal
  27011. * @returns a new Mesh
  27012. */
  27013. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  27014. /**
  27015. * Prepare internal position array for software CPU skinning
  27016. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  27017. */
  27018. setPositionsForCPUSkinning(): Float32Array;
  27019. /**
  27020. * Prepare internal normal array for software CPU skinning
  27021. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  27022. */
  27023. setNormalsForCPUSkinning(): Float32Array;
  27024. /**
  27025. * Updates the vertex buffer by applying transformation from the bones
  27026. * @param skeleton defines the skeleton to apply to current mesh
  27027. * @returns the current mesh
  27028. */
  27029. applySkeleton(skeleton: Skeleton): Mesh;
  27030. /**
  27031. * 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
  27032. * @param meshes defines the list of meshes to scan
  27033. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  27034. */
  27035. static MinMax(meshes: AbstractMesh[]): {
  27036. min: Vector3;
  27037. max: Vector3;
  27038. };
  27039. /**
  27040. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  27041. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  27042. * @returns a vector3
  27043. */
  27044. static Center(meshesOrMinMaxVector: {
  27045. min: Vector3;
  27046. max: Vector3;
  27047. } | AbstractMesh[]): Vector3;
  27048. /**
  27049. * Merge the array of meshes into a single mesh for performance reasons.
  27050. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  27051. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  27052. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  27053. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  27054. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  27055. * @returns a new mesh
  27056. */
  27057. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean): Nullable<Mesh>;
  27058. }
  27059. }
  27060. declare module BABYLON {
  27061. /**
  27062. * Define an interface for all classes that will get and set the data on vertices
  27063. */
  27064. interface IGetSetVerticesData {
  27065. /**
  27066. * Gets a boolean indicating if specific vertex data is present
  27067. * @param kind defines the vertex data kind to use
  27068. * @returns true is data kind is present
  27069. */
  27070. isVerticesDataPresent(kind: string): boolean;
  27071. /**
  27072. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  27073. * @param kind defines the data kind (Position, normal, etc...)
  27074. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  27075. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  27076. * @returns a float array containing vertex data
  27077. */
  27078. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  27079. /**
  27080. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  27081. * @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.
  27082. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  27083. * @returns the indices array or an empty array if the mesh has no geometry
  27084. */
  27085. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  27086. /**
  27087. * Set specific vertex data
  27088. * @param kind defines the data kind (Position, normal, etc...)
  27089. * @param data defines the vertex data to use
  27090. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  27091. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  27092. */
  27093. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  27094. /**
  27095. * Update a specific associated vertex buffer
  27096. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  27097. * - BABYLON.VertexBuffer.PositionKind
  27098. * - BABYLON.VertexBuffer.UVKind
  27099. * - BABYLON.VertexBuffer.UV2Kind
  27100. * - BABYLON.VertexBuffer.UV3Kind
  27101. * - BABYLON.VertexBuffer.UV4Kind
  27102. * - BABYLON.VertexBuffer.UV5Kind
  27103. * - BABYLON.VertexBuffer.UV6Kind
  27104. * - BABYLON.VertexBuffer.ColorKind
  27105. * - BABYLON.VertexBuffer.MatricesIndicesKind
  27106. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  27107. * - BABYLON.VertexBuffer.MatricesWeightsKind
  27108. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  27109. * @param data defines the data source
  27110. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  27111. * @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)
  27112. */
  27113. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  27114. /**
  27115. * Creates a new index buffer
  27116. * @param indices defines the indices to store in the index buffer
  27117. * @param totalVertices defines the total number of vertices (could be null)
  27118. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  27119. */
  27120. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  27121. }
  27122. /**
  27123. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  27124. */
  27125. class VertexData {
  27126. /**
  27127. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  27128. */
  27129. positions: Nullable<FloatArray>;
  27130. /**
  27131. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  27132. */
  27133. normals: Nullable<FloatArray>;
  27134. /**
  27135. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  27136. */
  27137. tangents: Nullable<FloatArray>;
  27138. /**
  27139. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27140. */
  27141. uvs: Nullable<FloatArray>;
  27142. /**
  27143. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27144. */
  27145. uvs2: Nullable<FloatArray>;
  27146. /**
  27147. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27148. */
  27149. uvs3: Nullable<FloatArray>;
  27150. /**
  27151. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27152. */
  27153. uvs4: Nullable<FloatArray>;
  27154. /**
  27155. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27156. */
  27157. uvs5: Nullable<FloatArray>;
  27158. /**
  27159. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27160. */
  27161. uvs6: Nullable<FloatArray>;
  27162. /**
  27163. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  27164. */
  27165. colors: Nullable<FloatArray>;
  27166. /**
  27167. * 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).
  27168. */
  27169. matricesIndices: Nullable<FloatArray>;
  27170. /**
  27171. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  27172. */
  27173. matricesWeights: Nullable<FloatArray>;
  27174. /**
  27175. * An array extending the number of possible indices
  27176. */
  27177. matricesIndicesExtra: Nullable<FloatArray>;
  27178. /**
  27179. * An array extending the number of possible weights when the number of indices is extended
  27180. */
  27181. matricesWeightsExtra: Nullable<FloatArray>;
  27182. /**
  27183. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  27184. */
  27185. indices: Nullable<IndicesArray>;
  27186. /**
  27187. * Uses the passed data array to set the set the values for the specified kind of data
  27188. * @param data a linear array of floating numbers
  27189. * @param kind the type of data that is being set, eg positions, colors etc
  27190. */
  27191. set(data: FloatArray, kind: string): void;
  27192. /**
  27193. * Associates the vertexData to the passed Mesh.
  27194. * Sets it as updatable or not (default `false`)
  27195. * @param mesh the mesh the vertexData is applied to
  27196. * @param updatable when used and having the value true allows new data to update the vertexData
  27197. * @returns the VertexData
  27198. */
  27199. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  27200. /**
  27201. * Associates the vertexData to the passed Geometry.
  27202. * Sets it as updatable or not (default `false`)
  27203. * @param geometry the geometry the vertexData is applied to
  27204. * @param updatable when used and having the value true allows new data to update the vertexData
  27205. * @returns VertexData
  27206. */
  27207. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  27208. /**
  27209. * Updates the associated mesh
  27210. * @param mesh the mesh to be updated
  27211. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  27212. * @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
  27213. * @returns VertexData
  27214. */
  27215. updateMesh(mesh: Mesh, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  27216. /**
  27217. * Updates the associated geometry
  27218. * @param geometry the geometry to be updated
  27219. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  27220. * @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
  27221. * @returns VertexData.
  27222. */
  27223. updateGeometry(geometry: Geometry, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  27224. private _applyTo;
  27225. private _update;
  27226. /**
  27227. * Transforms each position and each normal of the vertexData according to the passed Matrix
  27228. * @param matrix the transforming matrix
  27229. * @returns the VertexData
  27230. */
  27231. transform(matrix: Matrix): VertexData;
  27232. /**
  27233. * Merges the passed VertexData into the current one
  27234. * @param other the VertexData to be merged into the current one
  27235. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  27236. * @returns the modified VertexData
  27237. */
  27238. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  27239. private _mergeElement;
  27240. private _validate;
  27241. /**
  27242. * Serializes the VertexData
  27243. * @returns a serialized object
  27244. */
  27245. serialize(): any;
  27246. /**
  27247. * Extracts the vertexData from a mesh
  27248. * @param mesh the mesh from which to extract the VertexData
  27249. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  27250. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  27251. * @returns the object VertexData associated to the passed mesh
  27252. */
  27253. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  27254. /**
  27255. * Extracts the vertexData from the geometry
  27256. * @param geometry the geometry from which to extract the VertexData
  27257. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  27258. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  27259. * @returns the object VertexData associated to the passed mesh
  27260. */
  27261. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  27262. private static _ExtractFrom;
  27263. /**
  27264. * Creates the VertexData for a Ribbon
  27265. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  27266. * * pathArray array of paths, each of which an array of successive Vector3
  27267. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  27268. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  27269. * * 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
  27270. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27271. * * 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)
  27272. * * 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)
  27273. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  27274. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  27275. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  27276. * @returns the VertexData of the ribbon
  27277. */
  27278. static CreateRibbon(options: {
  27279. pathArray: Vector3[][];
  27280. closeArray?: boolean;
  27281. closePath?: boolean;
  27282. offset?: number;
  27283. sideOrientation?: number;
  27284. frontUVs?: Vector4;
  27285. backUVs?: Vector4;
  27286. invertUV?: boolean;
  27287. uvs?: Vector2[];
  27288. colors?: Color4[];
  27289. }): VertexData;
  27290. /**
  27291. * Creates the VertexData for a box
  27292. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27293. * * size sets the width, height and depth of the box to the value of size, optional default 1
  27294. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  27295. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  27296. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  27297. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  27298. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  27299. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27300. * * 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)
  27301. * * 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)
  27302. * @returns the VertexData of the box
  27303. */
  27304. static CreateBox(options: {
  27305. size?: number;
  27306. width?: number;
  27307. height?: number;
  27308. depth?: number;
  27309. faceUV?: Vector4[];
  27310. faceColors?: Color4[];
  27311. sideOrientation?: number;
  27312. frontUVs?: Vector4;
  27313. backUVs?: Vector4;
  27314. }): VertexData;
  27315. /**
  27316. * Creates the VertexData for an ellipsoid, defaults to a sphere
  27317. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27318. * * segments sets the number of horizontal strips optional, default 32
  27319. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  27320. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  27321. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  27322. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  27323. * * 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
  27324. * * 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
  27325. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27326. * * 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)
  27327. * * 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)
  27328. * @returns the VertexData of the ellipsoid
  27329. */
  27330. static CreateSphere(options: {
  27331. segments?: number;
  27332. diameter?: number;
  27333. diameterX?: number;
  27334. diameterY?: number;
  27335. diameterZ?: number;
  27336. arc?: number;
  27337. slice?: number;
  27338. sideOrientation?: number;
  27339. frontUVs?: Vector4;
  27340. backUVs?: Vector4;
  27341. }): VertexData;
  27342. /**
  27343. * Creates the VertexData for a cylinder, cone or prism
  27344. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27345. * * height sets the height (y direction) of the cylinder, optional, default 2
  27346. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  27347. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  27348. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  27349. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  27350. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  27351. * * 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
  27352. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27353. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27354. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  27355. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  27356. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27357. * * 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)
  27358. * * 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)
  27359. * @returns the VertexData of the cylinder, cone or prism
  27360. */
  27361. static CreateCylinder(options: {
  27362. height?: number;
  27363. diameterTop?: number;
  27364. diameterBottom?: number;
  27365. diameter?: number;
  27366. tessellation?: number;
  27367. subdivisions?: number;
  27368. arc?: number;
  27369. faceColors?: Color4[];
  27370. faceUV?: Vector4[];
  27371. hasRings?: boolean;
  27372. enclose?: boolean;
  27373. sideOrientation?: number;
  27374. frontUVs?: Vector4;
  27375. backUVs?: Vector4;
  27376. }): VertexData;
  27377. /**
  27378. * Creates the VertexData for a torus
  27379. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27380. * * diameter the diameter of the torus, optional default 1
  27381. * * thickness the diameter of the tube forming the torus, optional default 0.5
  27382. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  27383. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27384. * * 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)
  27385. * * 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)
  27386. * @returns the VertexData of the torus
  27387. */
  27388. static CreateTorus(options: {
  27389. diameter?: number;
  27390. thickness?: number;
  27391. tessellation?: number;
  27392. sideOrientation?: number;
  27393. frontUVs?: Vector4;
  27394. backUVs?: Vector4;
  27395. }): VertexData;
  27396. /**
  27397. * Creates the VertexData of the LineSystem
  27398. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  27399. * - lines an array of lines, each line being an array of successive Vector3
  27400. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  27401. * @returns the VertexData of the LineSystem
  27402. */
  27403. static CreateLineSystem(options: {
  27404. lines: Vector3[][];
  27405. colors?: Nullable<Color4[][]>;
  27406. }): VertexData;
  27407. /**
  27408. * Create the VertexData for a DashedLines
  27409. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  27410. * - points an array successive Vector3
  27411. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  27412. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  27413. * - dashNb the intended total number of dashes, optional, default 200
  27414. * @returns the VertexData for the DashedLines
  27415. */
  27416. static CreateDashedLines(options: {
  27417. points: Vector3[];
  27418. dashSize?: number;
  27419. gapSize?: number;
  27420. dashNb?: number;
  27421. }): VertexData;
  27422. /**
  27423. * Creates the VertexData for a Ground
  27424. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  27425. * - width the width (x direction) of the ground, optional, default 1
  27426. * - height the height (z direction) of the ground, optional, default 1
  27427. * - subdivisions the number of subdivisions per side, optional, default 1
  27428. * @returns the VertexData of the Ground
  27429. */
  27430. static CreateGround(options: {
  27431. width?: number;
  27432. height?: number;
  27433. subdivisions?: number;
  27434. subdivisionsX?: number;
  27435. subdivisionsY?: number;
  27436. }): VertexData;
  27437. /**
  27438. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  27439. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  27440. * * xmin the ground minimum X coordinate, optional, default -1
  27441. * * zmin the ground minimum Z coordinate, optional, default -1
  27442. * * xmax the ground maximum X coordinate, optional, default 1
  27443. * * zmax the ground maximum Z coordinate, optional, default 1
  27444. * * 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}
  27445. * * 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}
  27446. * @returns the VertexData of the TiledGround
  27447. */
  27448. static CreateTiledGround(options: {
  27449. xmin: number;
  27450. zmin: number;
  27451. xmax: number;
  27452. zmax: number;
  27453. subdivisions?: {
  27454. w: number;
  27455. h: number;
  27456. };
  27457. precision?: {
  27458. w: number;
  27459. h: number;
  27460. };
  27461. }): VertexData;
  27462. /**
  27463. * Creates the VertexData of the Ground designed from a heightmap
  27464. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  27465. * * width the width (x direction) of the ground
  27466. * * height the height (z direction) of the ground
  27467. * * subdivisions the number of subdivisions per side
  27468. * * minHeight the minimum altitude on the ground, optional, default 0
  27469. * * maxHeight the maximum altitude on the ground, optional default 1
  27470. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  27471. * * buffer the array holding the image color data
  27472. * * bufferWidth the width of image
  27473. * * bufferHeight the height of image
  27474. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  27475. * @returns the VertexData of the Ground designed from a heightmap
  27476. */
  27477. static CreateGroundFromHeightMap(options: {
  27478. width: number;
  27479. height: number;
  27480. subdivisions: number;
  27481. minHeight: number;
  27482. maxHeight: number;
  27483. colorFilter: Color3;
  27484. buffer: Uint8Array;
  27485. bufferWidth: number;
  27486. bufferHeight: number;
  27487. alphaFilter: number;
  27488. }): VertexData;
  27489. /**
  27490. * Creates the VertexData for a Plane
  27491. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  27492. * * size sets the width and height of the plane to the value of size, optional default 1
  27493. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  27494. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  27495. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27496. * * 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)
  27497. * * 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)
  27498. * @returns the VertexData of the box
  27499. */
  27500. static CreatePlane(options: {
  27501. size?: number;
  27502. width?: number;
  27503. height?: number;
  27504. sideOrientation?: number;
  27505. frontUVs?: Vector4;
  27506. backUVs?: Vector4;
  27507. }): VertexData;
  27508. /**
  27509. * Creates the VertexData of the Disc or regular Polygon
  27510. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  27511. * * radius the radius of the disc, optional default 0.5
  27512. * * tessellation the number of polygon sides, optional, default 64
  27513. * * 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
  27514. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27515. * * 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)
  27516. * * 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)
  27517. * @returns the VertexData of the box
  27518. */
  27519. static CreateDisc(options: {
  27520. radius?: number;
  27521. tessellation?: number;
  27522. arc?: number;
  27523. sideOrientation?: number;
  27524. frontUVs?: Vector4;
  27525. backUVs?: Vector4;
  27526. }): VertexData;
  27527. /**
  27528. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  27529. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  27530. * @param polygon a mesh built from polygonTriangulation.build()
  27531. * @param sideOrientation takes the values BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27532. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27533. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27534. * @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)
  27535. * @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)
  27536. * @returns the VertexData of the Polygon
  27537. */
  27538. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  27539. /**
  27540. * Creates the VertexData of the IcoSphere
  27541. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  27542. * * radius the radius of the IcoSphere, optional default 1
  27543. * * radiusX allows stretching in the x direction, optional, default radius
  27544. * * radiusY allows stretching in the y direction, optional, default radius
  27545. * * radiusZ allows stretching in the z direction, optional, default radius
  27546. * * flat when true creates a flat shaded mesh, optional, default true
  27547. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  27548. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27549. * * 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)
  27550. * * 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)
  27551. * @returns the VertexData of the IcoSphere
  27552. */
  27553. static CreateIcoSphere(options: {
  27554. radius?: number;
  27555. radiusX?: number;
  27556. radiusY?: number;
  27557. radiusZ?: number;
  27558. flat?: boolean;
  27559. subdivisions?: number;
  27560. sideOrientation?: number;
  27561. frontUVs?: Vector4;
  27562. backUVs?: Vector4;
  27563. }): VertexData;
  27564. /**
  27565. * Creates the VertexData for a Polyhedron
  27566. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  27567. * * type provided types are:
  27568. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  27569. * * 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)
  27570. * * size the size of the IcoSphere, optional default 1
  27571. * * sizeX allows stretching in the x direction, optional, default size
  27572. * * sizeY allows stretching in the y direction, optional, default size
  27573. * * sizeZ allows stretching in the z direction, optional, default size
  27574. * * 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
  27575. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27576. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27577. * * flat when true creates a flat shaded mesh, optional, default true
  27578. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  27579. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27580. * * 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)
  27581. * * 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)
  27582. * @returns the VertexData of the Polyhedron
  27583. */
  27584. static CreatePolyhedron(options: {
  27585. type?: number;
  27586. size?: number;
  27587. sizeX?: number;
  27588. sizeY?: number;
  27589. sizeZ?: number;
  27590. custom?: any;
  27591. faceUV?: Vector4[];
  27592. faceColors?: Color4[];
  27593. flat?: boolean;
  27594. sideOrientation?: number;
  27595. frontUVs?: Vector4;
  27596. backUVs?: Vector4;
  27597. }): VertexData;
  27598. /**
  27599. * Creates the VertexData for a TorusKnot
  27600. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  27601. * * radius the radius of the torus knot, optional, default 2
  27602. * * tube the thickness of the tube, optional, default 0.5
  27603. * * radialSegments the number of sides on each tube segments, optional, default 32
  27604. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  27605. * * p the number of windings around the z axis, optional, default 2
  27606. * * q the number of windings around the x axis, optional, default 3
  27607. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27608. * * 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)
  27609. * * 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)
  27610. * @returns the VertexData of the Torus Knot
  27611. */
  27612. static CreateTorusKnot(options: {
  27613. radius?: number;
  27614. tube?: number;
  27615. radialSegments?: number;
  27616. tubularSegments?: number;
  27617. p?: number;
  27618. q?: number;
  27619. sideOrientation?: number;
  27620. frontUVs?: Vector4;
  27621. backUVs?: Vector4;
  27622. }): VertexData;
  27623. /**
  27624. * Compute normals for given positions and indices
  27625. * @param positions an array of vertex positions, [...., x, y, z, ......]
  27626. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  27627. * @param normals an array of vertex normals, [...., x, y, z, ......]
  27628. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  27629. * * facetNormals : optional array of facet normals (vector3)
  27630. * * facetPositions : optional array of facet positions (vector3)
  27631. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  27632. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  27633. * * bInfo : optional bounding info, required for facetPartitioning computation
  27634. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  27635. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  27636. * * useRightHandedSystem: optional boolean to for right handed system computation
  27637. * * depthSort : optional boolean to enable the facet depth sort computation
  27638. * * distanceTo : optional Vector3 to compute the facet depth from this location
  27639. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  27640. */
  27641. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  27642. facetNormals?: any;
  27643. facetPositions?: any;
  27644. facetPartitioning?: any;
  27645. ratio?: number;
  27646. bInfo?: any;
  27647. bbSize?: Vector3;
  27648. subDiv?: any;
  27649. useRightHandedSystem?: boolean;
  27650. depthSort?: boolean;
  27651. distanceTo?: Vector3;
  27652. depthSortedFacets?: any;
  27653. }): void;
  27654. private static _ComputeSides;
  27655. /**
  27656. * Applies VertexData created from the imported parameters to the geometry
  27657. * @param parsedVertexData the parsed data from an imported file
  27658. * @param geometry the geometry to apply the VertexData to
  27659. */
  27660. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  27661. }
  27662. }
  27663. declare module BABYLON {
  27664. /**
  27665. * Class containing static functions to help procedurally build meshes
  27666. */
  27667. class MeshBuilder {
  27668. private static updateSideOrientation;
  27669. /**
  27670. * Creates a box mesh
  27671. * * The parameter `size` sets the size (float) of each box side (default 1)
  27672. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  27673. * * 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)
  27674. * * Please read this tutorial : http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  27675. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27676. * * 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
  27677. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27678. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#box
  27679. * @param name defines the name of the mesh
  27680. * @param options defines the options used to create the mesh
  27681. * @param scene defines the hosting scene
  27682. * @returns the box mesh
  27683. */
  27684. static CreateBox(name: string, options: {
  27685. size?: number;
  27686. width?: number;
  27687. height?: number;
  27688. depth?: number;
  27689. faceUV?: Vector4[];
  27690. faceColors?: Color4[];
  27691. sideOrientation?: number;
  27692. frontUVs?: Vector4;
  27693. backUVs?: Vector4;
  27694. updatable?: boolean;
  27695. }, scene?: Nullable<Scene>): Mesh;
  27696. /**
  27697. * Creates a sphere mesh
  27698. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  27699. * * 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`)
  27700. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  27701. * * 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
  27702. * * 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)
  27703. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27704. * * 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
  27705. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27706. * @param name defines the name of the mesh
  27707. * @param options defines the options used to create the mesh
  27708. * @param scene defines the hosting scene
  27709. * @returns the sphere mesh
  27710. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#sphere
  27711. */
  27712. static CreateSphere(name: string, options: {
  27713. segments?: number;
  27714. diameter?: number;
  27715. diameterX?: number;
  27716. diameterY?: number;
  27717. diameterZ?: number;
  27718. arc?: number;
  27719. slice?: number;
  27720. sideOrientation?: number;
  27721. frontUVs?: Vector4;
  27722. backUVs?: Vector4;
  27723. updatable?: boolean;
  27724. }, scene: any): Mesh;
  27725. /**
  27726. * Creates a plane polygonal mesh. By default, this is a disc
  27727. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  27728. * * 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
  27729. * * 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
  27730. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27731. * * 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
  27732. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27733. * @param name defines the name of the mesh
  27734. * @param options defines the options used to create the mesh
  27735. * @param scene defines the hosting scene
  27736. * @returns the plane polygonal mesh
  27737. * @see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  27738. */
  27739. static CreateDisc(name: string, options: {
  27740. radius?: number;
  27741. tessellation?: number;
  27742. arc?: number;
  27743. updatable?: boolean;
  27744. sideOrientation?: number;
  27745. frontUVs?: Vector4;
  27746. backUVs?: Vector4;
  27747. }, scene?: Nullable<Scene>): Mesh;
  27748. /**
  27749. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  27750. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  27751. * * 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`)
  27752. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  27753. * * 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
  27754. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27755. * * 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
  27756. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27757. * @param name defines the name of the mesh
  27758. * @param options defines the options used to create the mesh
  27759. * @param scene defines the hosting scene
  27760. * @returns the icosahedron mesh
  27761. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  27762. */
  27763. static CreateIcoSphere(name: string, options: {
  27764. radius?: number;
  27765. radiusX?: number;
  27766. radiusY?: number;
  27767. radiusZ?: number;
  27768. flat?: boolean;
  27769. subdivisions?: number;
  27770. sideOrientation?: number;
  27771. frontUVs?: Vector4;
  27772. backUVs?: Vector4;
  27773. updatable?: boolean;
  27774. }, scene: Scene): Mesh;
  27775. /**
  27776. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  27777. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  27778. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  27779. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  27780. * * 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
  27781. * * 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
  27782. * * The optional parameter `instance` is an instance of an existing Ribbon object to be updated with the passed `pathArray` parameter : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#ribbon
  27783. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27784. * * 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
  27785. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  27786. * * 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
  27787. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  27788. * * 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
  27789. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  27790. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27791. * @param name defines the name of the mesh
  27792. * @param options defines the options used to create the mesh
  27793. * @param scene defines the hosting scene
  27794. * @returns the ribbon mesh
  27795. * @see http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  27796. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  27797. */
  27798. static CreateRibbon(name: string, options: {
  27799. pathArray: Vector3[][];
  27800. closeArray?: boolean;
  27801. closePath?: boolean;
  27802. offset?: number;
  27803. updatable?: boolean;
  27804. sideOrientation?: number;
  27805. frontUVs?: Vector4;
  27806. backUVs?: Vector4;
  27807. instance?: Mesh;
  27808. invertUV?: boolean;
  27809. uvs?: Vector2[];
  27810. colors?: Color4[];
  27811. }, scene?: Nullable<Scene>): Mesh;
  27812. /**
  27813. * Creates a cylinder or a cone mesh
  27814. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  27815. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  27816. * * 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.
  27817. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  27818. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  27819. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  27820. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  27821. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  27822. * * 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).
  27823. * * 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
  27824. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  27825. * * 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
  27826. * * 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.
  27827. * * If `enclose` is false, a ring surface is one element.
  27828. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  27829. * * Example how to set colors and textures on a sliced cylinder : http://www.html5gamedevs.com/topic/17945-creating-a-closed-slice-of-a-cylinder/#comment-106379
  27830. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27831. * * 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
  27832. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  27833. * @param name defines the name of the mesh
  27834. * @param options defines the options used to create the mesh
  27835. * @param scene defines the hosting scene
  27836. * @returns the cylinder mesh
  27837. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#cylinder-or-cone
  27838. */
  27839. static CreateCylinder(name: string, options: {
  27840. height?: number;
  27841. diameterTop?: number;
  27842. diameterBottom?: number;
  27843. diameter?: number;
  27844. tessellation?: number;
  27845. subdivisions?: number;
  27846. arc?: number;
  27847. faceColors?: Color4[];
  27848. faceUV?: Vector4[];
  27849. updatable?: boolean;
  27850. hasRings?: boolean;
  27851. enclose?: boolean;
  27852. sideOrientation?: number;
  27853. frontUVs?: Vector4;
  27854. backUVs?: Vector4;
  27855. }, scene: any): Mesh;
  27856. /**
  27857. * Creates a torus mesh
  27858. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  27859. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  27860. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  27861. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27862. * * 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
  27863. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  27864. * @param name defines the name of the mesh
  27865. * @param options defines the options used to create the mesh
  27866. * @param scene defines the hosting scene
  27867. * @returns the torus mesh
  27868. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus
  27869. */
  27870. static CreateTorus(name: string, options: {
  27871. diameter?: number;
  27872. thickness?: number;
  27873. tessellation?: number;
  27874. updatable?: boolean;
  27875. sideOrientation?: number;
  27876. frontUVs?: Vector4;
  27877. backUVs?: Vector4;
  27878. }, scene: any): Mesh;
  27879. /**
  27880. * Creates a torus knot mesh
  27881. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  27882. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  27883. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  27884. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  27885. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27886. * * 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
  27887. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  27888. * @param name defines the name of the mesh
  27889. * @param options defines the options used to create the mesh
  27890. * @param scene defines the hosting scene
  27891. * @returns the torus knot mesh
  27892. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus-knot
  27893. */
  27894. static CreateTorusKnot(name: string, options: {
  27895. radius?: number;
  27896. tube?: number;
  27897. radialSegments?: number;
  27898. tubularSegments?: number;
  27899. p?: number;
  27900. q?: number;
  27901. updatable?: boolean;
  27902. sideOrientation?: number;
  27903. frontUVs?: Vector4;
  27904. backUVs?: Vector4;
  27905. }, scene: any): Mesh;
  27906. /**
  27907. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  27908. * * 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
  27909. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  27910. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  27911. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  27912. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  27913. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  27914. * * Updating a simple Line mesh, you just need to update every line in the `lines` array : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#lines-and-dashedlines
  27915. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  27916. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27917. * @see http://doc.babylonjs.com/how_to/parametric_shapes#line-system
  27918. * @param name defines the name of the new line system
  27919. * @param options defines the options used to create the line system
  27920. * @param scene defines the hosting scene
  27921. * @returns a new line system mesh
  27922. */
  27923. static CreateLineSystem(name: string, options: {
  27924. lines: Vector3[][];
  27925. updatable?: boolean;
  27926. instance?: Nullable<LinesMesh>;
  27927. colors?: Nullable<Color4[][]>;
  27928. useVertexAlpha?: boolean;
  27929. }, scene: Nullable<Scene>): LinesMesh;
  27930. /**
  27931. * Creates a line mesh
  27932. * 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
  27933. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  27934. * * The parameter `points` is an array successive Vector3
  27935. * * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#lines-and-dashedlines
  27936. * * The optional parameter `colors` is an array of successive Color4, one per line point
  27937. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  27938. * * When updating an instance, remember that only point positions can change, not the number of points
  27939. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27940. * @see http://doc.babylonjs.com/how_to/parametric_shapes#lines
  27941. * @param name defines the name of the new line system
  27942. * @param options defines the options used to create the line system
  27943. * @param scene defines the hosting scene
  27944. * @returns a new line mesh
  27945. */
  27946. static CreateLines(name: string, options: {
  27947. points: Vector3[];
  27948. updatable?: boolean;
  27949. instance?: Nullable<LinesMesh>;
  27950. colors?: Color4[];
  27951. useVertexAlpha?: boolean;
  27952. }, scene?: Nullable<Scene>): LinesMesh;
  27953. /**
  27954. * Creates a dashed line mesh
  27955. * * 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
  27956. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  27957. * * The parameter `points` is an array successive Vector3
  27958. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  27959. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  27960. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  27961. * * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#lines-and-dashedlines
  27962. * * When updating an instance, remember that only point positions can change, not the number of points
  27963. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27964. * @param name defines the name of the mesh
  27965. * @param options defines the options used to create the mesh
  27966. * @param scene defines the hosting scene
  27967. * @returns the dashed line mesh
  27968. * @see http://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  27969. */
  27970. static CreateDashedLines(name: string, options: {
  27971. points: Vector3[];
  27972. dashSize?: number;
  27973. gapSize?: number;
  27974. dashNb?: number;
  27975. updatable?: boolean;
  27976. instance?: LinesMesh;
  27977. }, scene?: Nullable<Scene>): LinesMesh;
  27978. /**
  27979. * 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.
  27980. * * 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.
  27981. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  27982. * * 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.
  27983. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  27984. * * 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
  27985. * * The optional parameter `instance` is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#extruded-shape
  27986. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  27987. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27988. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  27989. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  27990. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  27991. * @param name defines the name of the mesh
  27992. * @param options defines the options used to create the mesh
  27993. * @param scene defines the hosting scene
  27994. * @returns the extruded shape mesh
  27995. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  27996. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  27997. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  27998. */
  27999. static ExtrudeShape(name: string, options: {
  28000. shape: Vector3[];
  28001. path: Vector3[];
  28002. scale?: number;
  28003. rotation?: number;
  28004. cap?: number;
  28005. updatable?: boolean;
  28006. sideOrientation?: number;
  28007. frontUVs?: Vector4;
  28008. backUVs?: Vector4;
  28009. instance?: Mesh;
  28010. invertUV?: boolean;
  28011. }, scene?: Nullable<Scene>): Mesh;
  28012. /**
  28013. * Creates an custom extruded shape mesh.
  28014. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  28015. * * 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.
  28016. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  28017. * * 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
  28018. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  28019. * * 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
  28020. * * It must returns a float value that will be the scale value applied to the shape on each path point
  28021. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  28022. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  28023. * * 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
  28024. * * The optional parameter `instance` is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#extruded-shape
  28025. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  28026. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28027. * * 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
  28028. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  28029. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28030. * @param name defines the name of the mesh
  28031. * @param options defines the options used to create the mesh
  28032. * @param scene defines the hosting scene
  28033. * @returns the custom extruded shape mesh
  28034. * @see http://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  28035. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  28036. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28037. */
  28038. static ExtrudeShapeCustom(name: string, options: {
  28039. shape: Vector3[];
  28040. path: Vector3[];
  28041. scaleFunction?: any;
  28042. rotationFunction?: any;
  28043. ribbonCloseArray?: boolean;
  28044. ribbonClosePath?: boolean;
  28045. cap?: number;
  28046. updatable?: boolean;
  28047. sideOrientation?: number;
  28048. frontUVs?: Vector4;
  28049. backUVs?: Vector4;
  28050. instance?: Mesh;
  28051. invertUV?: boolean;
  28052. }, scene: Scene): Mesh;
  28053. /**
  28054. * Creates lathe mesh.
  28055. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  28056. * * 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
  28057. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  28058. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  28059. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  28060. * * 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
  28061. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  28062. * * 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
  28063. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28064. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  28065. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  28066. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28067. * @param name defines the name of the mesh
  28068. * @param options defines the options used to create the mesh
  28069. * @param scene defines the hosting scene
  28070. * @returns the lathe mesh
  28071. * @see http://doc.babylonjs.com/how_to/parametric_shapes#lathe
  28072. */
  28073. static CreateLathe(name: string, options: {
  28074. shape: Vector3[];
  28075. radius?: number;
  28076. tessellation?: number;
  28077. clip?: number;
  28078. arc?: number;
  28079. closed?: boolean;
  28080. updatable?: boolean;
  28081. sideOrientation?: number;
  28082. frontUVs?: Vector4;
  28083. backUVs?: Vector4;
  28084. cap?: number;
  28085. invertUV?: boolean;
  28086. }, scene: Scene): Mesh;
  28087. /**
  28088. * Creates a plane mesh
  28089. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  28090. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  28091. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  28092. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28093. * * 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
  28094. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28095. * @param name defines the name of the mesh
  28096. * @param options defines the options used to create the mesh
  28097. * @param scene defines the hosting scene
  28098. * @returns the plane mesh
  28099. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  28100. */
  28101. static CreatePlane(name: string, options: {
  28102. size?: number;
  28103. width?: number;
  28104. height?: number;
  28105. sideOrientation?: number;
  28106. frontUVs?: Vector4;
  28107. backUVs?: Vector4;
  28108. updatable?: boolean;
  28109. sourcePlane?: Plane;
  28110. }, scene: Scene): Mesh;
  28111. /**
  28112. * Creates a ground mesh
  28113. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  28114. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  28115. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28116. * @param name defines the name of the mesh
  28117. * @param options defines the options used to create the mesh
  28118. * @param scene defines the hosting scene
  28119. * @returns the ground mesh
  28120. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  28121. */
  28122. static CreateGround(name: string, options: {
  28123. width?: number;
  28124. height?: number;
  28125. subdivisions?: number;
  28126. subdivisionsX?: number;
  28127. subdivisionsY?: number;
  28128. updatable?: boolean;
  28129. }, scene: any): Mesh;
  28130. /**
  28131. * Creates a tiled ground mesh
  28132. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  28133. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  28134. * * 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
  28135. * * 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
  28136. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28137. * @param name defines the name of the mesh
  28138. * @param options defines the options used to create the mesh
  28139. * @param scene defines the hosting scene
  28140. * @returns the tiled ground mesh
  28141. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tiled-ground
  28142. */
  28143. static CreateTiledGround(name: string, options: {
  28144. xmin: number;
  28145. zmin: number;
  28146. xmax: number;
  28147. zmax: number;
  28148. subdivisions?: {
  28149. w: number;
  28150. h: number;
  28151. };
  28152. precision?: {
  28153. w: number;
  28154. h: number;
  28155. };
  28156. updatable?: boolean;
  28157. }, scene: Scene): Mesh;
  28158. /**
  28159. * Creates a ground mesh from a height map
  28160. * * The parameter `url` sets the URL of the height map image resource.
  28161. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  28162. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  28163. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  28164. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  28165. * * 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.
  28166. * * 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).
  28167. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  28168. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28169. * @param name defines the name of the mesh
  28170. * @param url defines the url to the height map
  28171. * @param options defines the options used to create the mesh
  28172. * @param scene defines the hosting scene
  28173. * @returns the ground mesh
  28174. * @see http://doc.babylonjs.com/babylon101/height_map
  28175. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#ground-from-a-height-map
  28176. */
  28177. static CreateGroundFromHeightMap(name: string, url: string, options: {
  28178. width?: number;
  28179. height?: number;
  28180. subdivisions?: number;
  28181. minHeight?: number;
  28182. maxHeight?: number;
  28183. colorFilter?: Color3;
  28184. alphaFilter?: number;
  28185. updatable?: boolean;
  28186. onReady?: (mesh: GroundMesh) => void;
  28187. }, scene: Scene): GroundMesh;
  28188. /**
  28189. * Creates a polygon mesh
  28190. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  28191. * * 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
  28192. * * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28193. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28194. * * 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)
  28195. * * Remember you can only change the shape positions, not their number when updating a polygon
  28196. * @param name defines the name of the mesh
  28197. * @param options defines the options used to create the mesh
  28198. * @param scene defines the hosting scene
  28199. * @returns the polygon mesh
  28200. */
  28201. static CreatePolygon(name: string, options: {
  28202. shape: Vector3[];
  28203. holes?: Vector3[][];
  28204. depth?: number;
  28205. faceUV?: Vector4[];
  28206. faceColors?: Color4[];
  28207. updatable?: boolean;
  28208. sideOrientation?: number;
  28209. frontUVs?: Vector4;
  28210. backUVs?: Vector4;
  28211. }, scene: Scene): Mesh;
  28212. /**
  28213. * Creates an extruded polygon mesh, with depth in the Y direction.
  28214. * * 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)
  28215. * @see http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  28216. * @param name defines the name of the mesh
  28217. * @param options defines the options used to create the mesh
  28218. * @param scene defines the hosting scene
  28219. * @returns the polygon mesh
  28220. */
  28221. static ExtrudePolygon(name: string, options: {
  28222. shape: Vector3[];
  28223. holes?: Vector3[][];
  28224. depth?: number;
  28225. faceUV?: Vector4[];
  28226. faceColors?: Color4[];
  28227. updatable?: boolean;
  28228. sideOrientation?: number;
  28229. frontUVs?: Vector4;
  28230. backUVs?: Vector4;
  28231. }, scene: Scene): Mesh;
  28232. /**
  28233. * Creates a tube mesh.
  28234. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  28235. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  28236. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  28237. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  28238. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  28239. * * 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)
  28240. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  28241. * * 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
  28242. * * The optional parameter `instance` is an instance of an existing Tube object to be updated with the passed `pathArray` parameter : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#tube
  28243. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28244. * * 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
  28245. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  28246. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28247. * @param name defines the name of the mesh
  28248. * @param options defines the options used to create the mesh
  28249. * @param scene defines the hosting scene
  28250. * @returns the tube mesh
  28251. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  28252. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tube
  28253. */
  28254. static CreateTube(name: string, options: {
  28255. path: Vector3[];
  28256. radius?: number;
  28257. tessellation?: number;
  28258. radiusFunction?: {
  28259. (i: number, distance: number): number;
  28260. };
  28261. cap?: number;
  28262. arc?: number;
  28263. updatable?: boolean;
  28264. sideOrientation?: number;
  28265. frontUVs?: Vector4;
  28266. backUVs?: Vector4;
  28267. instance?: Mesh;
  28268. invertUV?: boolean;
  28269. }, scene: Scene): Mesh;
  28270. /**
  28271. * Creates a polyhedron mesh
  28272. * * 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
  28273. * * The parameter `size` (positive float, default 1) sets the polygon size
  28274. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  28275. * * 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`
  28276. * * 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
  28277. * * 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)`)
  28278. * * To understand how to set `faceUV` or `faceColors`, please read this by considering the right number of faces of your polyhedron, instead of only 6 for the box : http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  28279. * * 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
  28280. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28281. * * 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
  28282. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28283. * @param name defines the name of the mesh
  28284. * @param options defines the options used to create the mesh
  28285. * @param scene defines the hosting scene
  28286. * @returns the polyhedron mesh
  28287. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes
  28288. */
  28289. static CreatePolyhedron(name: string, options: {
  28290. type?: number;
  28291. size?: number;
  28292. sizeX?: number;
  28293. sizeY?: number;
  28294. sizeZ?: number;
  28295. custom?: any;
  28296. faceUV?: Vector4[];
  28297. faceColors?: Color4[];
  28298. flat?: boolean;
  28299. updatable?: boolean;
  28300. sideOrientation?: number;
  28301. frontUVs?: Vector4;
  28302. backUVs?: Vector4;
  28303. }, scene: Scene): Mesh;
  28304. /**
  28305. * Creates a decal mesh.
  28306. * 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
  28307. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  28308. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  28309. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  28310. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  28311. * @param name defines the name of the mesh
  28312. * @param sourceMesh defines the mesh where the decal must be applied
  28313. * @param options defines the options used to create the mesh
  28314. * @param scene defines the hosting scene
  28315. * @returns the decal mesh
  28316. * @see http://doc.babylonjs.com/how_to/decals
  28317. */
  28318. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  28319. position?: Vector3;
  28320. normal?: Vector3;
  28321. size?: Vector3;
  28322. angle?: number;
  28323. }): Mesh;
  28324. private static _ExtrudeShapeGeneric;
  28325. }
  28326. }
  28327. declare module BABYLON {
  28328. /**
  28329. * Class used to represent a specific level of detail of a mesh
  28330. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  28331. */
  28332. class MeshLODLevel {
  28333. /** Defines the distance where this level should star being displayed */
  28334. distance: number;
  28335. /** Defines the mesh to use to render this level */
  28336. mesh: Nullable<Mesh>;
  28337. /**
  28338. * Creates a new LOD level
  28339. * @param distance defines the distance where this level should star being displayed
  28340. * @param mesh defines the mesh to use to render this level
  28341. */
  28342. constructor(
  28343. /** Defines the distance where this level should star being displayed */
  28344. distance: number,
  28345. /** Defines the mesh to use to render this level */
  28346. mesh: Nullable<Mesh>);
  28347. }
  28348. }
  28349. declare module BABYLON {
  28350. /**
  28351. * A simplifier interface for future simplification implementations
  28352. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28353. */
  28354. interface ISimplifier {
  28355. /**
  28356. * Simplification of a given mesh according to the given settings.
  28357. * Since this requires computation, it is assumed that the function runs async.
  28358. * @param settings The settings of the simplification, including quality and distance
  28359. * @param successCallback A callback that will be called after the mesh was simplified.
  28360. * @param errorCallback in case of an error, this callback will be called. optional.
  28361. */
  28362. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  28363. }
  28364. /**
  28365. * Expected simplification settings.
  28366. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  28367. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28368. */
  28369. interface ISimplificationSettings {
  28370. /**
  28371. * Gets or sets the expected quality
  28372. */
  28373. quality: number;
  28374. /**
  28375. * Gets or sets the distance when this optimized version should be used
  28376. */
  28377. distance: number;
  28378. /**
  28379. * Gets an already optimized mesh
  28380. */
  28381. optimizeMesh?: boolean;
  28382. }
  28383. /**
  28384. * Class used to specify simplification options
  28385. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28386. */
  28387. class SimplificationSettings implements ISimplificationSettings {
  28388. /** expected quality */
  28389. quality: number;
  28390. /** distance when this optimized version should be used */
  28391. distance: number;
  28392. /** already optimized mesh */
  28393. optimizeMesh?: boolean | undefined;
  28394. /**
  28395. * Creates a SimplificationSettings
  28396. * @param quality expected quality
  28397. * @param distance distance when this optimized version should be used
  28398. * @param optimizeMesh already optimized mesh
  28399. */
  28400. constructor(
  28401. /** expected quality */
  28402. quality: number,
  28403. /** distance when this optimized version should be used */
  28404. distance: number,
  28405. /** already optimized mesh */
  28406. optimizeMesh?: boolean | undefined);
  28407. }
  28408. /**
  28409. * Interface used to define a simplification task
  28410. */
  28411. interface ISimplificationTask {
  28412. /**
  28413. * Array of settings
  28414. */
  28415. settings: Array<ISimplificationSettings>;
  28416. /**
  28417. * Simplification type
  28418. */
  28419. simplificationType: SimplificationType;
  28420. /**
  28421. * Mesh to simplify
  28422. */
  28423. mesh: Mesh;
  28424. /**
  28425. * Callback called on success
  28426. */
  28427. successCallback?: () => void;
  28428. /**
  28429. * Defines if parallel processing can be used
  28430. */
  28431. parallelProcessing: boolean;
  28432. }
  28433. /**
  28434. * Queue used to order the simplification tasks
  28435. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28436. */
  28437. class SimplificationQueue {
  28438. private _simplificationArray;
  28439. /**
  28440. * Gets a boolean indicating that the process is still running
  28441. */
  28442. running: boolean;
  28443. /**
  28444. * Creates a new queue
  28445. */
  28446. constructor();
  28447. /**
  28448. * Adds a new simplification task
  28449. * @param task defines a task to add
  28450. */
  28451. addTask(task: ISimplificationTask): void;
  28452. /**
  28453. * Execute next task
  28454. */
  28455. executeNext(): void;
  28456. /**
  28457. * Execute a simplification task
  28458. * @param task defines the task to run
  28459. */
  28460. runSimplification(task: ISimplificationTask): void;
  28461. private getSimplifier;
  28462. }
  28463. /**
  28464. * The implemented types of simplification
  28465. * At the moment only Quadratic Error Decimation is implemented
  28466. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28467. */
  28468. enum SimplificationType {
  28469. /** Quadratic error decimation */
  28470. QUADRATIC = 0
  28471. }
  28472. }
  28473. declare module BABYLON {
  28474. interface Scene {
  28475. /** @hidden (Backing field) */
  28476. _simplificationQueue: SimplificationQueue;
  28477. /**
  28478. * Gets or sets the simplification queue attached to the scene
  28479. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28480. */
  28481. simplificationQueue: SimplificationQueue;
  28482. }
  28483. interface Mesh {
  28484. /**
  28485. * Simplify the mesh according to the given array of settings.
  28486. * Function will return immediately and will simplify async
  28487. * @param settings a collection of simplification settings
  28488. * @param parallelProcessing should all levels calculate parallel or one after the other
  28489. * @param simplificationType the type of simplification to run
  28490. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  28491. * @returns the current mesh
  28492. */
  28493. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  28494. }
  28495. /**
  28496. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  28497. * created in a scene
  28498. */
  28499. class SimplicationQueueSceneComponent implements ISceneComponent {
  28500. /**
  28501. * The component name helpfull to identify the component in the list of scene components.
  28502. */
  28503. readonly name: string;
  28504. /**
  28505. * The scene the component belongs to.
  28506. */
  28507. scene: Scene;
  28508. /**
  28509. * Creates a new instance of the component for the given scene
  28510. * @param scene Defines the scene to register the component in
  28511. */
  28512. constructor(scene: Scene);
  28513. /**
  28514. * Registers the component in a given scene
  28515. */
  28516. register(): void;
  28517. /**
  28518. * Rebuilds the elements related to this component in case of
  28519. * context lost for instance.
  28520. */
  28521. rebuild(): void;
  28522. /**
  28523. * Disposes the component and the associated ressources
  28524. */
  28525. dispose(): void;
  28526. private _beforeCameraUpdate;
  28527. }
  28528. }
  28529. declare module BABYLON {
  28530. /**
  28531. * Polygon
  28532. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  28533. */
  28534. class Polygon {
  28535. /**
  28536. * Creates a rectangle
  28537. * @param xmin bottom X coord
  28538. * @param ymin bottom Y coord
  28539. * @param xmax top X coord
  28540. * @param ymax top Y coord
  28541. * @returns points that make the resulting rectation
  28542. */
  28543. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  28544. /**
  28545. * Creates a circle
  28546. * @param radius radius of circle
  28547. * @param cx scale in x
  28548. * @param cy scale in y
  28549. * @param numberOfSides number of sides that make up the circle
  28550. * @returns points that make the resulting circle
  28551. */
  28552. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  28553. /**
  28554. * Creates a polygon from input string
  28555. * @param input Input polygon data
  28556. * @returns the parsed points
  28557. */
  28558. static Parse(input: string): Vector2[];
  28559. /**
  28560. * Starts building a polygon from x and y coordinates
  28561. * @param x x coordinate
  28562. * @param y y coordinate
  28563. * @returns the started path2
  28564. */
  28565. static StartingAt(x: number, y: number): Path2;
  28566. }
  28567. /**
  28568. * Builds a polygon
  28569. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  28570. */
  28571. class PolygonMeshBuilder {
  28572. private _points;
  28573. private _outlinepoints;
  28574. private _holes;
  28575. private _name;
  28576. private _scene;
  28577. private _epoints;
  28578. private _eholes;
  28579. private _addToepoint;
  28580. /**
  28581. * Creates a PolygonMeshBuilder
  28582. * @param name name of the builder
  28583. * @param contours Path of the polygon
  28584. * @param scene scene to add to
  28585. */
  28586. constructor(name: string, contours: Path2 | Vector2[] | any, scene: Scene);
  28587. /**
  28588. * Adds a whole within the polygon
  28589. * @param hole Array of points defining the hole
  28590. * @returns this
  28591. */
  28592. addHole(hole: Vector2[]): PolygonMeshBuilder;
  28593. /**
  28594. * Creates the polygon
  28595. * @param updatable If the mesh should be updatable
  28596. * @param depth The depth of the mesh created
  28597. * @returns the created mesh
  28598. */
  28599. build(updatable?: boolean, depth?: number): Mesh;
  28600. /**
  28601. * Adds a side to the polygon
  28602. * @param positions points that make the polygon
  28603. * @param normals normals of the polygon
  28604. * @param uvs uvs of the polygon
  28605. * @param indices indices of the polygon
  28606. * @param bounds bounds of the polygon
  28607. * @param points points of the polygon
  28608. * @param depth depth of the polygon
  28609. * @param flip flip of the polygon
  28610. */
  28611. private addSide;
  28612. }
  28613. }
  28614. declare module BABYLON {
  28615. /**
  28616. * Base class for submeshes
  28617. */
  28618. class BaseSubMesh {
  28619. /** @hidden */
  28620. _materialDefines: Nullable<MaterialDefines>;
  28621. /** @hidden */
  28622. _materialEffect: Nullable<Effect>;
  28623. /**
  28624. * Gets associated effect
  28625. */
  28626. readonly effect: Nullable<Effect>;
  28627. /**
  28628. * Sets associated effect (effect used to render this submesh)
  28629. * @param effect defines the effect to associate with
  28630. * @param defines defines the set of defines used to compile this effect
  28631. */
  28632. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  28633. }
  28634. /**
  28635. * Defines a subdivision inside a mesh
  28636. */
  28637. class SubMesh extends BaseSubMesh implements ICullable {
  28638. /** the material index to use */
  28639. materialIndex: number;
  28640. /** vertex index start */
  28641. verticesStart: number;
  28642. /** vertices count */
  28643. verticesCount: number;
  28644. /** index start */
  28645. indexStart: number;
  28646. /** indices count */
  28647. indexCount: number;
  28648. /** @hidden */
  28649. _linesIndexCount: number;
  28650. private _mesh;
  28651. private _renderingMesh;
  28652. private _boundingInfo;
  28653. private _linesIndexBuffer;
  28654. /** @hidden */
  28655. _lastColliderWorldVertices: Nullable<Vector3[]>;
  28656. /** @hidden */
  28657. _trianglePlanes: Plane[];
  28658. /** @hidden */
  28659. _lastColliderTransformMatrix: Matrix;
  28660. /** @hidden */
  28661. _renderId: number;
  28662. /** @hidden */
  28663. _alphaIndex: number;
  28664. /** @hidden */
  28665. _distanceToCamera: number;
  28666. /** @hidden */
  28667. _id: number;
  28668. private _currentMaterial;
  28669. /**
  28670. * Add a new submesh to a mesh
  28671. * @param materialIndex defines the material index to use
  28672. * @param verticesStart defines vertex index start
  28673. * @param verticesCount defines vertices count
  28674. * @param indexStart defines index start
  28675. * @param indexCount defines indices count
  28676. * @param mesh defines the parent mesh
  28677. * @param renderingMesh defines an optional rendering mesh
  28678. * @param createBoundingBox defines if bounding box should be created for this submesh
  28679. * @returns the new submesh
  28680. */
  28681. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  28682. /**
  28683. * Creates a new submesh
  28684. * @param materialIndex defines the material index to use
  28685. * @param verticesStart defines vertex index start
  28686. * @param verticesCount defines vertices count
  28687. * @param indexStart defines index start
  28688. * @param indexCount defines indices count
  28689. * @param mesh defines the parent mesh
  28690. * @param renderingMesh defines an optional rendering mesh
  28691. * @param createBoundingBox defines if bounding box should be created for this submesh
  28692. */
  28693. constructor(
  28694. /** the material index to use */
  28695. materialIndex: number,
  28696. /** vertex index start */
  28697. verticesStart: number,
  28698. /** vertices count */
  28699. verticesCount: number,
  28700. /** index start */
  28701. indexStart: number,
  28702. /** indices count */
  28703. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  28704. /**
  28705. * Returns true if this submesh covers the entire parent mesh
  28706. * @ignorenaming
  28707. */
  28708. readonly IsGlobal: boolean;
  28709. /**
  28710. * Returns the submesh BoudingInfo object
  28711. * @returns current bounding info (or mesh's one if the submesh is global)
  28712. */
  28713. getBoundingInfo(): BoundingInfo;
  28714. /**
  28715. * Sets the submesh BoundingInfo
  28716. * @param boundingInfo defines the new bounding info to use
  28717. * @returns the SubMesh
  28718. */
  28719. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  28720. /**
  28721. * Returns the mesh of the current submesh
  28722. * @return the parent mesh
  28723. */
  28724. getMesh(): AbstractMesh;
  28725. /**
  28726. * Returns the rendering mesh of the submesh
  28727. * @returns the rendering mesh (could be different from parent mesh)
  28728. */
  28729. getRenderingMesh(): Mesh;
  28730. /**
  28731. * Returns the submesh material
  28732. * @returns null or the current material
  28733. */
  28734. getMaterial(): Nullable<Material>;
  28735. /**
  28736. * Sets a new updated BoundingInfo object to the submesh
  28737. * @returns the SubMesh
  28738. */
  28739. refreshBoundingInfo(): SubMesh;
  28740. /** @hidden */
  28741. _checkCollision(collider: Collider): boolean;
  28742. /**
  28743. * Updates the submesh BoundingInfo
  28744. * @param world defines the world matrix to use to update the bounding info
  28745. * @returns the submesh
  28746. */
  28747. updateBoundingInfo(world: Matrix): SubMesh;
  28748. /**
  28749. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  28750. * @param frustumPlanes defines the frustum planes
  28751. * @returns true if the submesh is intersecting with the frustum
  28752. */
  28753. isInFrustum(frustumPlanes: Plane[]): boolean;
  28754. /**
  28755. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  28756. * @param frustumPlanes defines the frustum planes
  28757. * @returns true if the submesh is inside the frustum
  28758. */
  28759. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  28760. /**
  28761. * Renders the submesh
  28762. * @param enableAlphaMode defines if alpha needs to be used
  28763. * @returns the submesh
  28764. */
  28765. render(enableAlphaMode: boolean): SubMesh;
  28766. /**
  28767. * @hidden
  28768. */
  28769. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  28770. /**
  28771. * Checks if the submesh intersects with a ray
  28772. * @param ray defines the ray to test
  28773. * @returns true is the passed ray intersects the submesh bounding box
  28774. */
  28775. canIntersects(ray: Ray): boolean;
  28776. /**
  28777. * Intersects current submesh with a ray
  28778. * @param ray defines the ray to test
  28779. * @param positions defines mesh's positions array
  28780. * @param indices defines mesh's indices array
  28781. * @param fastCheck defines if only bounding info should be used
  28782. * @returns intersection info or null if no intersection
  28783. */
  28784. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  28785. /** @hidden */
  28786. private _intersectLines;
  28787. /** @hidden */
  28788. private _intersectTriangles;
  28789. /** @hidden */
  28790. _rebuild(): void;
  28791. /**
  28792. * Creates a new submesh from the passed mesh
  28793. * @param newMesh defines the new hosting mesh
  28794. * @param newRenderingMesh defines an optional rendering mesh
  28795. * @returns the new submesh
  28796. */
  28797. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  28798. /**
  28799. * Release associated resources
  28800. */
  28801. dispose(): void;
  28802. /**
  28803. * Creates a new submesh from indices data
  28804. * @param materialIndex the index of the main mesh material
  28805. * @param startIndex the index where to start the copy in the mesh indices array
  28806. * @param indexCount the number of indices to copy then from the startIndex
  28807. * @param mesh the main mesh to create the submesh from
  28808. * @param renderingMesh the optional rendering mesh
  28809. * @returns a new submesh
  28810. */
  28811. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  28812. }
  28813. }
  28814. declare module BABYLON {
  28815. /**
  28816. * 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.
  28817. * @see https://doc.babylonjs.com/how_to/transformnode
  28818. */
  28819. class TransformNode extends Node {
  28820. /**
  28821. * Object will not rotate to face the camera
  28822. */
  28823. static BILLBOARDMODE_NONE: number;
  28824. /**
  28825. * Object will rotate to face the camera but only on the x axis
  28826. */
  28827. static BILLBOARDMODE_X: number;
  28828. /**
  28829. * Object will rotate to face the camera but only on the y axis
  28830. */
  28831. static BILLBOARDMODE_Y: number;
  28832. /**
  28833. * Object will rotate to face the camera but only on the z axis
  28834. */
  28835. static BILLBOARDMODE_Z: number;
  28836. /**
  28837. * Object will rotate to face the camera
  28838. */
  28839. static BILLBOARDMODE_ALL: number;
  28840. private _forward;
  28841. private _forwardInverted;
  28842. private _up;
  28843. private _right;
  28844. private _rightInverted;
  28845. private _position;
  28846. private _rotation;
  28847. private _rotationQuaternion;
  28848. protected _scaling: Vector3;
  28849. protected _isDirty: boolean;
  28850. private _transformToBoneReferal;
  28851. /**
  28852. * Set the billboard mode. Default is 0.
  28853. *
  28854. * | Value | Type | Description |
  28855. * | --- | --- | --- |
  28856. * | 0 | BILLBOARDMODE_NONE | |
  28857. * | 1 | BILLBOARDMODE_X | |
  28858. * | 2 | BILLBOARDMODE_Y | |
  28859. * | 4 | BILLBOARDMODE_Z | |
  28860. * | 7 | BILLBOARDMODE_ALL | |
  28861. *
  28862. */
  28863. billboardMode: number;
  28864. /**
  28865. * 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
  28866. */
  28867. scalingDeterminant: number;
  28868. /**
  28869. * Sets the distance of the object to max, often used by skybox
  28870. */
  28871. infiniteDistance: boolean;
  28872. /**
  28873. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  28874. * By default the system will update normals to compensate
  28875. */
  28876. ignoreNonUniformScaling: boolean;
  28877. /** @hidden */
  28878. _poseMatrix: Matrix;
  28879. private _localWorld;
  28880. private _absolutePosition;
  28881. private _pivotMatrix;
  28882. private _pivotMatrixInverse;
  28883. private _postMultiplyPivotMatrix;
  28884. protected _isWorldMatrixFrozen: boolean;
  28885. /**
  28886. * An event triggered after the world matrix is updated
  28887. */
  28888. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  28889. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  28890. /**
  28891. * Gets a string identifying the name of the class
  28892. * @returns "TransformNode" string
  28893. */
  28894. getClassName(): string;
  28895. /**
  28896. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  28897. */
  28898. position: Vector3;
  28899. /**
  28900. * 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)).
  28901. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  28902. */
  28903. rotation: Vector3;
  28904. /**
  28905. * 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)).
  28906. */
  28907. scaling: Vector3;
  28908. /**
  28909. * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (null by default).
  28910. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  28911. */
  28912. rotationQuaternion: Nullable<Quaternion>;
  28913. /**
  28914. * The forward direction of that transform in world space.
  28915. */
  28916. readonly forward: Vector3;
  28917. /**
  28918. * The up direction of that transform in world space.
  28919. */
  28920. readonly up: Vector3;
  28921. /**
  28922. * The right direction of that transform in world space.
  28923. */
  28924. readonly right: Vector3;
  28925. /**
  28926. * Copies the parameter passed Matrix into the mesh Pose matrix.
  28927. * @param matrix the matrix to copy the pose from
  28928. * @returns this TransformNode.
  28929. */
  28930. updatePoseMatrix(matrix: Matrix): TransformNode;
  28931. /**
  28932. * Returns the mesh Pose matrix.
  28933. * @returns the pose matrix
  28934. */
  28935. getPoseMatrix(): Matrix;
  28936. /** @hidden */
  28937. _isSynchronized(): boolean;
  28938. /** @hidden */
  28939. _initCache(): void;
  28940. /**
  28941. * Flag the transform node as dirty (Forcing it to update everything)
  28942. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  28943. * @returns this transform node
  28944. */
  28945. markAsDirty(property: string): TransformNode;
  28946. /**
  28947. * Returns the current mesh absolute position.
  28948. * Returns a Vector3.
  28949. */
  28950. readonly absolutePosition: Vector3;
  28951. /**
  28952. * Sets a new matrix to apply before all other transformation
  28953. * @param matrix defines the transform matrix
  28954. * @returns the current TransformNode
  28955. */
  28956. setPreTransformMatrix(matrix: Matrix): TransformNode;
  28957. /**
  28958. * Sets a new pivot matrix to the current node
  28959. * @param matrix defines the new pivot matrix to use
  28960. * @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
  28961. * @returns the current TransformNode
  28962. */
  28963. setPivotMatrix(matrix: Matrix, postMultiplyPivotMatrix?: boolean): TransformNode;
  28964. /**
  28965. * Returns the mesh pivot matrix.
  28966. * Default : Identity.
  28967. * @returns the matrix
  28968. */
  28969. getPivotMatrix(): Matrix;
  28970. /**
  28971. * Prevents the World matrix to be computed any longer.
  28972. * @returns the TransformNode.
  28973. */
  28974. freezeWorldMatrix(): TransformNode;
  28975. /**
  28976. * Allows back the World matrix computation.
  28977. * @returns the TransformNode.
  28978. */
  28979. unfreezeWorldMatrix(): this;
  28980. /**
  28981. * True if the World matrix has been frozen.
  28982. */
  28983. readonly isWorldMatrixFrozen: boolean;
  28984. /**
  28985. * Retuns the mesh absolute position in the World.
  28986. * @returns a Vector3.
  28987. */
  28988. getAbsolutePosition(): Vector3;
  28989. /**
  28990. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  28991. * @param absolutePosition the absolute position to set
  28992. * @returns the TransformNode.
  28993. */
  28994. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  28995. /**
  28996. * Sets the mesh position in its local space.
  28997. * @param vector3 the position to set in localspace
  28998. * @returns the TransformNode.
  28999. */
  29000. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  29001. /**
  29002. * Returns the mesh position in the local space from the current World matrix values.
  29003. * @returns a new Vector3.
  29004. */
  29005. getPositionExpressedInLocalSpace(): Vector3;
  29006. /**
  29007. * Translates the mesh along the passed Vector3 in its local space.
  29008. * @param vector3 the distance to translate in localspace
  29009. * @returns the TransformNode.
  29010. */
  29011. locallyTranslate(vector3: Vector3): TransformNode;
  29012. private static _lookAtVectorCache;
  29013. /**
  29014. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  29015. * @param targetPoint the position (must be in same space as current mesh) to look at
  29016. * @param yawCor optional yaw (y-axis) correction in radians
  29017. * @param pitchCor optional pitch (x-axis) correction in radians
  29018. * @param rollCor optional roll (z-axis) correction in radians
  29019. * @param space the choosen space of the target
  29020. * @returns the TransformNode.
  29021. */
  29022. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  29023. /**
  29024. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  29025. * This Vector3 is expressed in the World space.
  29026. * @param localAxis axis to rotate
  29027. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  29028. */
  29029. getDirection(localAxis: Vector3): Vector3;
  29030. /**
  29031. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  29032. * localAxis is expressed in the mesh local space.
  29033. * result is computed in the Wordl space from the mesh World matrix.
  29034. * @param localAxis axis to rotate
  29035. * @param result the resulting transformnode
  29036. * @returns this TransformNode.
  29037. */
  29038. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  29039. /**
  29040. * Sets a new pivot point to the current node
  29041. * @param point defines the new pivot point to use
  29042. * @param space defines if the point is in world or local space (local by default)
  29043. * @returns the current TransformNode
  29044. */
  29045. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  29046. /**
  29047. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  29048. * @returns the pivot point
  29049. */
  29050. getPivotPoint(): Vector3;
  29051. /**
  29052. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  29053. * @param result the vector3 to store the result
  29054. * @returns this TransformNode.
  29055. */
  29056. getPivotPointToRef(result: Vector3): TransformNode;
  29057. /**
  29058. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  29059. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  29060. */
  29061. getAbsolutePivotPoint(): Vector3;
  29062. /**
  29063. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  29064. * @param result vector3 to store the result
  29065. * @returns this TransformNode.
  29066. */
  29067. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  29068. /**
  29069. * Defines the passed node as the parent of the current node.
  29070. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  29071. * @param node the node ot set as the parent
  29072. * @returns this TransformNode.
  29073. */
  29074. setParent(node: Nullable<Node>): TransformNode;
  29075. private _nonUniformScaling;
  29076. /**
  29077. * True if the scaling property of this object is non uniform eg. (1,2,1)
  29078. */
  29079. readonly nonUniformScaling: boolean;
  29080. /** @hidden */
  29081. _updateNonUniformScalingState(value: boolean): boolean;
  29082. /**
  29083. * Attach the current TransformNode to another TransformNode associated with a bone
  29084. * @param bone Bone affecting the TransformNode
  29085. * @param affectedTransformNode TransformNode associated with the bone
  29086. * @returns this object
  29087. */
  29088. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  29089. /**
  29090. * Detach the transform node if its associated with a bone
  29091. * @returns this object
  29092. */
  29093. detachFromBone(): TransformNode;
  29094. private static _rotationAxisCache;
  29095. /**
  29096. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  29097. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  29098. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  29099. * The passed axis is also normalized.
  29100. * @param axis the axis to rotate around
  29101. * @param amount the amount to rotate in radians
  29102. * @param space Space to rotate in (Default: local)
  29103. * @returns the TransformNode.
  29104. */
  29105. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  29106. /**
  29107. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  29108. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  29109. * The passed axis is also normalized. .
  29110. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  29111. * @param point the point to rotate around
  29112. * @param axis the axis to rotate around
  29113. * @param amount the amount to rotate in radians
  29114. * @returns the TransformNode
  29115. */
  29116. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  29117. /**
  29118. * Translates the mesh along the axis vector for the passed distance in the given space.
  29119. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  29120. * @param axis the axis to translate in
  29121. * @param distance the distance to translate
  29122. * @param space Space to rotate in (Default: local)
  29123. * @returns the TransformNode.
  29124. */
  29125. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  29126. /**
  29127. * Adds a rotation step to the mesh current rotation.
  29128. * x, y, z are Euler angles expressed in radians.
  29129. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  29130. * This means this rotation is made in the mesh local space only.
  29131. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  29132. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  29133. * ```javascript
  29134. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  29135. * ```
  29136. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  29137. * 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.
  29138. * @param x Rotation to add
  29139. * @param y Rotation to add
  29140. * @param z Rotation to add
  29141. * @returns the TransformNode.
  29142. */
  29143. addRotation(x: number, y: number, z: number): TransformNode;
  29144. /**
  29145. * Computes the world matrix of the node
  29146. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29147. * @returns the world matrix
  29148. */
  29149. computeWorldMatrix(force?: boolean): Matrix;
  29150. protected _afterComputeWorldMatrix(): void;
  29151. /**
  29152. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  29153. * @param func callback function to add
  29154. *
  29155. * @returns the TransformNode.
  29156. */
  29157. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  29158. /**
  29159. * Removes a registered callback function.
  29160. * @param func callback function to remove
  29161. * @returns the TransformNode.
  29162. */
  29163. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  29164. /**
  29165. * Clone the current transform node
  29166. * @param name Name of the new clone
  29167. * @param newParent New parent for the clone
  29168. * @param doNotCloneChildren Do not clone children hierarchy
  29169. * @returns the new transform node
  29170. */
  29171. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  29172. /**
  29173. * Serializes the objects information.
  29174. * @param currentSerializationObject defines the object to serialize in
  29175. * @returns the serialized object
  29176. */
  29177. serialize(currentSerializationObject?: any): any;
  29178. /**
  29179. * Returns a new TransformNode object parsed from the source provided.
  29180. * @param parsedTransformNode is the source.
  29181. * @param scene the scne the object belongs to
  29182. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  29183. * @returns a new TransformNode object parsed from the source provided.
  29184. */
  29185. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  29186. /**
  29187. * Releases resources associated with this transform node.
  29188. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29189. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29190. */
  29191. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29192. }
  29193. }
  29194. declare module BABYLON {
  29195. /**
  29196. * Specialized buffer used to store vertex data
  29197. */
  29198. class VertexBuffer {
  29199. /** @hidden */
  29200. _buffer: Buffer;
  29201. private _kind;
  29202. private _size;
  29203. private _ownsBuffer;
  29204. private _instanced;
  29205. private _instanceDivisor;
  29206. /**
  29207. * The byte type.
  29208. */
  29209. static readonly BYTE: number;
  29210. /**
  29211. * The unsigned byte type.
  29212. */
  29213. static readonly UNSIGNED_BYTE: number;
  29214. /**
  29215. * The short type.
  29216. */
  29217. static readonly SHORT: number;
  29218. /**
  29219. * The unsigned short type.
  29220. */
  29221. static readonly UNSIGNED_SHORT: number;
  29222. /**
  29223. * The integer type.
  29224. */
  29225. static readonly INT: number;
  29226. /**
  29227. * The unsigned integer type.
  29228. */
  29229. static readonly UNSIGNED_INT: number;
  29230. /**
  29231. * The float type.
  29232. */
  29233. static readonly FLOAT: number;
  29234. /**
  29235. * Gets or sets the instance divisor when in instanced mode
  29236. */
  29237. instanceDivisor: number;
  29238. /**
  29239. * Gets the byte stride.
  29240. */
  29241. readonly byteStride: number;
  29242. /**
  29243. * Gets the byte offset.
  29244. */
  29245. readonly byteOffset: number;
  29246. /**
  29247. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  29248. */
  29249. readonly normalized: boolean;
  29250. /**
  29251. * Gets the data type of each component in the array.
  29252. */
  29253. readonly type: number;
  29254. /**
  29255. * Constructor
  29256. * @param engine the engine
  29257. * @param data the data to use for this vertex buffer
  29258. * @param kind the vertex buffer kind
  29259. * @param updatable whether the data is updatable
  29260. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  29261. * @param stride the stride (optional)
  29262. * @param instanced whether the buffer is instanced (optional)
  29263. * @param offset the offset of the data (optional)
  29264. * @param size the number of components (optional)
  29265. * @param type the type of the component (optional)
  29266. * @param normalized whether the data contains normalized data (optional)
  29267. * @param useBytes set to true if stride and offset are in bytes (optional)
  29268. */
  29269. 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);
  29270. /** @hidden */
  29271. _rebuild(): void;
  29272. /**
  29273. * Returns the kind of the VertexBuffer (string)
  29274. * @returns a string
  29275. */
  29276. getKind(): string;
  29277. /**
  29278. * Gets a boolean indicating if the VertexBuffer is updatable?
  29279. * @returns true if the buffer is updatable
  29280. */
  29281. isUpdatable(): boolean;
  29282. /**
  29283. * Gets current buffer's data
  29284. * @returns a DataArray or null
  29285. */
  29286. getData(): Nullable<DataArray>;
  29287. /**
  29288. * Gets underlying native buffer
  29289. * @returns underlying native buffer
  29290. */
  29291. getBuffer(): Nullable<WebGLBuffer>;
  29292. /**
  29293. * Gets the stride in float32 units (i.e. byte stride / 4).
  29294. * May not be an integer if the byte stride is not divisible by 4.
  29295. * DEPRECATED. Use byteStride instead.
  29296. * @returns the stride in float32 units
  29297. */
  29298. getStrideSize(): number;
  29299. /**
  29300. * Returns the offset as a multiple of the type byte length.
  29301. * DEPRECATED. Use byteOffset instead.
  29302. * @returns the offset in bytes
  29303. */
  29304. getOffset(): number;
  29305. /**
  29306. * Returns the number of components per vertex attribute (integer)
  29307. * @returns the size in float
  29308. */
  29309. getSize(): number;
  29310. /**
  29311. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  29312. * @returns true if this buffer is instanced
  29313. */
  29314. getIsInstanced(): boolean;
  29315. /**
  29316. * Returns the instancing divisor, zero for non-instanced (integer).
  29317. * @returns a number
  29318. */
  29319. getInstanceDivisor(): number;
  29320. /**
  29321. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  29322. * @param data defines the data to store
  29323. */
  29324. create(data?: DataArray): void;
  29325. /**
  29326. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  29327. * This function will create a new buffer if the current one is not updatable
  29328. * @param data defines the data to store
  29329. */
  29330. update(data: DataArray): void;
  29331. /**
  29332. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  29333. * Returns the directly updated WebGLBuffer.
  29334. * @param data the new data
  29335. * @param offset the new offset
  29336. * @param useBytes set to true if the offset is in bytes
  29337. */
  29338. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  29339. /**
  29340. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  29341. */
  29342. dispose(): void;
  29343. /**
  29344. * Enumerates each value of this vertex buffer as numbers.
  29345. * @param count the number of values to enumerate
  29346. * @param callback the callback function called for each value
  29347. */
  29348. forEach(count: number, callback: (value: number, index: number) => void): void;
  29349. /**
  29350. * Positions
  29351. */
  29352. static readonly PositionKind: string;
  29353. /**
  29354. * Normals
  29355. */
  29356. static readonly NormalKind: string;
  29357. /**
  29358. * Tangents
  29359. */
  29360. static readonly TangentKind: string;
  29361. /**
  29362. * Texture coordinates
  29363. */
  29364. static readonly UVKind: string;
  29365. /**
  29366. * Texture coordinates 2
  29367. */
  29368. static readonly UV2Kind: string;
  29369. /**
  29370. * Texture coordinates 3
  29371. */
  29372. static readonly UV3Kind: string;
  29373. /**
  29374. * Texture coordinates 4
  29375. */
  29376. static readonly UV4Kind: string;
  29377. /**
  29378. * Texture coordinates 5
  29379. */
  29380. static readonly UV5Kind: string;
  29381. /**
  29382. * Texture coordinates 6
  29383. */
  29384. static readonly UV6Kind: string;
  29385. /**
  29386. * Colors
  29387. */
  29388. static readonly ColorKind: string;
  29389. /**
  29390. * Matrix indices (for bones)
  29391. */
  29392. static readonly MatricesIndicesKind: string;
  29393. /**
  29394. * Matrix weights (for bones)
  29395. */
  29396. static readonly MatricesWeightsKind: string;
  29397. /**
  29398. * Additional matrix indices (for bones)
  29399. */
  29400. static readonly MatricesIndicesExtraKind: string;
  29401. /**
  29402. * Additional matrix weights (for bones)
  29403. */
  29404. static readonly MatricesWeightsExtraKind: string;
  29405. /**
  29406. * Deduces the stride given a kind.
  29407. * @param kind The kind string to deduce
  29408. * @returns The deduced stride
  29409. */
  29410. static DeduceStride(kind: string): number;
  29411. /**
  29412. * Gets the byte length of the given type.
  29413. * @param type the type
  29414. * @returns the number of bytes
  29415. */
  29416. static GetTypeByteLength(type: number): number;
  29417. /**
  29418. * Enumerates each value of the given parameters as numbers.
  29419. * @param data the data to enumerate
  29420. * @param byteOffset the byte offset of the data
  29421. * @param byteStride the byte stride of the data
  29422. * @param componentCount the number of components per element
  29423. * @param componentType the type of the component
  29424. * @param count the total number of components
  29425. * @param normalized whether the data is normalized
  29426. * @param callback the callback function called for each value
  29427. */
  29428. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  29429. private static _GetFloatValue;
  29430. }
  29431. }
  29432. declare module BABYLON {
  29433. /**
  29434. * Defines a target to use with MorphTargetManager
  29435. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  29436. */
  29437. class MorphTarget implements IAnimatable {
  29438. /** defines the name of the target */
  29439. name: string;
  29440. /**
  29441. * Gets or sets the list of animations
  29442. */
  29443. animations: Animation[];
  29444. private _scene;
  29445. private _positions;
  29446. private _normals;
  29447. private _tangents;
  29448. private _influence;
  29449. /**
  29450. * Observable raised when the influence changes
  29451. */
  29452. onInfluenceChanged: Observable<boolean>;
  29453. /** @hidden */
  29454. _onDataLayoutChanged: Observable<void>;
  29455. /**
  29456. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  29457. */
  29458. influence: number;
  29459. private _animationPropertiesOverride;
  29460. /**
  29461. * Gets or sets the animation properties override
  29462. */
  29463. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  29464. /**
  29465. * Creates a new MorphTarget
  29466. * @param name defines the name of the target
  29467. * @param influence defines the influence to use
  29468. */
  29469. constructor(
  29470. /** defines the name of the target */
  29471. name: string, influence?: number, scene?: Nullable<Scene>);
  29472. /**
  29473. * Gets a boolean defining if the target contains position data
  29474. */
  29475. readonly hasPositions: boolean;
  29476. /**
  29477. * Gets a boolean defining if the target contains normal data
  29478. */
  29479. readonly hasNormals: boolean;
  29480. /**
  29481. * Gets a boolean defining if the target contains tangent data
  29482. */
  29483. readonly hasTangents: boolean;
  29484. /**
  29485. * Affects position data to this target
  29486. * @param data defines the position data to use
  29487. */
  29488. setPositions(data: Nullable<FloatArray>): void;
  29489. /**
  29490. * Gets the position data stored in this target
  29491. * @returns a FloatArray containing the position data (or null if not present)
  29492. */
  29493. getPositions(): Nullable<FloatArray>;
  29494. /**
  29495. * Affects normal data to this target
  29496. * @param data defines the normal data to use
  29497. */
  29498. setNormals(data: Nullable<FloatArray>): void;
  29499. /**
  29500. * Gets the normal data stored in this target
  29501. * @returns a FloatArray containing the normal data (or null if not present)
  29502. */
  29503. getNormals(): Nullable<FloatArray>;
  29504. /**
  29505. * Affects tangent data to this target
  29506. * @param data defines the tangent data to use
  29507. */
  29508. setTangents(data: Nullable<FloatArray>): void;
  29509. /**
  29510. * Gets the tangent data stored in this target
  29511. * @returns a FloatArray containing the tangent data (or null if not present)
  29512. */
  29513. getTangents(): Nullable<FloatArray>;
  29514. /**
  29515. * Serializes the current target into a Serialization object
  29516. * @returns the serialized object
  29517. */
  29518. serialize(): any;
  29519. /**
  29520. * Creates a new target from serialized data
  29521. * @param serializationObject defines the serialized data to use
  29522. * @returns a new MorphTarget
  29523. */
  29524. static Parse(serializationObject: any): MorphTarget;
  29525. /**
  29526. * Creates a MorphTarget from mesh data
  29527. * @param mesh defines the source mesh
  29528. * @param name defines the name to use for the new target
  29529. * @param influence defines the influence to attach to the target
  29530. * @returns a new MorphTarget
  29531. */
  29532. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  29533. }
  29534. }
  29535. declare module BABYLON {
  29536. /**
  29537. * This class is used to deform meshes using morphing between different targets
  29538. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  29539. */
  29540. class MorphTargetManager {
  29541. private _targets;
  29542. private _targetInfluenceChangedObservers;
  29543. private _targetDataLayoutChangedObservers;
  29544. private _activeTargets;
  29545. private _scene;
  29546. private _influences;
  29547. private _supportsNormals;
  29548. private _supportsTangents;
  29549. private _vertexCount;
  29550. private _uniqueId;
  29551. private _tempInfluences;
  29552. /**
  29553. * Creates a new MorphTargetManager
  29554. * @param scene defines the current scene
  29555. */
  29556. constructor(scene?: Nullable<Scene>);
  29557. /**
  29558. * Gets the unique ID of this manager
  29559. */
  29560. readonly uniqueId: number;
  29561. /**
  29562. * Gets the number of vertices handled by this manager
  29563. */
  29564. readonly vertexCount: number;
  29565. /**
  29566. * Gets a boolean indicating if this manager supports morphing of normals
  29567. */
  29568. readonly supportsNormals: boolean;
  29569. /**
  29570. * Gets a boolean indicating if this manager supports morphing of tangents
  29571. */
  29572. readonly supportsTangents: boolean;
  29573. /**
  29574. * Gets the number of targets stored in this manager
  29575. */
  29576. readonly numTargets: number;
  29577. /**
  29578. * Gets the number of influencers (ie. the number of targets with influences > 0)
  29579. */
  29580. readonly numInfluencers: number;
  29581. /**
  29582. * Gets the list of influences (one per target)
  29583. */
  29584. readonly influences: Float32Array;
  29585. /**
  29586. * Gets the active target at specified index. An active target is a target with an influence > 0
  29587. * @param index defines the index to check
  29588. * @returns the requested target
  29589. */
  29590. getActiveTarget(index: number): MorphTarget;
  29591. /**
  29592. * Gets the target at specified index
  29593. * @param index defines the index to check
  29594. * @returns the requested target
  29595. */
  29596. getTarget(index: number): MorphTarget;
  29597. /**
  29598. * Add a new target to this manager
  29599. * @param target defines the target to add
  29600. */
  29601. addTarget(target: MorphTarget): void;
  29602. /**
  29603. * Removes a target from the manager
  29604. * @param target defines the target to remove
  29605. */
  29606. removeTarget(target: MorphTarget): void;
  29607. /**
  29608. * Serializes the current manager into a Serialization object
  29609. * @returns the serialized object
  29610. */
  29611. serialize(): any;
  29612. private _syncActiveTargets;
  29613. /**
  29614. * Syncrhonize the targets with all the meshes using this morph target manager
  29615. */
  29616. synchronize(): void;
  29617. /**
  29618. * Creates a new MorphTargetManager from serialized data
  29619. * @param serializationObject defines the serialized data
  29620. * @param scene defines the hosting scene
  29621. * @returns the new MorphTargetManager
  29622. */
  29623. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  29624. }
  29625. }
  29626. declare module BABYLON {
  29627. /**
  29628. * Interface used to describe a physics joint
  29629. */
  29630. interface PhysicsImpostorJoint {
  29631. /** Defines the main impostor to which the joint is linked */
  29632. mainImpostor: PhysicsImpostor;
  29633. /** Defines the impostor that is connected to the main impostor using this joint */
  29634. connectedImpostor: PhysicsImpostor;
  29635. /** Defines the joint itself */
  29636. joint: PhysicsJoint;
  29637. }
  29638. /** @hidden */
  29639. interface IPhysicsEnginePlugin {
  29640. world: any;
  29641. name: string;
  29642. setGravity(gravity: Vector3): void;
  29643. setTimeStep(timeStep: number): void;
  29644. getTimeStep(): number;
  29645. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  29646. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  29647. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  29648. generatePhysicsBody(impostor: PhysicsImpostor): void;
  29649. removePhysicsBody(impostor: PhysicsImpostor): void;
  29650. generateJoint(joint: PhysicsImpostorJoint): void;
  29651. removeJoint(joint: PhysicsImpostorJoint): void;
  29652. isSupported(): boolean;
  29653. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  29654. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  29655. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  29656. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  29657. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  29658. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  29659. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  29660. getBodyMass(impostor: PhysicsImpostor): number;
  29661. getBodyFriction(impostor: PhysicsImpostor): number;
  29662. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  29663. getBodyRestitution(impostor: PhysicsImpostor): number;
  29664. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  29665. sleepBody(impostor: PhysicsImpostor): void;
  29666. wakeUpBody(impostor: PhysicsImpostor): void;
  29667. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  29668. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  29669. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  29670. getRadius(impostor: PhysicsImpostor): number;
  29671. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  29672. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  29673. dispose(): void;
  29674. }
  29675. /**
  29676. * Interface used to define a physics engine
  29677. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  29678. */
  29679. interface IPhysicsEngine {
  29680. /**
  29681. * Gets the gravity vector used by the simulation
  29682. */
  29683. gravity: Vector3;
  29684. /**
  29685. * Sets the gravity vector used by the simulation
  29686. * @param gravity defines the gravity vector to use
  29687. */
  29688. setGravity(gravity: Vector3): void;
  29689. /**
  29690. * Set the time step of the physics engine.
  29691. * Default is 1/60.
  29692. * To slow it down, enter 1/600 for example.
  29693. * To speed it up, 1/30
  29694. * @param newTimeStep the new timestep to apply to this world.
  29695. */
  29696. setTimeStep(newTimeStep: number): void;
  29697. /**
  29698. * Get the time step of the physics engine.
  29699. * @returns the current time step
  29700. */
  29701. getTimeStep(): number;
  29702. /**
  29703. * Release all resources
  29704. */
  29705. dispose(): void;
  29706. /**
  29707. * Gets the name of the current physics plugin
  29708. * @returns the name of the plugin
  29709. */
  29710. getPhysicsPluginName(): string;
  29711. /**
  29712. * Adding a new impostor for the impostor tracking.
  29713. * This will be done by the impostor itself.
  29714. * @param impostor the impostor to add
  29715. */
  29716. addImpostor(impostor: PhysicsImpostor): void;
  29717. /**
  29718. * Remove an impostor from the engine.
  29719. * This impostor and its mesh will not longer be updated by the physics engine.
  29720. * @param impostor the impostor to remove
  29721. */
  29722. removeImpostor(impostor: PhysicsImpostor): void;
  29723. /**
  29724. * Add a joint to the physics engine
  29725. * @param mainImpostor defines the main impostor to which the joint is added.
  29726. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  29727. * @param joint defines the joint that will connect both impostors.
  29728. */
  29729. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  29730. /**
  29731. * Removes a joint from the simulation
  29732. * @param mainImpostor defines the impostor used with the joint
  29733. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  29734. * @param joint defines the joint to remove
  29735. */
  29736. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  29737. /**
  29738. * Gets the current plugin used to run the simulation
  29739. * @returns current plugin
  29740. */
  29741. getPhysicsPlugin(): IPhysicsEnginePlugin;
  29742. /**
  29743. * Gets the list of physic impostors
  29744. * @returns an array of PhysicsImpostor
  29745. */
  29746. getImpostors(): Array<PhysicsImpostor>;
  29747. /**
  29748. * Gets the impostor for a physics enabled object
  29749. * @param object defines the object impersonated by the impostor
  29750. * @returns the PhysicsImpostor or null if not found
  29751. */
  29752. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  29753. /**
  29754. * Gets the impostor for a physics body object
  29755. * @param body defines physics body used by the impostor
  29756. * @returns the PhysicsImpostor or null if not found
  29757. */
  29758. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  29759. /**
  29760. * Called by the scene. No need to call it.
  29761. * @param delta defines the timespam between frames
  29762. */
  29763. _step(delta: number): void;
  29764. }
  29765. }
  29766. declare module BABYLON {
  29767. /**
  29768. * Class used to control physics engine
  29769. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  29770. */
  29771. class PhysicsEngine implements IPhysicsEngine {
  29772. private _physicsPlugin;
  29773. /**
  29774. * Global value used to control the smallest number supported by the simulation
  29775. */
  29776. static Epsilon: number;
  29777. private _impostors;
  29778. private _joints;
  29779. /**
  29780. * Gets the gravity vector used by the simulation
  29781. */
  29782. gravity: Vector3;
  29783. /**
  29784. * Creates a new Physics Engine
  29785. * @param gravity defines the gravity vector used by the simulation
  29786. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  29787. */
  29788. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  29789. /**
  29790. * Sets the gravity vector used by the simulation
  29791. * @param gravity defines the gravity vector to use
  29792. */
  29793. setGravity(gravity: Vector3): void;
  29794. /**
  29795. * Set the time step of the physics engine.
  29796. * Default is 1/60.
  29797. * To slow it down, enter 1/600 for example.
  29798. * To speed it up, 1/30
  29799. * @param newTimeStep defines the new timestep to apply to this world.
  29800. */
  29801. setTimeStep(newTimeStep?: number): void;
  29802. /**
  29803. * Get the time step of the physics engine.
  29804. * @returns the current time step
  29805. */
  29806. getTimeStep(): number;
  29807. /**
  29808. * Release all resources
  29809. */
  29810. dispose(): void;
  29811. /**
  29812. * Gets the name of the current physics plugin
  29813. * @returns the name of the plugin
  29814. */
  29815. getPhysicsPluginName(): string;
  29816. /**
  29817. * Adding a new impostor for the impostor tracking.
  29818. * This will be done by the impostor itself.
  29819. * @param impostor the impostor to add
  29820. */
  29821. addImpostor(impostor: PhysicsImpostor): void;
  29822. /**
  29823. * Remove an impostor from the engine.
  29824. * This impostor and its mesh will not longer be updated by the physics engine.
  29825. * @param impostor the impostor to remove
  29826. */
  29827. removeImpostor(impostor: PhysicsImpostor): void;
  29828. /**
  29829. * Add a joint to the physics engine
  29830. * @param mainImpostor defines the main impostor to which the joint is added.
  29831. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  29832. * @param joint defines the joint that will connect both impostors.
  29833. */
  29834. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  29835. /**
  29836. * Removes a joint from the simulation
  29837. * @param mainImpostor defines the impostor used with the joint
  29838. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  29839. * @param joint defines the joint to remove
  29840. */
  29841. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  29842. /**
  29843. * Called by the scene. No need to call it.
  29844. * @param delta defines the timespam between frames
  29845. */
  29846. _step(delta: number): void;
  29847. /**
  29848. * Gets the current plugin used to run the simulation
  29849. * @returns current plugin
  29850. */
  29851. getPhysicsPlugin(): IPhysicsEnginePlugin;
  29852. /**
  29853. * Gets the list of physic impostors
  29854. * @returns an array of PhysicsImpostor
  29855. */
  29856. getImpostors(): Array<PhysicsImpostor>;
  29857. /**
  29858. * Gets the impostor for a physics enabled object
  29859. * @param object defines the object impersonated by the impostor
  29860. * @returns the PhysicsImpostor or null if not found
  29861. */
  29862. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  29863. /**
  29864. * Gets the impostor for a physics body object
  29865. * @param body defines physics body used by the impostor
  29866. * @returns the PhysicsImpostor or null if not found
  29867. */
  29868. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  29869. }
  29870. }
  29871. declare module BABYLON {
  29872. interface Scene {
  29873. /** @hidden (Backing field) */
  29874. _physicsEngine: Nullable<IPhysicsEngine>;
  29875. /**
  29876. * Gets the current physics engine
  29877. * @returns a IPhysicsEngine or null if none attached
  29878. */
  29879. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  29880. /**
  29881. * Enables physics to the current scene
  29882. * @param gravity defines the scene's gravity for the physics engine
  29883. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  29884. * @return a boolean indicating if the physics engine was initialized
  29885. */
  29886. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  29887. /**
  29888. * Disables and disposes the physics engine associated with the scene
  29889. */
  29890. disablePhysicsEngine(): void;
  29891. /**
  29892. * Gets a boolean indicating if there is an active physics engine
  29893. * @returns a boolean indicating if there is an active physics engine
  29894. */
  29895. isPhysicsEnabled(): boolean;
  29896. /**
  29897. * Deletes a physics compound impostor
  29898. * @param compound defines the compound to delete
  29899. */
  29900. deleteCompoundImpostor(compound: any): void;
  29901. /**
  29902. * An event triggered when physic simulation is about to be run
  29903. */
  29904. onBeforePhysicsObservable: Observable<Scene>;
  29905. /**
  29906. * An event triggered when physic simulation has been done
  29907. */
  29908. onAfterPhysicsObservable: Observable<Scene>;
  29909. }
  29910. interface AbstractMesh {
  29911. /** @hidden */
  29912. _physicsImpostor: Nullable<PhysicsImpostor>;
  29913. /**
  29914. * Gets or sets impostor used for physic simulation
  29915. * @see http://doc.babylonjs.com/features/physics_engine
  29916. */
  29917. physicsImpostor: Nullable<PhysicsImpostor>;
  29918. /**
  29919. * Gets the current physics impostor
  29920. * @see http://doc.babylonjs.com/features/physics_engine
  29921. * @returns a physics impostor or null
  29922. */
  29923. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  29924. /** Apply a physic impulse to the mesh
  29925. * @param force defines the force to apply
  29926. * @param contactPoint defines where to apply the force
  29927. * @returns the current mesh
  29928. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  29929. */
  29930. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  29931. /**
  29932. * Creates a physic joint between two meshes
  29933. * @param otherMesh defines the other mesh to use
  29934. * @param pivot1 defines the pivot to use on this mesh
  29935. * @param pivot2 defines the pivot to use on the other mesh
  29936. * @param options defines additional options (can be plugin dependent)
  29937. * @returns the current mesh
  29938. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  29939. */
  29940. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  29941. /** @hidden */
  29942. _disposePhysicsObserver: Nullable<Observer<Node>>;
  29943. }
  29944. /**
  29945. * Defines the physics engine scene component responsible to manage a physics engine
  29946. */
  29947. class PhysicsEngineSceneComponent implements ISceneComponent {
  29948. /**
  29949. * The component name helpful to identify the component in the list of scene components.
  29950. */
  29951. readonly name: string;
  29952. /**
  29953. * The scene the component belongs to.
  29954. */
  29955. scene: Scene;
  29956. /**
  29957. * Creates a new instance of the component for the given scene
  29958. * @param scene Defines the scene to register the component in
  29959. */
  29960. constructor(scene: Scene);
  29961. /**
  29962. * Registers the component in a given scene
  29963. */
  29964. register(): void;
  29965. /**
  29966. * Rebuilds the elements related to this component in case of
  29967. * context lost for instance.
  29968. */
  29969. rebuild(): void;
  29970. /**
  29971. * Disposes the component and the associated ressources
  29972. */
  29973. dispose(): void;
  29974. }
  29975. }
  29976. declare module BABYLON {
  29977. /**
  29978. * A helper for physics simulations
  29979. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  29980. */
  29981. class PhysicsHelper {
  29982. private _scene;
  29983. private _physicsEngine;
  29984. /**
  29985. * Initializes the Physics helper
  29986. * @param scene Babylon.js scene
  29987. */
  29988. constructor(scene: Scene);
  29989. /**
  29990. * Applies a radial explosion impulse
  29991. * @param origin the origin of the explosion
  29992. * @param radius the explosion radius
  29993. * @param strength the explosion strength
  29994. * @param falloff possible options: Constant & Linear. Defaults to Constant
  29995. * @returns A physics radial explosion event, or null
  29996. */
  29997. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  29998. /**
  29999. * Applies a radial explosion force
  30000. * @param origin the origin of the explosion
  30001. * @param radius the explosion radius
  30002. * @param strength the explosion strength
  30003. * @param falloff possible options: Constant & Linear. Defaults to Constant
  30004. * @returns A physics radial explosion event, or null
  30005. */
  30006. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  30007. /**
  30008. * Creates a gravitational field
  30009. * @param origin the origin of the explosion
  30010. * @param radius the explosion radius
  30011. * @param strength the explosion strength
  30012. * @param falloff possible options: Constant & Linear. Defaults to Constant
  30013. * @returns A physics gravitational field event, or null
  30014. */
  30015. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  30016. /**
  30017. * Creates a physics updraft event
  30018. * @param origin the origin of the updraft
  30019. * @param radius the radius of the updraft
  30020. * @param strength the strength of the updraft
  30021. * @param height the height of the updraft
  30022. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  30023. * @returns A physics updraft event, or null
  30024. */
  30025. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  30026. /**
  30027. * Creates a physics vortex event
  30028. * @param origin the of the vortex
  30029. * @param radius the radius of the vortex
  30030. * @param strength the strength of the vortex
  30031. * @param height the height of the vortex
  30032. * @returns a Physics vortex event, or null
  30033. * A physics vortex event or null
  30034. */
  30035. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  30036. }
  30037. /**
  30038. * Represents a physics radial explosion event
  30039. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  30040. */
  30041. class PhysicsRadialExplosionEvent {
  30042. private _scene;
  30043. private _sphere;
  30044. private _sphereOptions;
  30045. private _rays;
  30046. private _dataFetched;
  30047. /**
  30048. * Initializes a radial explosioin event
  30049. * @param scene BabylonJS scene
  30050. */
  30051. constructor(scene: Scene);
  30052. /**
  30053. * Returns the data related to the radial explosion event (sphere & rays).
  30054. * @returns The radial explosion event data
  30055. */
  30056. getData(): PhysicsRadialExplosionEventData;
  30057. /**
  30058. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  30059. * @param impostor A physics imposter
  30060. * @param origin the origin of the explosion
  30061. * @param radius the explosion radius
  30062. * @param strength the explosion strength
  30063. * @param falloff possible options: Constant & Linear
  30064. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  30065. */
  30066. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  30067. /**
  30068. * Disposes the sphere.
  30069. * @param force Specifies if the sphere should be disposed by force
  30070. */
  30071. dispose(force?: boolean): void;
  30072. /*** Helpers ***/
  30073. private _prepareSphere;
  30074. private _intersectsWithSphere;
  30075. }
  30076. /**
  30077. * Represents a gravitational field event
  30078. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  30079. */
  30080. class PhysicsGravitationalFieldEvent {
  30081. private _physicsHelper;
  30082. private _scene;
  30083. private _origin;
  30084. private _radius;
  30085. private _strength;
  30086. private _falloff;
  30087. private _tickCallback;
  30088. private _sphere;
  30089. private _dataFetched;
  30090. /**
  30091. * Initializes the physics gravitational field event
  30092. * @param physicsHelper A physics helper
  30093. * @param scene BabylonJS scene
  30094. * @param origin The origin position of the gravitational field event
  30095. * @param radius The radius of the gravitational field event
  30096. * @param strength The strength of the gravitational field event
  30097. * @param falloff The falloff for the gravitational field event
  30098. */
  30099. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  30100. /**
  30101. * Returns the data related to the gravitational field event (sphere).
  30102. * @returns A gravitational field event
  30103. */
  30104. getData(): PhysicsGravitationalFieldEventData;
  30105. /**
  30106. * Enables the gravitational field.
  30107. */
  30108. enable(): void;
  30109. /**
  30110. * Disables the gravitational field.
  30111. */
  30112. disable(): void;
  30113. /**
  30114. * Disposes the sphere.
  30115. * @param force The force to dispose from the gravitational field event
  30116. */
  30117. dispose(force?: boolean): void;
  30118. private _tick;
  30119. }
  30120. /**
  30121. * Represents a physics updraft event
  30122. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  30123. */
  30124. class PhysicsUpdraftEvent {
  30125. private _scene;
  30126. private _origin;
  30127. private _radius;
  30128. private _strength;
  30129. private _height;
  30130. private _updraftMode;
  30131. private _physicsEngine;
  30132. private _originTop;
  30133. private _originDirection;
  30134. private _tickCallback;
  30135. private _cylinder;
  30136. private _cylinderPosition;
  30137. private _dataFetched;
  30138. /**
  30139. * Initializes the physics updraft event
  30140. * @param _scene BabylonJS scene
  30141. * @param _origin The origin position of the updraft
  30142. * @param _radius The radius of the updraft
  30143. * @param _strength The strength of the updraft
  30144. * @param _height The height of the updraft
  30145. * @param _updraftMode The mode of the updraft
  30146. */
  30147. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  30148. /**
  30149. * Returns the data related to the updraft event (cylinder).
  30150. * @returns A physics updraft event
  30151. */
  30152. getData(): PhysicsUpdraftEventData;
  30153. /**
  30154. * Enables the updraft.
  30155. */
  30156. enable(): void;
  30157. /**
  30158. * Disables the cortex.
  30159. */
  30160. disable(): void;
  30161. /**
  30162. * Disposes the sphere.
  30163. * @param force Specifies if the updraft should be disposed by force
  30164. */
  30165. dispose(force?: boolean): void;
  30166. private getImpostorForceAndContactPoint;
  30167. private _tick;
  30168. /*** Helpers ***/
  30169. private _prepareCylinder;
  30170. private _intersectsWithCylinder;
  30171. }
  30172. /**
  30173. * Represents a physics vortex event
  30174. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  30175. */
  30176. class PhysicsVortexEvent {
  30177. private _scene;
  30178. private _origin;
  30179. private _radius;
  30180. private _strength;
  30181. private _height;
  30182. private _physicsEngine;
  30183. private _originTop;
  30184. private _centripetalForceThreshold;
  30185. private _updraftMultiplier;
  30186. private _tickCallback;
  30187. private _cylinder;
  30188. private _cylinderPosition;
  30189. private _dataFetched;
  30190. /**
  30191. * Initializes the physics vortex event
  30192. * @param _scene The BabylonJS scene
  30193. * @param _origin The origin position of the vortex
  30194. * @param _radius The radius of the vortex
  30195. * @param _strength The strength of the vortex
  30196. * @param _height The height of the vortex
  30197. */
  30198. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  30199. /**
  30200. * Returns the data related to the vortex event (cylinder).
  30201. * @returns The physics vortex event data
  30202. */
  30203. getData(): PhysicsVortexEventData;
  30204. /**
  30205. * Enables the vortex.
  30206. */
  30207. enable(): void;
  30208. /**
  30209. * Disables the cortex.
  30210. */
  30211. disable(): void;
  30212. /**
  30213. * Disposes the sphere.
  30214. * @param force
  30215. */
  30216. dispose(force?: boolean): void;
  30217. private getImpostorForceAndContactPoint;
  30218. private _tick;
  30219. /*** Helpers ***/
  30220. private _prepareCylinder;
  30221. private _intersectsWithCylinder;
  30222. }
  30223. /**
  30224. * The strenght of the force in correspondence to the distance of the affected object
  30225. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  30226. */
  30227. enum PhysicsRadialImpulseFalloff {
  30228. /** Defines that impulse is constant in strength across it's whole radius */
  30229. Constant = 0,
  30230. /** DEfines that impulse gets weaker if it's further from the origin */
  30231. Linear = 1
  30232. }
  30233. /**
  30234. * The strength of the force in correspondence to the distance of the affected object
  30235. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  30236. */
  30237. enum PhysicsUpdraftMode {
  30238. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  30239. Center = 0,
  30240. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  30241. Perpendicular = 1
  30242. }
  30243. /**
  30244. * Interface for a physics force and contact point
  30245. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  30246. */
  30247. interface PhysicsForceAndContactPoint {
  30248. /**
  30249. * The force applied at the contact point
  30250. */
  30251. force: Vector3;
  30252. /**
  30253. * The contact point
  30254. */
  30255. contactPoint: Vector3;
  30256. }
  30257. /**
  30258. * Interface for radial explosion event data
  30259. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  30260. */
  30261. interface PhysicsRadialExplosionEventData {
  30262. /**
  30263. * A sphere used for the radial explosion event
  30264. */
  30265. sphere: Mesh;
  30266. /**
  30267. * An array of rays for the radial explosion event
  30268. */
  30269. rays: Array<Ray>;
  30270. }
  30271. /**
  30272. * Interface for gravitational field event data
  30273. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  30274. */
  30275. interface PhysicsGravitationalFieldEventData {
  30276. /**
  30277. * A sphere mesh used for the gravitational field event
  30278. */
  30279. sphere: Mesh;
  30280. }
  30281. /**
  30282. * Interface for updraft event data
  30283. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  30284. */
  30285. interface PhysicsUpdraftEventData {
  30286. /**
  30287. * A cylinder used for the updraft event
  30288. */
  30289. cylinder: Mesh;
  30290. }
  30291. /**
  30292. * Interface for vortex event data
  30293. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  30294. */
  30295. interface PhysicsVortexEventData {
  30296. /**
  30297. * A cylinder used for the vortex event
  30298. */
  30299. cylinder: Mesh;
  30300. }
  30301. }
  30302. declare module BABYLON {
  30303. /**
  30304. * The interface for the physics imposter parameters
  30305. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  30306. */
  30307. interface PhysicsImpostorParameters {
  30308. /**
  30309. * The mass of the physics imposter
  30310. */
  30311. mass: number;
  30312. /**
  30313. * The friction of the physics imposter
  30314. */
  30315. friction?: number;
  30316. /**
  30317. * The coefficient of restitution of the physics imposter
  30318. */
  30319. restitution?: number;
  30320. /**
  30321. * The native options of the physics imposter
  30322. */
  30323. nativeOptions?: any;
  30324. /**
  30325. * Specifies if the parent should be ignored
  30326. */
  30327. ignoreParent?: boolean;
  30328. /**
  30329. * Specifies if bi-directional transformations should be disabled
  30330. */
  30331. disableBidirectionalTransformation?: boolean;
  30332. }
  30333. /**
  30334. * Interface for a physics-enabled object
  30335. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  30336. */
  30337. interface IPhysicsEnabledObject {
  30338. /**
  30339. * The position of the physics-enabled object
  30340. */
  30341. position: Vector3;
  30342. /**
  30343. * The rotation of the physics-enabled object
  30344. */
  30345. rotationQuaternion: Nullable<Quaternion>;
  30346. /**
  30347. * The scale of the physics-enabled object
  30348. */
  30349. scaling: Vector3;
  30350. /**
  30351. * The rotation of the physics-enabled object
  30352. */
  30353. rotation?: Vector3;
  30354. /**
  30355. * The parent of the physics-enabled object
  30356. */
  30357. parent?: any;
  30358. /**
  30359. * The bounding info of the physics-enabled object
  30360. * @returns The bounding info of the physics-enabled object
  30361. */
  30362. getBoundingInfo(): BoundingInfo;
  30363. /**
  30364. * Computes the world matrix
  30365. * @param force Specifies if the world matrix should be computed by force
  30366. * @returns A world matrix
  30367. */
  30368. computeWorldMatrix(force: boolean): Matrix;
  30369. /**
  30370. * Gets the world matrix
  30371. * @returns A world matrix
  30372. */
  30373. getWorldMatrix?(): Matrix;
  30374. /**
  30375. * Gets the child meshes
  30376. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  30377. * @returns An array of abstract meshes
  30378. */
  30379. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  30380. /**
  30381. * Gets the vertex data
  30382. * @param kind The type of vertex data
  30383. * @returns A nullable array of numbers, or a float32 array
  30384. */
  30385. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  30386. /**
  30387. * Gets the indices from the mesh
  30388. * @returns A nullable array of index arrays
  30389. */
  30390. getIndices?(): Nullable<IndicesArray>;
  30391. /**
  30392. * Gets the scene from the mesh
  30393. * @returns the indices array or null
  30394. */
  30395. getScene?(): Scene;
  30396. /**
  30397. * Gets the absolute position from the mesh
  30398. * @returns the absolute position
  30399. */
  30400. getAbsolutePosition(): Vector3;
  30401. /**
  30402. * Gets the absolute pivot point from the mesh
  30403. * @returns the absolute pivot point
  30404. */
  30405. getAbsolutePivotPoint(): Vector3;
  30406. /**
  30407. * Rotates the mesh
  30408. * @param axis The axis of rotation
  30409. * @param amount The amount of rotation
  30410. * @param space The space of the rotation
  30411. * @returns The rotation transform node
  30412. */
  30413. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  30414. /**
  30415. * Translates the mesh
  30416. * @param axis The axis of translation
  30417. * @param distance The distance of translation
  30418. * @param space The space of the translation
  30419. * @returns The transform node
  30420. */
  30421. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  30422. /**
  30423. * Sets the absolute position of the mesh
  30424. * @param absolutePosition The absolute position of the mesh
  30425. * @returns The transform node
  30426. */
  30427. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  30428. /**
  30429. * Gets the class name of the mesh
  30430. * @returns The class name
  30431. */
  30432. getClassName(): string;
  30433. }
  30434. /**
  30435. * Represents a physics imposter
  30436. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  30437. */
  30438. class PhysicsImpostor {
  30439. /**
  30440. * The physics-enabled object used as the physics imposter
  30441. */
  30442. object: IPhysicsEnabledObject;
  30443. /**
  30444. * The type of the physics imposter
  30445. */
  30446. type: number;
  30447. private _options;
  30448. private _scene?;
  30449. /**
  30450. * The default object size of the imposter
  30451. */
  30452. static DEFAULT_OBJECT_SIZE: Vector3;
  30453. /**
  30454. * The identity quaternion of the imposter
  30455. */
  30456. static IDENTITY_QUATERNION: Quaternion;
  30457. private _physicsEngine;
  30458. private _physicsBody;
  30459. private _bodyUpdateRequired;
  30460. private _onBeforePhysicsStepCallbacks;
  30461. private _onAfterPhysicsStepCallbacks;
  30462. private _onPhysicsCollideCallbacks;
  30463. private _deltaPosition;
  30464. private _deltaRotation;
  30465. private _deltaRotationConjugated;
  30466. private _parent;
  30467. private _isDisposed;
  30468. private static _tmpVecs;
  30469. private static _tmpQuat;
  30470. /**
  30471. * Specifies if the physics imposter is disposed
  30472. */
  30473. readonly isDisposed: boolean;
  30474. /**
  30475. * Gets the mass of the physics imposter
  30476. */
  30477. mass: number;
  30478. /**
  30479. * Gets the coefficient of friction
  30480. */
  30481. /**
  30482. * Sets the coefficient of friction
  30483. */
  30484. friction: number;
  30485. /**
  30486. * Gets the coefficient of restitution
  30487. */
  30488. /**
  30489. * Sets the coefficient of restitution
  30490. */
  30491. restitution: number;
  30492. /**
  30493. * The unique id of the physics imposter
  30494. * set by the physics engine when adding this impostor to the array
  30495. */
  30496. uniqueId: number;
  30497. private _joints;
  30498. /**
  30499. * Initializes the physics imposter
  30500. * @param object The physics-enabled object used as the physics imposter
  30501. * @param type The type of the physics imposter
  30502. * @param _options The options for the physics imposter
  30503. * @param _scene The Babylon scene
  30504. */
  30505. constructor(
  30506. /**
  30507. * The physics-enabled object used as the physics imposter
  30508. */
  30509. object: IPhysicsEnabledObject,
  30510. /**
  30511. * The type of the physics imposter
  30512. */
  30513. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  30514. /**
  30515. * This function will completly initialize this impostor.
  30516. * It will create a new body - but only if this mesh has no parent.
  30517. * If it has, this impostor will not be used other than to define the impostor
  30518. * of the child mesh.
  30519. * @hidden
  30520. */
  30521. _init(): void;
  30522. private _getPhysicsParent;
  30523. /**
  30524. * Should a new body be generated.
  30525. * @returns boolean specifying if body initialization is required
  30526. */
  30527. isBodyInitRequired(): boolean;
  30528. /**
  30529. * Sets the updated scaling
  30530. * @param updated Specifies if the scaling is updated
  30531. */
  30532. setScalingUpdated(updated: boolean): void;
  30533. /**
  30534. * Force a regeneration of this or the parent's impostor's body.
  30535. * Use under cautious - This will remove all joints already implemented.
  30536. */
  30537. forceUpdate(): void;
  30538. /**
  30539. * Gets the body that holds this impostor. Either its own, or its parent.
  30540. */
  30541. /**
  30542. * Set the physics body. Used mainly by the physics engine/plugin
  30543. */
  30544. physicsBody: any;
  30545. /**
  30546. * Get the parent of the physics imposter
  30547. * @returns Physics imposter or null
  30548. */
  30549. /**
  30550. * Sets the parent of the physics imposter
  30551. */
  30552. parent: Nullable<PhysicsImpostor>;
  30553. /**
  30554. * Resets the update flags
  30555. */
  30556. resetUpdateFlags(): void;
  30557. /**
  30558. * Gets the object extend size
  30559. * @returns the object extend size
  30560. */
  30561. getObjectExtendSize(): Vector3;
  30562. /**
  30563. * Gets the object center
  30564. * @returns The object center
  30565. */
  30566. getObjectCenter(): Vector3;
  30567. /**
  30568. * Get a specific parametes from the options parameter
  30569. * @param paramName The object parameter name
  30570. * @returns The object parameter
  30571. */
  30572. getParam(paramName: string): any;
  30573. /**
  30574. * Sets a specific parameter in the options given to the physics plugin
  30575. * @param paramName The parameter name
  30576. * @param value The value of the parameter
  30577. */
  30578. setParam(paramName: string, value: number): void;
  30579. /**
  30580. * Specifically change the body's mass option. Won't recreate the physics body object
  30581. * @param mass The mass of the physics imposter
  30582. */
  30583. setMass(mass: number): void;
  30584. /**
  30585. * Gets the linear velocity
  30586. * @returns linear velocity or null
  30587. */
  30588. getLinearVelocity(): Nullable<Vector3>;
  30589. /**
  30590. * Sets the linear velocity
  30591. * @param velocity linear velocity or null
  30592. */
  30593. setLinearVelocity(velocity: Nullable<Vector3>): void;
  30594. /**
  30595. * Gets the angular velocity
  30596. * @returns angular velocity or null
  30597. */
  30598. getAngularVelocity(): Nullable<Vector3>;
  30599. /**
  30600. * Sets the angular velocity
  30601. * @param velocity The velocity or null
  30602. */
  30603. setAngularVelocity(velocity: Nullable<Vector3>): void;
  30604. /**
  30605. * Execute a function with the physics plugin native code
  30606. * Provide a function the will have two variables - the world object and the physics body object
  30607. * @param func The function to execute with the physics plugin native code
  30608. */
  30609. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  30610. /**
  30611. * Register a function that will be executed before the physics world is stepping forward
  30612. * @param func The function to execute before the physics world is stepped forward
  30613. */
  30614. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  30615. /**
  30616. * Unregister a function that will be executed before the physics world is stepping forward
  30617. * @param func The function to execute before the physics world is stepped forward
  30618. */
  30619. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  30620. /**
  30621. * Register a function that will be executed after the physics step
  30622. * @param func The function to execute after physics step
  30623. */
  30624. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  30625. /**
  30626. * Unregisters a function that will be executed after the physics step
  30627. * @param func The function to execute after physics step
  30628. */
  30629. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  30630. /**
  30631. * register a function that will be executed when this impostor collides against a different body
  30632. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  30633. * @param func Callback that is executed on collision
  30634. */
  30635. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  30636. /**
  30637. * Unregisters the physics imposter on contact
  30638. * @param collideAgainst The physics object to collide against
  30639. * @param func Callback to execute on collision
  30640. */
  30641. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  30642. private _tmpQuat;
  30643. private _tmpQuat2;
  30644. /**
  30645. * Get the parent rotation
  30646. * @returns The parent rotation
  30647. */
  30648. getParentsRotation(): Quaternion;
  30649. /**
  30650. * this function is executed by the physics engine.
  30651. */
  30652. beforeStep: () => void;
  30653. /**
  30654. * this function is executed by the physics engine
  30655. */
  30656. afterStep: () => void;
  30657. /**
  30658. * Legacy collision detection event support
  30659. */
  30660. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  30661. /**
  30662. * event and body object due to cannon's event-based architecture.
  30663. */
  30664. onCollide: (e: {
  30665. body: any;
  30666. }) => void;
  30667. /**
  30668. * Apply a force
  30669. * @param force The force to apply
  30670. * @param contactPoint The contact point for the force
  30671. * @returns The physics imposter
  30672. */
  30673. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  30674. /**
  30675. * Apply an impulse
  30676. * @param force The impulse force
  30677. * @param contactPoint The contact point for the impulse force
  30678. * @returns The physics imposter
  30679. */
  30680. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  30681. /**
  30682. * A help function to create a joint
  30683. * @param otherImpostor A physics imposter used to create a joint
  30684. * @param jointType The type of joint
  30685. * @param jointData The data for the joint
  30686. * @returns The physics imposter
  30687. */
  30688. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  30689. /**
  30690. * Add a joint to this impostor with a different impostor
  30691. * @param otherImpostor A physics imposter used to add a joint
  30692. * @param joint The joint to add
  30693. * @returns The physics imposter
  30694. */
  30695. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  30696. /**
  30697. * Will keep this body still, in a sleep mode.
  30698. * @returns the physics imposter
  30699. */
  30700. sleep(): PhysicsImpostor;
  30701. /**
  30702. * Wake the body up.
  30703. * @returns The physics imposter
  30704. */
  30705. wakeUp(): PhysicsImpostor;
  30706. /**
  30707. * Clones the physics imposter
  30708. * @param newObject The physics imposter clones to this physics-enabled object
  30709. * @returns A nullable physics imposter
  30710. */
  30711. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  30712. /**
  30713. * Disposes the physics imposter
  30714. */
  30715. dispose(): void;
  30716. /**
  30717. * Sets the delta position
  30718. * @param position The delta position amount
  30719. */
  30720. setDeltaPosition(position: Vector3): void;
  30721. /**
  30722. * Sets the delta rotation
  30723. * @param rotation The delta rotation amount
  30724. */
  30725. setDeltaRotation(rotation: Quaternion): void;
  30726. /**
  30727. * Gets the box size of the physics imposter and stores the result in the input parameter
  30728. * @param result Stores the box size
  30729. * @returns The physics imposter
  30730. */
  30731. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  30732. /**
  30733. * Gets the radius of the physics imposter
  30734. * @returns Radius of the physics imposter
  30735. */
  30736. getRadius(): number;
  30737. /**
  30738. * Sync a bone with this impostor
  30739. * @param bone The bone to sync to the impostor.
  30740. * @param boneMesh The mesh that the bone is influencing.
  30741. * @param jointPivot The pivot of the joint / bone in local space.
  30742. * @param distToJoint Optional distance from the impostor to the joint.
  30743. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  30744. */
  30745. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  30746. /**
  30747. * Sync impostor to a bone
  30748. * @param bone The bone that the impostor will be synced to.
  30749. * @param boneMesh The mesh that the bone is influencing.
  30750. * @param jointPivot The pivot of the joint / bone in local space.
  30751. * @param distToJoint Optional distance from the impostor to the joint.
  30752. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  30753. * @param boneAxis Optional vector3 axis the bone is aligned with
  30754. */
  30755. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  30756. /**
  30757. * No-Imposter type
  30758. */
  30759. static NoImpostor: number;
  30760. /**
  30761. * Sphere-Imposter type
  30762. */
  30763. static SphereImpostor: number;
  30764. /**
  30765. * Box-Imposter type
  30766. */
  30767. static BoxImpostor: number;
  30768. /**
  30769. * Plane-Imposter type
  30770. */
  30771. static PlaneImpostor: number;
  30772. /**
  30773. * Mesh-imposter type
  30774. */
  30775. static MeshImpostor: number;
  30776. /**
  30777. * Cylinder-Imposter type
  30778. */
  30779. static CylinderImpostor: number;
  30780. /**
  30781. * Particle-Imposter type
  30782. */
  30783. static ParticleImpostor: number;
  30784. /**
  30785. * Heightmap-Imposter type
  30786. */
  30787. static HeightmapImpostor: number;
  30788. }
  30789. }
  30790. declare module BABYLON {
  30791. /**
  30792. * Interface for Physics-Joint data
  30793. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  30794. */
  30795. interface PhysicsJointData {
  30796. /**
  30797. * The main pivot of the joint
  30798. */
  30799. mainPivot?: Vector3;
  30800. /**
  30801. * The connected pivot of the joint
  30802. */
  30803. connectedPivot?: Vector3;
  30804. /**
  30805. * The main axis of the joint
  30806. */
  30807. mainAxis?: Vector3;
  30808. /**
  30809. * The connected axis of the joint
  30810. */
  30811. connectedAxis?: Vector3;
  30812. /**
  30813. * The collision of the joint
  30814. */
  30815. collision?: boolean;
  30816. /**
  30817. * Native Oimo/Cannon/Energy data
  30818. */
  30819. nativeParams?: any;
  30820. }
  30821. /**
  30822. * This is a holder class for the physics joint created by the physics plugin
  30823. * It holds a set of functions to control the underlying joint
  30824. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  30825. */
  30826. class PhysicsJoint {
  30827. /**
  30828. * The type of the physics joint
  30829. */
  30830. type: number;
  30831. /**
  30832. * The data for the physics joint
  30833. */
  30834. jointData: PhysicsJointData;
  30835. private _physicsJoint;
  30836. protected _physicsPlugin: IPhysicsEnginePlugin;
  30837. /**
  30838. * Initializes the physics joint
  30839. * @param type The type of the physics joint
  30840. * @param jointData The data for the physics joint
  30841. */
  30842. constructor(
  30843. /**
  30844. * The type of the physics joint
  30845. */
  30846. type: number,
  30847. /**
  30848. * The data for the physics joint
  30849. */
  30850. jointData: PhysicsJointData);
  30851. /**
  30852. * Gets the physics joint
  30853. */
  30854. /**
  30855. * Sets the physics joint
  30856. */
  30857. physicsJoint: any;
  30858. /**
  30859. * Sets the physics plugin
  30860. */
  30861. physicsPlugin: IPhysicsEnginePlugin;
  30862. /**
  30863. * Execute a function that is physics-plugin specific.
  30864. * @param {Function} func the function that will be executed.
  30865. * It accepts two parameters: the physics world and the physics joint
  30866. */
  30867. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  30868. /**
  30869. * Distance-Joint type
  30870. */
  30871. static DistanceJoint: number;
  30872. /**
  30873. * Hinge-Joint type
  30874. */
  30875. static HingeJoint: number;
  30876. /**
  30877. * Ball-and-Socket joint type
  30878. */
  30879. static BallAndSocketJoint: number;
  30880. /**
  30881. * Wheel-Joint type
  30882. */
  30883. static WheelJoint: number;
  30884. /**
  30885. * Slider-Joint type
  30886. */
  30887. static SliderJoint: number;
  30888. /**
  30889. * Prismatic-Joint type
  30890. */
  30891. static PrismaticJoint: number;
  30892. /**
  30893. * Universal-Joint type
  30894. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  30895. */
  30896. static UniversalJoint: number;
  30897. /**
  30898. * Hinge-Joint 2 type
  30899. */
  30900. static Hinge2Joint: number;
  30901. /**
  30902. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  30903. */
  30904. static PointToPointJoint: number;
  30905. /**
  30906. * Spring-Joint type
  30907. */
  30908. static SpringJoint: number;
  30909. /**
  30910. * Lock-Joint type
  30911. */
  30912. static LockJoint: number;
  30913. }
  30914. /**
  30915. * A class representing a physics distance joint
  30916. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  30917. */
  30918. class DistanceJoint extends PhysicsJoint {
  30919. /**
  30920. *
  30921. * @param jointData The data for the Distance-Joint
  30922. */
  30923. constructor(jointData: DistanceJointData);
  30924. /**
  30925. * Update the predefined distance.
  30926. * @param maxDistance The maximum preferred distance
  30927. * @param minDistance The minimum preferred distance
  30928. */
  30929. updateDistance(maxDistance: number, minDistance?: number): void;
  30930. }
  30931. /**
  30932. * Represents a Motor-Enabled Joint
  30933. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  30934. */
  30935. class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  30936. /**
  30937. * Initializes the Motor-Enabled Joint
  30938. * @param type The type of the joint
  30939. * @param jointData The physica joint data for the joint
  30940. */
  30941. constructor(type: number, jointData: PhysicsJointData);
  30942. /**
  30943. * Set the motor values.
  30944. * Attention, this function is plugin specific. Engines won't react 100% the same.
  30945. * @param force the force to apply
  30946. * @param maxForce max force for this motor.
  30947. */
  30948. setMotor(force?: number, maxForce?: number): void;
  30949. /**
  30950. * Set the motor's limits.
  30951. * Attention, this function is plugin specific. Engines won't react 100% the same.
  30952. * @param upperLimit The upper limit of the motor
  30953. * @param lowerLimit The lower limit of the motor
  30954. */
  30955. setLimit(upperLimit: number, lowerLimit?: number): void;
  30956. }
  30957. /**
  30958. * This class represents a single physics Hinge-Joint
  30959. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  30960. */
  30961. class HingeJoint extends MotorEnabledJoint {
  30962. /**
  30963. * Initializes the Hinge-Joint
  30964. * @param jointData The joint data for the Hinge-Joint
  30965. */
  30966. constructor(jointData: PhysicsJointData);
  30967. /**
  30968. * Set the motor values.
  30969. * Attention, this function is plugin specific. Engines won't react 100% the same.
  30970. * @param {number} force the force to apply
  30971. * @param {number} maxForce max force for this motor.
  30972. */
  30973. setMotor(force?: number, maxForce?: number): void;
  30974. /**
  30975. * Set the motor's limits.
  30976. * Attention, this function is plugin specific. Engines won't react 100% the same.
  30977. * @param upperLimit The upper limit of the motor
  30978. * @param lowerLimit The lower limit of the motor
  30979. */
  30980. setLimit(upperLimit: number, lowerLimit?: number): void;
  30981. }
  30982. /**
  30983. * This class represents a dual hinge physics joint (same as wheel joint)
  30984. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  30985. */
  30986. class Hinge2Joint extends MotorEnabledJoint {
  30987. /**
  30988. * Initializes the Hinge2-Joint
  30989. * @param jointData The joint data for the Hinge2-Joint
  30990. */
  30991. constructor(jointData: PhysicsJointData);
  30992. /**
  30993. * Set the motor values.
  30994. * Attention, this function is plugin specific. Engines won't react 100% the same.
  30995. * @param {number} force the force to apply
  30996. * @param {number} maxForce max force for this motor.
  30997. * @param {motorIndex} the motor's index, 0 or 1.
  30998. */
  30999. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  31000. /**
  31001. * Set the motor limits.
  31002. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31003. * @param {number} upperLimit the upper limit
  31004. * @param {number} lowerLimit lower limit
  31005. * @param {motorIndex} the motor's index, 0 or 1.
  31006. */
  31007. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  31008. }
  31009. /**
  31010. * Interface for a motor enabled joint
  31011. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31012. */
  31013. interface IMotorEnabledJoint {
  31014. /**
  31015. * Physics joint
  31016. */
  31017. physicsJoint: any;
  31018. /**
  31019. * Sets the motor of the motor-enabled joint
  31020. * @param force The force of the motor
  31021. * @param maxForce The maximum force of the motor
  31022. * @param motorIndex The index of the motor
  31023. */
  31024. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  31025. /**
  31026. * Sets the limit of the motor
  31027. * @param upperLimit The upper limit of the motor
  31028. * @param lowerLimit The lower limit of the motor
  31029. * @param motorIndex The index of the motor
  31030. */
  31031. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  31032. }
  31033. /**
  31034. * Joint data for a Distance-Joint
  31035. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31036. */
  31037. interface DistanceJointData extends PhysicsJointData {
  31038. /**
  31039. * Max distance the 2 joint objects can be apart
  31040. */
  31041. maxDistance: number;
  31042. }
  31043. /**
  31044. * Joint data from a spring joint
  31045. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31046. */
  31047. interface SpringJointData extends PhysicsJointData {
  31048. /**
  31049. * Length of the spring
  31050. */
  31051. length: number;
  31052. /**
  31053. * Stiffness of the spring
  31054. */
  31055. stiffness: number;
  31056. /**
  31057. * Damping of the spring
  31058. */
  31059. damping: number;
  31060. /** this callback will be called when applying the force to the impostors. */
  31061. forceApplicationCallback: () => void;
  31062. }
  31063. }
  31064. declare module BABYLON {
  31065. /**
  31066. * This represents the base class for particle system in Babylon.
  31067. * 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.
  31068. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  31069. * @example https://doc.babylonjs.com/babylon101/particles
  31070. */
  31071. class BaseParticleSystem {
  31072. /**
  31073. * Source color is added to the destination color without alpha affecting the result
  31074. */
  31075. static BLENDMODE_ONEONE: number;
  31076. /**
  31077. * Blend current color and particle color using particle’s alpha
  31078. */
  31079. static BLENDMODE_STANDARD: number;
  31080. /**
  31081. * Add current color and particle color multiplied by particle’s alpha
  31082. */
  31083. static BLENDMODE_ADD: number;
  31084. /**
  31085. * Multiply current color with particle color
  31086. */
  31087. static BLENDMODE_MULTIPLY: number;
  31088. /**
  31089. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  31090. */
  31091. static BLENDMODE_MULTIPLYADD: number;
  31092. /**
  31093. * List of animations used by the particle system.
  31094. */
  31095. animations: Animation[];
  31096. /**
  31097. * The id of the Particle system.
  31098. */
  31099. id: string;
  31100. /**
  31101. * The friendly name of the Particle system.
  31102. */
  31103. name: string;
  31104. /**
  31105. * The rendering group used by the Particle system to chose when to render.
  31106. */
  31107. renderingGroupId: number;
  31108. /**
  31109. * The emitter represents the Mesh or position we are attaching the particle system to.
  31110. */
  31111. emitter: Nullable<AbstractMesh | Vector3>;
  31112. /**
  31113. * The maximum number of particles to emit per frame
  31114. */
  31115. emitRate: number;
  31116. /**
  31117. * If you want to launch only a few particles at once, that can be done, as well.
  31118. */
  31119. manualEmitCount: number;
  31120. /**
  31121. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  31122. */
  31123. updateSpeed: number;
  31124. /**
  31125. * The amount of time the particle system is running (depends of the overall update speed).
  31126. */
  31127. targetStopDuration: number;
  31128. /**
  31129. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  31130. */
  31131. disposeOnStop: boolean;
  31132. /**
  31133. * Minimum power of emitting particles.
  31134. */
  31135. minEmitPower: number;
  31136. /**
  31137. * Maximum power of emitting particles.
  31138. */
  31139. maxEmitPower: number;
  31140. /**
  31141. * Minimum life time of emitting particles.
  31142. */
  31143. minLifeTime: number;
  31144. /**
  31145. * Maximum life time of emitting particles.
  31146. */
  31147. maxLifeTime: number;
  31148. /**
  31149. * Minimum Size of emitting particles.
  31150. */
  31151. minSize: number;
  31152. /**
  31153. * Maximum Size of emitting particles.
  31154. */
  31155. maxSize: number;
  31156. /**
  31157. * Minimum scale of emitting particles on X axis.
  31158. */
  31159. minScaleX: number;
  31160. /**
  31161. * Maximum scale of emitting particles on X axis.
  31162. */
  31163. maxScaleX: number;
  31164. /**
  31165. * Minimum scale of emitting particles on Y axis.
  31166. */
  31167. minScaleY: number;
  31168. /**
  31169. * Maximum scale of emitting particles on Y axis.
  31170. */
  31171. maxScaleY: number;
  31172. /**
  31173. * Gets or sets the minimal initial rotation in radians.
  31174. */
  31175. minInitialRotation: number;
  31176. /**
  31177. * Gets or sets the maximal initial rotation in radians.
  31178. */
  31179. maxInitialRotation: number;
  31180. /**
  31181. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  31182. */
  31183. minAngularSpeed: number;
  31184. /**
  31185. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  31186. */
  31187. maxAngularSpeed: number;
  31188. /**
  31189. * The texture used to render each particle. (this can be a spritesheet)
  31190. */
  31191. particleTexture: Nullable<Texture>;
  31192. /**
  31193. * The layer mask we are rendering the particles through.
  31194. */
  31195. layerMask: number;
  31196. /**
  31197. * This can help using your own shader to render the particle system.
  31198. * The according effect will be created
  31199. */
  31200. customShader: any;
  31201. /**
  31202. * By default particle system starts as soon as they are created. This prevents the
  31203. * automatic start to happen and let you decide when to start emitting particles.
  31204. */
  31205. preventAutoStart: boolean;
  31206. /**
  31207. * Gets or sets a texture used to add random noise to particle positions
  31208. */
  31209. noiseTexture: Nullable<ProceduralTexture>;
  31210. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  31211. noiseStrength: Vector3;
  31212. /**
  31213. * Callback triggered when the particle animation is ending.
  31214. */
  31215. onAnimationEnd: Nullable<() => void>;
  31216. /**
  31217. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  31218. */
  31219. blendMode: number;
  31220. /**
  31221. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  31222. * to override the particles.
  31223. */
  31224. forceDepthWrite: boolean;
  31225. /** 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 */
  31226. preWarmCycles: number;
  31227. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  31228. preWarmStepOffset: number;
  31229. /**
  31230. * 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)
  31231. */
  31232. spriteCellChangeSpeed: number;
  31233. /**
  31234. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  31235. */
  31236. startSpriteCellID: number;
  31237. /**
  31238. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  31239. */
  31240. endSpriteCellID: number;
  31241. /**
  31242. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  31243. */
  31244. spriteCellWidth: number;
  31245. /**
  31246. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  31247. */
  31248. spriteCellHeight: number;
  31249. /**
  31250. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  31251. */
  31252. spriteRandomStartCell: boolean;
  31253. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  31254. translationPivot: Vector2;
  31255. /** @hidden */
  31256. protected _isAnimationSheetEnabled: boolean;
  31257. /**
  31258. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  31259. */
  31260. beginAnimationOnStart: boolean;
  31261. /**
  31262. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  31263. */
  31264. beginAnimationFrom: number;
  31265. /**
  31266. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  31267. */
  31268. beginAnimationTo: number;
  31269. /**
  31270. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  31271. */
  31272. beginAnimationLoop: boolean;
  31273. /**
  31274. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  31275. */
  31276. isAnimationSheetEnabled: boolean;
  31277. /**
  31278. * Get hosting scene
  31279. * @returns the scene
  31280. */
  31281. getScene(): Scene;
  31282. /**
  31283. * You can use gravity if you want to give an orientation to your particles.
  31284. */
  31285. gravity: Vector3;
  31286. protected _colorGradients: Nullable<Array<ColorGradient>>;
  31287. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  31288. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  31289. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  31290. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  31291. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  31292. protected _dragGradients: Nullable<Array<FactorGradient>>;
  31293. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  31294. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  31295. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  31296. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  31297. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  31298. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  31299. /**
  31300. * Defines the delay in milliseconds before starting the system (0 by default)
  31301. */
  31302. startDelay: number;
  31303. /**
  31304. * Gets the current list of drag gradients.
  31305. * You must use addDragGradient and removeDragGradient to udpate this list
  31306. * @returns the list of drag gradients
  31307. */
  31308. getDragGradients(): Nullable<Array<FactorGradient>>;
  31309. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  31310. limitVelocityDamping: number;
  31311. /**
  31312. * Gets the current list of limit velocity gradients.
  31313. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  31314. * @returns the list of limit velocity gradients
  31315. */
  31316. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  31317. /**
  31318. * Gets the current list of color gradients.
  31319. * You must use addColorGradient and removeColorGradient to udpate this list
  31320. * @returns the list of color gradients
  31321. */
  31322. getColorGradients(): Nullable<Array<ColorGradient>>;
  31323. /**
  31324. * Gets the current list of size gradients.
  31325. * You must use addSizeGradient and removeSizeGradient to udpate this list
  31326. * @returns the list of size gradients
  31327. */
  31328. getSizeGradients(): Nullable<Array<FactorGradient>>;
  31329. /**
  31330. * Gets the current list of color remap gradients.
  31331. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  31332. * @returns the list of color remap gradients
  31333. */
  31334. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  31335. /**
  31336. * Gets the current list of alpha remap gradients.
  31337. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  31338. * @returns the list of alpha remap gradients
  31339. */
  31340. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  31341. /**
  31342. * Gets the current list of life time gradients.
  31343. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  31344. * @returns the list of life time gradients
  31345. */
  31346. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  31347. /**
  31348. * Gets the current list of angular speed gradients.
  31349. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  31350. * @returns the list of angular speed gradients
  31351. */
  31352. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  31353. /**
  31354. * Gets the current list of velocity gradients.
  31355. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  31356. * @returns the list of velocity gradients
  31357. */
  31358. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  31359. /**
  31360. * Gets the current list of start size gradients.
  31361. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  31362. * @returns the list of start size gradients
  31363. */
  31364. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  31365. /**
  31366. * Gets the current list of emit rate gradients.
  31367. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  31368. * @returns the list of emit rate gradients
  31369. */
  31370. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  31371. /**
  31372. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  31373. * This only works when particleEmitterTyps is a BoxParticleEmitter
  31374. */
  31375. direction1: Vector3;
  31376. /**
  31377. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  31378. * This only works when particleEmitterTyps is a BoxParticleEmitter
  31379. */
  31380. direction2: Vector3;
  31381. /**
  31382. * 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.
  31383. * This only works when particleEmitterTyps is a BoxParticleEmitter
  31384. */
  31385. minEmitBox: Vector3;
  31386. /**
  31387. * 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.
  31388. * This only works when particleEmitterTyps is a BoxParticleEmitter
  31389. */
  31390. maxEmitBox: Vector3;
  31391. /**
  31392. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  31393. */
  31394. color1: Color4;
  31395. /**
  31396. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  31397. */
  31398. color2: Color4;
  31399. /**
  31400. * Color the particle will have at the end of its lifetime
  31401. */
  31402. colorDead: Color4;
  31403. /**
  31404. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  31405. */
  31406. textureMask: Color4;
  31407. /**
  31408. * The particle emitter type defines the emitter used by the particle system.
  31409. * It can be for example box, sphere, or cone...
  31410. */
  31411. particleEmitterType: IParticleEmitterType;
  31412. /** @hidden */
  31413. _isSubEmitter: boolean;
  31414. /**
  31415. * Gets or sets the billboard mode to use when isBillboardBased = true.
  31416. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  31417. */
  31418. billboardMode: number;
  31419. protected _isBillboardBased: boolean;
  31420. /**
  31421. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  31422. */
  31423. isBillboardBased: boolean;
  31424. /**
  31425. * The scene the particle system belongs to.
  31426. */
  31427. protected _scene: Scene;
  31428. /**
  31429. * Local cache of defines for image processing.
  31430. */
  31431. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  31432. /**
  31433. * Default configuration related to image processing available in the standard Material.
  31434. */
  31435. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  31436. /**
  31437. * Gets the image processing configuration used either in this material.
  31438. */
  31439. /**
  31440. * Sets the Default image processing configuration used either in the this material.
  31441. *
  31442. * If sets to null, the scene one is in use.
  31443. */
  31444. imageProcessingConfiguration: ImageProcessingConfiguration;
  31445. /**
  31446. * Attaches a new image processing configuration to the Standard Material.
  31447. * @param configuration
  31448. */
  31449. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  31450. /** @hidden */
  31451. protected _reset(): void;
  31452. /** @hidden */
  31453. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  31454. /**
  31455. * Instantiates a particle system.
  31456. * 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.
  31457. * @param name The name of the particle system
  31458. */
  31459. constructor(name: string);
  31460. /**
  31461. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  31462. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  31463. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  31464. * @returns the emitter
  31465. */
  31466. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  31467. /**
  31468. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  31469. * @param radius The radius of the hemisphere to emit from
  31470. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  31471. * @returns the emitter
  31472. */
  31473. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  31474. /**
  31475. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  31476. * @param radius The radius of the sphere to emit from
  31477. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  31478. * @returns the emitter
  31479. */
  31480. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  31481. /**
  31482. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  31483. * @param radius The radius of the sphere to emit from
  31484. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  31485. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  31486. * @returns the emitter
  31487. */
  31488. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  31489. /**
  31490. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  31491. * @param radius The radius of the emission cylinder
  31492. * @param height The height of the emission cylinder
  31493. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  31494. * @param directionRandomizer How much to randomize the particle direction [0-1]
  31495. * @returns the emitter
  31496. */
  31497. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  31498. /**
  31499. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  31500. * @param radius The radius of the cylinder to emit from
  31501. * @param height The height of the emission cylinder
  31502. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  31503. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  31504. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  31505. * @returns the emitter
  31506. */
  31507. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  31508. /**
  31509. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  31510. * @param radius The radius of the cone to emit from
  31511. * @param angle The base angle of the cone
  31512. * @returns the emitter
  31513. */
  31514. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  31515. /**
  31516. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  31517. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  31518. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  31519. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  31520. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  31521. * @returns the emitter
  31522. */
  31523. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  31524. }
  31525. }
  31526. declare module BABYLON {
  31527. /**
  31528. * This represents a GPU particle system in Babylon
  31529. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  31530. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  31531. */
  31532. class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  31533. /**
  31534. * The layer mask we are rendering the particles through.
  31535. */
  31536. layerMask: number;
  31537. private _capacity;
  31538. private _activeCount;
  31539. private _currentActiveCount;
  31540. private _accumulatedCount;
  31541. private _renderEffect;
  31542. private _updateEffect;
  31543. private _buffer0;
  31544. private _buffer1;
  31545. private _spriteBuffer;
  31546. private _updateVAO;
  31547. private _renderVAO;
  31548. private _targetIndex;
  31549. private _sourceBuffer;
  31550. private _targetBuffer;
  31551. private _engine;
  31552. private _currentRenderId;
  31553. private _started;
  31554. private _stopped;
  31555. private _timeDelta;
  31556. private _randomTexture;
  31557. private _randomTexture2;
  31558. private _attributesStrideSize;
  31559. private _updateEffectOptions;
  31560. private _randomTextureSize;
  31561. private _actualFrame;
  31562. private readonly _rawTextureWidth;
  31563. /**
  31564. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  31565. */
  31566. static readonly IsSupported: boolean;
  31567. /**
  31568. * An event triggered when the system is disposed.
  31569. */
  31570. onDisposeObservable: Observable<GPUParticleSystem>;
  31571. /**
  31572. * Gets the maximum number of particles active at the same time.
  31573. * @returns The max number of active particles.
  31574. */
  31575. getCapacity(): number;
  31576. /**
  31577. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  31578. * to override the particles.
  31579. */
  31580. forceDepthWrite: boolean;
  31581. /**
  31582. * Gets or set the number of active particles
  31583. */
  31584. activeParticleCount: number;
  31585. private _preWarmDone;
  31586. /**
  31587. * Is this system ready to be used/rendered
  31588. * @return true if the system is ready
  31589. */
  31590. isReady(): boolean;
  31591. /**
  31592. * Gets if the system has been started. (Note: this will still be true after stop is called)
  31593. * @returns True if it has been started, otherwise false.
  31594. */
  31595. isStarted(): boolean;
  31596. /**
  31597. * Starts the particle system and begins to emit
  31598. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  31599. */
  31600. start(delay?: number): void;
  31601. /**
  31602. * Stops the particle system.
  31603. */
  31604. stop(): void;
  31605. /**
  31606. * Remove all active particles
  31607. */
  31608. reset(): void;
  31609. /**
  31610. * Returns the string "GPUParticleSystem"
  31611. * @returns a string containing the class name
  31612. */
  31613. getClassName(): string;
  31614. private _colorGradientsTexture;
  31615. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  31616. /**
  31617. * Adds a new color gradient
  31618. * @param gradient defines the gradient to use (between 0 and 1)
  31619. * @param color1 defines the color to affect to the specified gradient
  31620. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  31621. * @returns the current particle system
  31622. */
  31623. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  31624. /**
  31625. * Remove a specific color gradient
  31626. * @param gradient defines the gradient to remove
  31627. * @returns the current particle system
  31628. */
  31629. removeColorGradient(gradient: number): GPUParticleSystem;
  31630. private _angularSpeedGradientsTexture;
  31631. private _sizeGradientsTexture;
  31632. private _velocityGradientsTexture;
  31633. private _limitVelocityGradientsTexture;
  31634. private _dragGradientsTexture;
  31635. private _addFactorGradient;
  31636. /**
  31637. * Adds a new size gradient
  31638. * @param gradient defines the gradient to use (between 0 and 1)
  31639. * @param factor defines the size factor to affect to the specified gradient
  31640. * @returns the current particle system
  31641. */
  31642. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  31643. /**
  31644. * Remove a specific size gradient
  31645. * @param gradient defines the gradient to remove
  31646. * @returns the current particle system
  31647. */
  31648. removeSizeGradient(gradient: number): GPUParticleSystem;
  31649. /**
  31650. * Adds a new angular speed gradient
  31651. * @param gradient defines the gradient to use (between 0 and 1)
  31652. * @param factor defines the angular speed to affect to the specified gradient
  31653. * @returns the current particle system
  31654. */
  31655. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  31656. /**
  31657. * Remove a specific angular speed gradient
  31658. * @param gradient defines the gradient to remove
  31659. * @returns the current particle system
  31660. */
  31661. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  31662. /**
  31663. * Adds a new velocity gradient
  31664. * @param gradient defines the gradient to use (between 0 and 1)
  31665. * @param factor defines the velocity to affect to the specified gradient
  31666. * @returns the current particle system
  31667. */
  31668. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  31669. /**
  31670. * Remove a specific velocity gradient
  31671. * @param gradient defines the gradient to remove
  31672. * @returns the current particle system
  31673. */
  31674. removeVelocityGradient(gradient: number): GPUParticleSystem;
  31675. /**
  31676. * Adds a new limit velocity gradient
  31677. * @param gradient defines the gradient to use (between 0 and 1)
  31678. * @param factor defines the limit velocity value to affect to the specified gradient
  31679. * @returns the current particle system
  31680. */
  31681. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  31682. /**
  31683. * Remove a specific limit velocity gradient
  31684. * @param gradient defines the gradient to remove
  31685. * @returns the current particle system
  31686. */
  31687. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  31688. /**
  31689. * Adds a new drag gradient
  31690. * @param gradient defines the gradient to use (between 0 and 1)
  31691. * @param factor defines the drag value to affect to the specified gradient
  31692. * @returns the current particle system
  31693. */
  31694. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  31695. /**
  31696. * Remove a specific drag gradient
  31697. * @param gradient defines the gradient to remove
  31698. * @returns the current particle system
  31699. */
  31700. removeDragGradient(gradient: number): GPUParticleSystem;
  31701. /**
  31702. * Not supported by GPUParticleSystem
  31703. * @param gradient defines the gradient to use (between 0 and 1)
  31704. * @param factor defines the emit rate value to affect to the specified gradient
  31705. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31706. * @returns the current particle system
  31707. */
  31708. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31709. /**
  31710. * Not supported by GPUParticleSystem
  31711. * @param gradient defines the gradient to remove
  31712. * @returns the current particle system
  31713. */
  31714. removeEmitRateGradient(gradient: number): IParticleSystem;
  31715. /**
  31716. * Not supported by GPUParticleSystem
  31717. * @param gradient defines the gradient to use (between 0 and 1)
  31718. * @param factor defines the start size value to affect to the specified gradient
  31719. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31720. * @returns the current particle system
  31721. */
  31722. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31723. /**
  31724. * Not supported by GPUParticleSystem
  31725. * @param gradient defines the gradient to remove
  31726. * @returns the current particle system
  31727. */
  31728. removeStartSizeGradient(gradient: number): IParticleSystem;
  31729. /**
  31730. * Not supported by GPUParticleSystem
  31731. * @param gradient defines the gradient to use (between 0 and 1)
  31732. * @param min defines the color remap minimal range
  31733. * @param max defines the color remap maximal range
  31734. * @returns the current particle system
  31735. */
  31736. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  31737. /**
  31738. * Not supported by GPUParticleSystem
  31739. * @param gradient defines the gradient to remove
  31740. * @returns the current particle system
  31741. */
  31742. removeColorRemapGradient(gradient: number): IParticleSystem;
  31743. /**
  31744. * Not supported by GPUParticleSystem
  31745. * @param gradient defines the gradient to use (between 0 and 1)
  31746. * @param min defines the alpha remap minimal range
  31747. * @param max defines the alpha remap maximal range
  31748. * @returns the current particle system
  31749. */
  31750. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  31751. /**
  31752. * Not supported by GPUParticleSystem
  31753. * @param gradient defines the gradient to remove
  31754. * @returns the current particle system
  31755. */
  31756. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  31757. /**
  31758. * Not supported by GPUParticleSystem
  31759. * @param gradient defines the gradient to use (between 0 and 1)
  31760. * @param color defines the color to affect to the specified gradient
  31761. * @returns the current particle system
  31762. */
  31763. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  31764. /**
  31765. * Not supported by GPUParticleSystem
  31766. * @param gradient defines the gradient to remove
  31767. * @returns the current particle system
  31768. */
  31769. removeRampGradient(gradient: number): IParticleSystem;
  31770. /**
  31771. * Not supported by GPUParticleSystem
  31772. * @returns the list of ramp gradients
  31773. */
  31774. getRampGradients(): Nullable<Array<Color3Gradient>>;
  31775. /**
  31776. * Not supported by GPUParticleSystem
  31777. * Gets or sets a boolean indicating that ramp gradients must be used
  31778. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  31779. */
  31780. useRampGradients: boolean;
  31781. /**
  31782. * Not supported by GPUParticleSystem
  31783. * @param gradient defines the gradient to use (between 0 and 1)
  31784. * @param factor defines the life time factor to affect to the specified gradient
  31785. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31786. * @returns the current particle system
  31787. */
  31788. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31789. /**
  31790. * Not supported by GPUParticleSystem
  31791. * @param gradient defines the gradient to remove
  31792. * @returns the current particle system
  31793. */
  31794. removeLifeTimeGradient(gradient: number): IParticleSystem;
  31795. /**
  31796. * Instantiates a GPU particle system.
  31797. * 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.
  31798. * @param name The name of the particle system
  31799. * @param options The options used to create the system
  31800. * @param scene The scene the particle system belongs to
  31801. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  31802. */
  31803. constructor(name: string, options: Partial<{
  31804. capacity: number;
  31805. randomTextureSize: number;
  31806. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  31807. protected _reset(): void;
  31808. private _createUpdateVAO;
  31809. private _createRenderVAO;
  31810. private _initialize;
  31811. /** @hidden */
  31812. _recreateUpdateEffect(): void;
  31813. /** @hidden */
  31814. _recreateRenderEffect(): void;
  31815. /**
  31816. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  31817. * @param preWarm defines if we are in the pre-warmimg phase
  31818. */
  31819. animate(preWarm?: boolean): void;
  31820. private _createFactorGradientTexture;
  31821. private _createSizeGradientTexture;
  31822. private _createAngularSpeedGradientTexture;
  31823. private _createVelocityGradientTexture;
  31824. private _createLimitVelocityGradientTexture;
  31825. private _createDragGradientTexture;
  31826. private _createColorGradientTexture;
  31827. /**
  31828. * Renders the particle system in its current state
  31829. * @param preWarm defines if the system should only update the particles but not render them
  31830. * @returns the current number of particles
  31831. */
  31832. render(preWarm?: boolean): number;
  31833. /**
  31834. * Rebuilds the particle system
  31835. */
  31836. rebuild(): void;
  31837. private _releaseBuffers;
  31838. private _releaseVAOs;
  31839. /**
  31840. * Disposes the particle system and free the associated resources
  31841. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  31842. */
  31843. dispose(disposeTexture?: boolean): void;
  31844. /**
  31845. * Clones the particle system.
  31846. * @param name The name of the cloned object
  31847. * @param newEmitter The new emitter to use
  31848. * @returns the cloned particle system
  31849. */
  31850. clone(name: string, newEmitter: any): GPUParticleSystem;
  31851. /**
  31852. * Serializes the particle system to a JSON object.
  31853. * @returns the JSON object
  31854. */
  31855. serialize(): any;
  31856. /**
  31857. * Parses a JSON object to create a GPU particle system.
  31858. * @param parsedParticleSystem The JSON object to parse
  31859. * @param scene The scene to create the particle system in
  31860. * @param rootUrl The root url to use to load external dependencies like texture
  31861. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  31862. * @returns the parsed GPU particle system
  31863. */
  31864. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  31865. }
  31866. }
  31867. declare module BABYLON {
  31868. /**
  31869. * Interface representing a particle system in Babylon.js.
  31870. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  31871. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  31872. */
  31873. interface IParticleSystem {
  31874. /**
  31875. * List of animations used by the particle system.
  31876. */
  31877. animations: Animation[];
  31878. /**
  31879. * The id of the Particle system.
  31880. */
  31881. id: string;
  31882. /**
  31883. * The name of the Particle system.
  31884. */
  31885. name: string;
  31886. /**
  31887. * The emitter represents the Mesh or position we are attaching the particle system to.
  31888. */
  31889. emitter: Nullable<AbstractMesh | Vector3>;
  31890. /**
  31891. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  31892. */
  31893. isBillboardBased: boolean;
  31894. /**
  31895. * The rendering group used by the Particle system to chose when to render.
  31896. */
  31897. renderingGroupId: number;
  31898. /**
  31899. * The layer mask we are rendering the particles through.
  31900. */
  31901. layerMask: number;
  31902. /**
  31903. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  31904. */
  31905. updateSpeed: number;
  31906. /**
  31907. * The amount of time the particle system is running (depends of the overall update speed).
  31908. */
  31909. targetStopDuration: number;
  31910. /**
  31911. * The texture used to render each particle. (this can be a spritesheet)
  31912. */
  31913. particleTexture: Nullable<Texture>;
  31914. /**
  31915. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  31916. */
  31917. blendMode: number;
  31918. /**
  31919. * Minimum life time of emitting particles.
  31920. */
  31921. minLifeTime: number;
  31922. /**
  31923. * Maximum life time of emitting particles.
  31924. */
  31925. maxLifeTime: number;
  31926. /**
  31927. * Minimum Size of emitting particles.
  31928. */
  31929. minSize: number;
  31930. /**
  31931. * Maximum Size of emitting particles.
  31932. */
  31933. maxSize: number;
  31934. /**
  31935. * Minimum scale of emitting particles on X axis.
  31936. */
  31937. minScaleX: number;
  31938. /**
  31939. * Maximum scale of emitting particles on X axis.
  31940. */
  31941. maxScaleX: number;
  31942. /**
  31943. * Minimum scale of emitting particles on Y axis.
  31944. */
  31945. minScaleY: number;
  31946. /**
  31947. * Maximum scale of emitting particles on Y axis.
  31948. */
  31949. maxScaleY: number;
  31950. /**
  31951. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  31952. */
  31953. color1: Color4;
  31954. /**
  31955. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  31956. */
  31957. color2: Color4;
  31958. /**
  31959. * Color the particle will have at the end of its lifetime.
  31960. */
  31961. colorDead: Color4;
  31962. /**
  31963. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  31964. */
  31965. emitRate: number;
  31966. /**
  31967. * You can use gravity if you want to give an orientation to your particles.
  31968. */
  31969. gravity: Vector3;
  31970. /**
  31971. * Minimum power of emitting particles.
  31972. */
  31973. minEmitPower: number;
  31974. /**
  31975. * Maximum power of emitting particles.
  31976. */
  31977. maxEmitPower: number;
  31978. /**
  31979. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  31980. */
  31981. minAngularSpeed: number;
  31982. /**
  31983. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  31984. */
  31985. maxAngularSpeed: number;
  31986. /**
  31987. * Gets or sets the minimal initial rotation in radians.
  31988. */
  31989. minInitialRotation: number;
  31990. /**
  31991. * Gets or sets the maximal initial rotation in radians.
  31992. */
  31993. maxInitialRotation: number;
  31994. /**
  31995. * The particle emitter type defines the emitter used by the particle system.
  31996. * It can be for example box, sphere, or cone...
  31997. */
  31998. particleEmitterType: Nullable<IParticleEmitterType>;
  31999. /**
  32000. * Defines the delay in milliseconds before starting the system (0 by default)
  32001. */
  32002. startDelay: number;
  32003. /**
  32004. * 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
  32005. */
  32006. preWarmCycles: number;
  32007. /**
  32008. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  32009. */
  32010. preWarmStepOffset: number;
  32011. /**
  32012. * 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)
  32013. */
  32014. spriteCellChangeSpeed: number;
  32015. /**
  32016. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  32017. */
  32018. startSpriteCellID: number;
  32019. /**
  32020. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  32021. */
  32022. endSpriteCellID: number;
  32023. /**
  32024. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  32025. */
  32026. spriteCellWidth: number;
  32027. /**
  32028. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  32029. */
  32030. spriteCellHeight: number;
  32031. /**
  32032. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  32033. */
  32034. spriteRandomStartCell: boolean;
  32035. /**
  32036. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  32037. */
  32038. isAnimationSheetEnabled: boolean;
  32039. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  32040. translationPivot: Vector2;
  32041. /**
  32042. * Gets or sets a texture used to add random noise to particle positions
  32043. */
  32044. noiseTexture: Nullable<BaseTexture>;
  32045. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  32046. noiseStrength: Vector3;
  32047. /**
  32048. * Gets or sets the billboard mode to use when isBillboardBased = true.
  32049. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  32050. */
  32051. billboardMode: number;
  32052. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  32053. limitVelocityDamping: number;
  32054. /**
  32055. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  32056. */
  32057. beginAnimationOnStart: boolean;
  32058. /**
  32059. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  32060. */
  32061. beginAnimationFrom: number;
  32062. /**
  32063. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  32064. */
  32065. beginAnimationTo: number;
  32066. /**
  32067. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  32068. */
  32069. beginAnimationLoop: boolean;
  32070. /**
  32071. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  32072. */
  32073. disposeOnStop: boolean;
  32074. /**
  32075. * Gets the maximum number of particles active at the same time.
  32076. * @returns The max number of active particles.
  32077. */
  32078. getCapacity(): number;
  32079. /**
  32080. * Gets if the system has been started. (Note: this will still be true after stop is called)
  32081. * @returns True if it has been started, otherwise false.
  32082. */
  32083. isStarted(): boolean;
  32084. /**
  32085. * Animates the particle system for this frame.
  32086. */
  32087. animate(): void;
  32088. /**
  32089. * Renders the particle system in its current state.
  32090. * @returns the current number of particles
  32091. */
  32092. render(): number;
  32093. /**
  32094. * Dispose the particle system and frees its associated resources.
  32095. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  32096. */
  32097. dispose(disposeTexture?: boolean): void;
  32098. /**
  32099. * Clones the particle system.
  32100. * @param name The name of the cloned object
  32101. * @param newEmitter The new emitter to use
  32102. * @returns the cloned particle system
  32103. */
  32104. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  32105. /**
  32106. * Serializes the particle system to a JSON object.
  32107. * @returns the JSON object
  32108. */
  32109. serialize(): any;
  32110. /**
  32111. * Rebuild the particle system
  32112. */
  32113. rebuild(): void;
  32114. /**
  32115. * Starts the particle system and begins to emit
  32116. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  32117. */
  32118. start(delay?: number): void;
  32119. /**
  32120. * Stops the particle system.
  32121. */
  32122. stop(): void;
  32123. /**
  32124. * Remove all active particles
  32125. */
  32126. reset(): void;
  32127. /**
  32128. * Is this system ready to be used/rendered
  32129. * @return true if the system is ready
  32130. */
  32131. isReady(): boolean;
  32132. /**
  32133. * Adds a new color gradient
  32134. * @param gradient defines the gradient to use (between 0 and 1)
  32135. * @param color1 defines the color to affect to the specified gradient
  32136. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  32137. * @returns the current particle system
  32138. */
  32139. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  32140. /**
  32141. * Remove a specific color gradient
  32142. * @param gradient defines the gradient to remove
  32143. * @returns the current particle system
  32144. */
  32145. removeColorGradient(gradient: number): IParticleSystem;
  32146. /**
  32147. * Adds a new size gradient
  32148. * @param gradient defines the gradient to use (between 0 and 1)
  32149. * @param factor defines the size factor to affect to the specified gradient
  32150. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32151. * @returns the current particle system
  32152. */
  32153. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32154. /**
  32155. * Remove a specific size gradient
  32156. * @param gradient defines the gradient to remove
  32157. * @returns the current particle system
  32158. */
  32159. removeSizeGradient(gradient: number): IParticleSystem;
  32160. /**
  32161. * Gets the current list of color gradients.
  32162. * You must use addColorGradient and removeColorGradient to udpate this list
  32163. * @returns the list of color gradients
  32164. */
  32165. getColorGradients(): Nullable<Array<ColorGradient>>;
  32166. /**
  32167. * Gets the current list of size gradients.
  32168. * You must use addSizeGradient and removeSizeGradient to udpate this list
  32169. * @returns the list of size gradients
  32170. */
  32171. getSizeGradients(): Nullable<Array<FactorGradient>>;
  32172. /**
  32173. * Gets the current list of angular speed gradients.
  32174. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  32175. * @returns the list of angular speed gradients
  32176. */
  32177. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  32178. /**
  32179. * Adds a new angular speed gradient
  32180. * @param gradient defines the gradient to use (between 0 and 1)
  32181. * @param factor defines the angular speed to affect to the specified gradient
  32182. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32183. * @returns the current particle system
  32184. */
  32185. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32186. /**
  32187. * Remove a specific angular speed gradient
  32188. * @param gradient defines the gradient to remove
  32189. * @returns the current particle system
  32190. */
  32191. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  32192. /**
  32193. * Gets the current list of velocity gradients.
  32194. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  32195. * @returns the list of velocity gradients
  32196. */
  32197. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  32198. /**
  32199. * Adds a new velocity gradient
  32200. * @param gradient defines the gradient to use (between 0 and 1)
  32201. * @param factor defines the velocity to affect to the specified gradient
  32202. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32203. * @returns the current particle system
  32204. */
  32205. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32206. /**
  32207. * Remove a specific velocity gradient
  32208. * @param gradient defines the gradient to remove
  32209. * @returns the current particle system
  32210. */
  32211. removeVelocityGradient(gradient: number): IParticleSystem;
  32212. /**
  32213. * Gets the current list of limit velocity gradients.
  32214. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  32215. * @returns the list of limit velocity gradients
  32216. */
  32217. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  32218. /**
  32219. * Adds a new limit velocity gradient
  32220. * @param gradient defines the gradient to use (between 0 and 1)
  32221. * @param factor defines the limit velocity to affect to the specified gradient
  32222. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32223. * @returns the current particle system
  32224. */
  32225. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32226. /**
  32227. * Remove a specific limit velocity gradient
  32228. * @param gradient defines the gradient to remove
  32229. * @returns the current particle system
  32230. */
  32231. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  32232. /**
  32233. * Adds a new drag gradient
  32234. * @param gradient defines the gradient to use (between 0 and 1)
  32235. * @param factor defines the drag to affect to the specified gradient
  32236. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32237. * @returns the current particle system
  32238. */
  32239. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32240. /**
  32241. * Remove a specific drag gradient
  32242. * @param gradient defines the gradient to remove
  32243. * @returns the current particle system
  32244. */
  32245. removeDragGradient(gradient: number): IParticleSystem;
  32246. /**
  32247. * Gets the current list of drag gradients.
  32248. * You must use addDragGradient and removeDragGradient to udpate this list
  32249. * @returns the list of drag gradients
  32250. */
  32251. getDragGradients(): Nullable<Array<FactorGradient>>;
  32252. /**
  32253. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  32254. * @param gradient defines the gradient to use (between 0 and 1)
  32255. * @param factor defines the emit rate to affect to the specified gradient
  32256. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32257. * @returns the current particle system
  32258. */
  32259. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32260. /**
  32261. * Remove a specific emit rate gradient
  32262. * @param gradient defines the gradient to remove
  32263. * @returns the current particle system
  32264. */
  32265. removeEmitRateGradient(gradient: number): IParticleSystem;
  32266. /**
  32267. * Gets the current list of emit rate gradients.
  32268. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  32269. * @returns the list of emit rate gradients
  32270. */
  32271. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  32272. /**
  32273. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  32274. * @param gradient defines the gradient to use (between 0 and 1)
  32275. * @param factor defines the start size to affect to the specified gradient
  32276. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32277. * @returns the current particle system
  32278. */
  32279. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32280. /**
  32281. * Remove a specific start size gradient
  32282. * @param gradient defines the gradient to remove
  32283. * @returns the current particle system
  32284. */
  32285. removeStartSizeGradient(gradient: number): IParticleSystem;
  32286. /**
  32287. * Gets the current list of start size gradients.
  32288. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  32289. * @returns the list of start size gradients
  32290. */
  32291. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  32292. /**
  32293. * Adds a new life time gradient
  32294. * @param gradient defines the gradient to use (between 0 and 1)
  32295. * @param factor defines the life time factor to affect to the specified gradient
  32296. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32297. * @returns the current particle system
  32298. */
  32299. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32300. /**
  32301. * Remove a specific life time gradient
  32302. * @param gradient defines the gradient to remove
  32303. * @returns the current particle system
  32304. */
  32305. removeLifeTimeGradient(gradient: number): IParticleSystem;
  32306. /**
  32307. * Gets the current list of life time gradients.
  32308. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  32309. * @returns the list of life time gradients
  32310. */
  32311. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  32312. /**
  32313. * Gets the current list of color gradients.
  32314. * You must use addColorGradient and removeColorGradient to udpate this list
  32315. * @returns the list of color gradients
  32316. */
  32317. getColorGradients(): Nullable<Array<ColorGradient>>;
  32318. /**
  32319. * Adds a new ramp gradient used to remap particle colors
  32320. * @param gradient defines the gradient to use (between 0 and 1)
  32321. * @param color defines the color to affect to the specified gradient
  32322. * @returns the current particle system
  32323. */
  32324. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  32325. /**
  32326. * Gets the current list of ramp gradients.
  32327. * You must use addRampGradient and removeRampGradient to udpate this list
  32328. * @returns the list of ramp gradients
  32329. */
  32330. getRampGradients(): Nullable<Array<Color3Gradient>>;
  32331. /** Gets or sets a boolean indicating that ramp gradients must be used
  32332. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  32333. */
  32334. useRampGradients: boolean;
  32335. /**
  32336. * Adds a new color remap gradient
  32337. * @param gradient defines the gradient to use (between 0 and 1)
  32338. * @param min defines the color remap minimal range
  32339. * @param max defines the color remap maximal range
  32340. * @returns the current particle system
  32341. */
  32342. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  32343. /**
  32344. * Gets the current list of color remap gradients.
  32345. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  32346. * @returns the list of color remap gradients
  32347. */
  32348. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  32349. /**
  32350. * Adds a new alpha remap gradient
  32351. * @param gradient defines the gradient to use (between 0 and 1)
  32352. * @param min defines the alpha remap minimal range
  32353. * @param max defines the alpha remap maximal range
  32354. * @returns the current particle system
  32355. */
  32356. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  32357. /**
  32358. * Gets the current list of alpha remap gradients.
  32359. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  32360. * @returns the list of alpha remap gradients
  32361. */
  32362. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  32363. /**
  32364. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  32365. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  32366. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  32367. * @returns the emitter
  32368. */
  32369. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  32370. /**
  32371. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  32372. * @param radius The radius of the hemisphere to emit from
  32373. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  32374. * @returns the emitter
  32375. */
  32376. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  32377. /**
  32378. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  32379. * @param radius The radius of the sphere to emit from
  32380. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  32381. * @returns the emitter
  32382. */
  32383. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  32384. /**
  32385. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  32386. * @param radius The radius of the sphere to emit from
  32387. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  32388. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  32389. * @returns the emitter
  32390. */
  32391. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  32392. /**
  32393. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  32394. * @param radius The radius of the emission cylinder
  32395. * @param height The height of the emission cylinder
  32396. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  32397. * @param directionRandomizer How much to randomize the particle direction [0-1]
  32398. * @returns the emitter
  32399. */
  32400. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  32401. /**
  32402. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  32403. * @param radius The radius of the cylinder to emit from
  32404. * @param height The height of the emission cylinder
  32405. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  32406. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  32407. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  32408. * @returns the emitter
  32409. */
  32410. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  32411. /**
  32412. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  32413. * @param radius The radius of the cone to emit from
  32414. * @param angle The base angle of the cone
  32415. * @returns the emitter
  32416. */
  32417. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  32418. /**
  32419. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  32420. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  32421. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  32422. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  32423. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  32424. * @returns the emitter
  32425. */
  32426. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  32427. /**
  32428. * Get hosting scene
  32429. * @returns the scene
  32430. */
  32431. getScene(): Scene;
  32432. }
  32433. }
  32434. declare module BABYLON {
  32435. /**
  32436. * A particle represents one of the element emitted by a particle system.
  32437. * This is mainly define by its coordinates, direction, velocity and age.
  32438. */
  32439. class Particle {
  32440. /**
  32441. * The particle system the particle belongs to.
  32442. */
  32443. particleSystem: ParticleSystem;
  32444. private static _Count;
  32445. /**
  32446. * Unique ID of the particle
  32447. */
  32448. id: number;
  32449. /**
  32450. * The world position of the particle in the scene.
  32451. */
  32452. position: Vector3;
  32453. /**
  32454. * The world direction of the particle in the scene.
  32455. */
  32456. direction: Vector3;
  32457. /**
  32458. * The color of the particle.
  32459. */
  32460. color: Color4;
  32461. /**
  32462. * The color change of the particle per step.
  32463. */
  32464. colorStep: Color4;
  32465. /**
  32466. * Defines how long will the life of the particle be.
  32467. */
  32468. lifeTime: number;
  32469. /**
  32470. * The current age of the particle.
  32471. */
  32472. age: number;
  32473. /**
  32474. * The current size of the particle.
  32475. */
  32476. size: number;
  32477. /**
  32478. * The current scale of the particle.
  32479. */
  32480. scale: Vector2;
  32481. /**
  32482. * The current angle of the particle.
  32483. */
  32484. angle: number;
  32485. /**
  32486. * Defines how fast is the angle changing.
  32487. */
  32488. angularSpeed: number;
  32489. /**
  32490. * Defines the cell index used by the particle to be rendered from a sprite.
  32491. */
  32492. cellIndex: number;
  32493. /**
  32494. * The information required to support color remapping
  32495. */
  32496. remapData: Vector4;
  32497. /** @hidden */
  32498. _randomCellOffset?: number;
  32499. /** @hidden */
  32500. _initialDirection: Nullable<Vector3>;
  32501. /** @hidden */
  32502. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  32503. /** @hidden */
  32504. _initialStartSpriteCellID: number;
  32505. /** @hidden */
  32506. _initialEndSpriteCellID: number;
  32507. /** @hidden */
  32508. _currentColorGradient: Nullable<ColorGradient>;
  32509. /** @hidden */
  32510. _currentColor1: Color4;
  32511. /** @hidden */
  32512. _currentColor2: Color4;
  32513. /** @hidden */
  32514. _currentSizeGradient: Nullable<FactorGradient>;
  32515. /** @hidden */
  32516. _currentSize1: number;
  32517. /** @hidden */
  32518. _currentSize2: number;
  32519. /** @hidden */
  32520. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  32521. /** @hidden */
  32522. _currentAngularSpeed1: number;
  32523. /** @hidden */
  32524. _currentAngularSpeed2: number;
  32525. /** @hidden */
  32526. _currentVelocityGradient: Nullable<FactorGradient>;
  32527. /** @hidden */
  32528. _currentVelocity1: number;
  32529. /** @hidden */
  32530. _currentVelocity2: number;
  32531. /** @hidden */
  32532. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  32533. /** @hidden */
  32534. _currentLimitVelocity1: number;
  32535. /** @hidden */
  32536. _currentLimitVelocity2: number;
  32537. /** @hidden */
  32538. _currentDragGradient: Nullable<FactorGradient>;
  32539. /** @hidden */
  32540. _currentDrag1: number;
  32541. /** @hidden */
  32542. _currentDrag2: number;
  32543. /** @hidden */
  32544. _randomNoiseCoordinates1: Vector3;
  32545. /** @hidden */
  32546. _randomNoiseCoordinates2: Vector3;
  32547. /**
  32548. * Creates a new instance Particle
  32549. * @param particleSystem the particle system the particle belongs to
  32550. */
  32551. constructor(
  32552. /**
  32553. * The particle system the particle belongs to.
  32554. */
  32555. particleSystem: ParticleSystem);
  32556. private updateCellInfoFromSystem;
  32557. /**
  32558. * Defines how the sprite cell index is updated for the particle
  32559. */
  32560. updateCellIndex(): void;
  32561. /** @hidden */
  32562. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  32563. /** @hidden */
  32564. _inheritParticleInfoToSubEmitters(): void;
  32565. /** @hidden */
  32566. _reset(): void;
  32567. /**
  32568. * Copy the properties of particle to another one.
  32569. * @param other the particle to copy the information to.
  32570. */
  32571. copyTo(other: Particle): void;
  32572. }
  32573. }
  32574. declare module BABYLON {
  32575. /**
  32576. * This class is made for on one-liner static method to help creating particle system set.
  32577. */
  32578. class ParticleHelper {
  32579. /**
  32580. * Gets or sets base Assets URL
  32581. */
  32582. static BaseAssetsUrl: string;
  32583. /**
  32584. * Create a default particle system that you can tweak
  32585. * @param emitter defines the emitter to use
  32586. * @param capacity defines the system capacity (default is 500 particles)
  32587. * @param scene defines the hosting scene
  32588. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  32589. * @returns the new Particle system
  32590. */
  32591. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  32592. /**
  32593. * This is the main static method (one-liner) of this helper to create different particle systems
  32594. * @param type This string represents the type to the particle system to create
  32595. * @param scene The scene where the particle system should live
  32596. * @param gpu If the system will use gpu
  32597. * @returns the ParticleSystemSet created
  32598. */
  32599. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  32600. /**
  32601. * Static function used to export a particle system to a ParticleSystemSet variable.
  32602. * Please note that the emitter shape is not exported
  32603. * @param systems defines the particle systems to export
  32604. * @returns the created particle system set
  32605. */
  32606. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  32607. }
  32608. }
  32609. declare module BABYLON {
  32610. /**
  32611. * This represents a particle system in Babylon.
  32612. * 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.
  32613. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  32614. * @example https://doc.babylonjs.com/babylon101/particles
  32615. */
  32616. class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  32617. /**
  32618. * Billboard mode will only apply to Y axis
  32619. */
  32620. static readonly BILLBOARDMODE_Y: number;
  32621. /**
  32622. * Billboard mode will apply to all axes
  32623. */
  32624. static readonly BILLBOARDMODE_ALL: number;
  32625. /**
  32626. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  32627. */
  32628. static readonly BILLBOARDMODE_STRETCHED: number;
  32629. /**
  32630. * This function can be defined to provide custom update for active particles.
  32631. * This function will be called instead of regular update (age, position, color, etc.).
  32632. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  32633. */
  32634. updateFunction: (particles: Particle[]) => void;
  32635. private _emitterWorldMatrix;
  32636. /**
  32637. * This function can be defined to specify initial direction for every new particle.
  32638. * It by default use the emitterType defined function
  32639. */
  32640. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  32641. /**
  32642. * This function can be defined to specify initial position for every new particle.
  32643. * It by default use the emitterType defined function
  32644. */
  32645. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  32646. /**
  32647. * @hidden
  32648. */
  32649. _inheritedVelocityOffset: Vector3;
  32650. /**
  32651. * An event triggered when the system is disposed
  32652. */
  32653. onDisposeObservable: Observable<ParticleSystem>;
  32654. private _onDisposeObserver;
  32655. /**
  32656. * Sets a callback that will be triggered when the system is disposed
  32657. */
  32658. onDispose: () => void;
  32659. private _particles;
  32660. private _epsilon;
  32661. private _capacity;
  32662. private _stockParticles;
  32663. private _newPartsExcess;
  32664. private _vertexData;
  32665. private _vertexBuffer;
  32666. private _vertexBuffers;
  32667. private _spriteBuffer;
  32668. private _indexBuffer;
  32669. private _effect;
  32670. private _customEffect;
  32671. private _cachedDefines;
  32672. private _scaledColorStep;
  32673. private _colorDiff;
  32674. private _scaledDirection;
  32675. private _scaledGravity;
  32676. private _currentRenderId;
  32677. private _alive;
  32678. private _useInstancing;
  32679. private _started;
  32680. private _stopped;
  32681. private _actualFrame;
  32682. private _scaledUpdateSpeed;
  32683. private _vertexBufferSize;
  32684. /** @hidden */
  32685. _currentEmitRateGradient: Nullable<FactorGradient>;
  32686. /** @hidden */
  32687. _currentEmitRate1: number;
  32688. /** @hidden */
  32689. _currentEmitRate2: number;
  32690. /** @hidden */
  32691. _currentStartSizeGradient: Nullable<FactorGradient>;
  32692. /** @hidden */
  32693. _currentStartSize1: number;
  32694. /** @hidden */
  32695. _currentStartSize2: number;
  32696. private readonly _rawTextureWidth;
  32697. private _rampGradientsTexture;
  32698. private _useRampGradients;
  32699. /** Gets or sets a boolean indicating that ramp gradients must be used
  32700. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  32701. */
  32702. useRampGradients: boolean;
  32703. /**
  32704. * 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.
  32705. * 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: [])
  32706. */
  32707. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  32708. private _subEmitters;
  32709. /**
  32710. * @hidden
  32711. * If the particle systems emitter should be disposed when the particle system is disposed
  32712. */
  32713. _disposeEmitterOnDispose: boolean;
  32714. /**
  32715. * The current active Sub-systems, this property is used by the root particle system only.
  32716. */
  32717. activeSubSystems: Array<ParticleSystem>;
  32718. private _rootParticleSystem;
  32719. /**
  32720. * Gets the current list of active particles
  32721. */
  32722. readonly particles: Particle[];
  32723. /**
  32724. * Returns the string "ParticleSystem"
  32725. * @returns a string containing the class name
  32726. */
  32727. getClassName(): string;
  32728. /**
  32729. * Instantiates a particle system.
  32730. * 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.
  32731. * @param name The name of the particle system
  32732. * @param capacity The max number of particles alive at the same time
  32733. * @param scene The scene the particle system belongs to
  32734. * @param customEffect a custom effect used to change the way particles are rendered by default
  32735. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  32736. * @param epsilon Offset used to render the particles
  32737. */
  32738. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  32739. private _addFactorGradient;
  32740. private _removeFactorGradient;
  32741. /**
  32742. * Adds a new life time gradient
  32743. * @param gradient defines the gradient to use (between 0 and 1)
  32744. * @param factor defines the life time factor to affect to the specified gradient
  32745. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32746. * @returns the current particle system
  32747. */
  32748. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32749. /**
  32750. * Remove a specific life time gradient
  32751. * @param gradient defines the gradient to remove
  32752. * @returns the current particle system
  32753. */
  32754. removeLifeTimeGradient(gradient: number): IParticleSystem;
  32755. /**
  32756. * Adds a new size gradient
  32757. * @param gradient defines the gradient to use (between 0 and 1)
  32758. * @param factor defines the size factor to affect to the specified gradient
  32759. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32760. * @returns the current particle system
  32761. */
  32762. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32763. /**
  32764. * Remove a specific size gradient
  32765. * @param gradient defines the gradient to remove
  32766. * @returns the current particle system
  32767. */
  32768. removeSizeGradient(gradient: number): IParticleSystem;
  32769. /**
  32770. * Adds a new color remap gradient
  32771. * @param gradient defines the gradient to use (between 0 and 1)
  32772. * @param min defines the color remap minimal range
  32773. * @param max defines the color remap maximal range
  32774. * @returns the current particle system
  32775. */
  32776. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  32777. /**
  32778. * Remove a specific color remap gradient
  32779. * @param gradient defines the gradient to remove
  32780. * @returns the current particle system
  32781. */
  32782. removeColorRemapGradient(gradient: number): IParticleSystem;
  32783. /**
  32784. * Adds a new alpha remap gradient
  32785. * @param gradient defines the gradient to use (between 0 and 1)
  32786. * @param min defines the alpha remap minimal range
  32787. * @param max defines the alpha remap maximal range
  32788. * @returns the current particle system
  32789. */
  32790. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  32791. /**
  32792. * Remove a specific alpha remap gradient
  32793. * @param gradient defines the gradient to remove
  32794. * @returns the current particle system
  32795. */
  32796. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  32797. /**
  32798. * Adds a new angular speed gradient
  32799. * @param gradient defines the gradient to use (between 0 and 1)
  32800. * @param factor defines the angular speed to affect to the specified gradient
  32801. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32802. * @returns the current particle system
  32803. */
  32804. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32805. /**
  32806. * Remove a specific angular speed gradient
  32807. * @param gradient defines the gradient to remove
  32808. * @returns the current particle system
  32809. */
  32810. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  32811. /**
  32812. * Adds a new velocity gradient
  32813. * @param gradient defines the gradient to use (between 0 and 1)
  32814. * @param factor defines the velocity to affect to the specified gradient
  32815. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32816. * @returns the current particle system
  32817. */
  32818. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32819. /**
  32820. * Remove a specific velocity gradient
  32821. * @param gradient defines the gradient to remove
  32822. * @returns the current particle system
  32823. */
  32824. removeVelocityGradient(gradient: number): IParticleSystem;
  32825. /**
  32826. * Adds a new limit velocity gradient
  32827. * @param gradient defines the gradient to use (between 0 and 1)
  32828. * @param factor defines the limit velocity value to affect to the specified gradient
  32829. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32830. * @returns the current particle system
  32831. */
  32832. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32833. /**
  32834. * Remove a specific limit velocity gradient
  32835. * @param gradient defines the gradient to remove
  32836. * @returns the current particle system
  32837. */
  32838. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  32839. /**
  32840. * Adds a new drag gradient
  32841. * @param gradient defines the gradient to use (between 0 and 1)
  32842. * @param factor defines the drag value to affect to the specified gradient
  32843. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32844. * @returns the current particle system
  32845. */
  32846. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32847. /**
  32848. * Remove a specific drag gradient
  32849. * @param gradient defines the gradient to remove
  32850. * @returns the current particle system
  32851. */
  32852. removeDragGradient(gradient: number): IParticleSystem;
  32853. /**
  32854. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  32855. * @param gradient defines the gradient to use (between 0 and 1)
  32856. * @param factor defines the emit rate value to affect to the specified gradient
  32857. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32858. * @returns the current particle system
  32859. */
  32860. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32861. /**
  32862. * Remove a specific emit rate gradient
  32863. * @param gradient defines the gradient to remove
  32864. * @returns the current particle system
  32865. */
  32866. removeEmitRateGradient(gradient: number): IParticleSystem;
  32867. /**
  32868. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  32869. * @param gradient defines the gradient to use (between 0 and 1)
  32870. * @param factor defines the start size value to affect to the specified gradient
  32871. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32872. * @returns the current particle system
  32873. */
  32874. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32875. /**
  32876. * Remove a specific start size gradient
  32877. * @param gradient defines the gradient to remove
  32878. * @returns the current particle system
  32879. */
  32880. removeStartSizeGradient(gradient: number): IParticleSystem;
  32881. private _createRampGradientTexture;
  32882. /**
  32883. * Gets the current list of ramp gradients.
  32884. * You must use addRampGradient and removeRampGradient to udpate this list
  32885. * @returns the list of ramp gradients
  32886. */
  32887. getRampGradients(): Nullable<Array<Color3Gradient>>;
  32888. /**
  32889. * Adds a new ramp gradient used to remap particle colors
  32890. * @param gradient defines the gradient to use (between 0 and 1)
  32891. * @param color defines the color to affect to the specified gradient
  32892. * @returns the current particle system
  32893. */
  32894. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  32895. /**
  32896. * Remove a specific ramp gradient
  32897. * @param gradient defines the gradient to remove
  32898. * @returns the current particle system
  32899. */
  32900. removeRampGradient(gradient: number): ParticleSystem;
  32901. /**
  32902. * Adds a new color gradient
  32903. * @param gradient defines the gradient to use (between 0 and 1)
  32904. * @param color1 defines the color to affect to the specified gradient
  32905. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  32906. * @returns this particle system
  32907. */
  32908. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  32909. /**
  32910. * Remove a specific color gradient
  32911. * @param gradient defines the gradient to remove
  32912. * @returns this particle system
  32913. */
  32914. removeColorGradient(gradient: number): IParticleSystem;
  32915. private _fetchR;
  32916. protected _reset(): void;
  32917. private _resetEffect;
  32918. private _createVertexBuffers;
  32919. private _createIndexBuffer;
  32920. /**
  32921. * Gets the maximum number of particles active at the same time.
  32922. * @returns The max number of active particles.
  32923. */
  32924. getCapacity(): number;
  32925. /**
  32926. * Gets whether there are still active particles in the system.
  32927. * @returns True if it is alive, otherwise false.
  32928. */
  32929. isAlive(): boolean;
  32930. /**
  32931. * Gets if the system has been started. (Note: this will still be true after stop is called)
  32932. * @returns True if it has been started, otherwise false.
  32933. */
  32934. isStarted(): boolean;
  32935. private _prepareSubEmitterInternalArray;
  32936. /**
  32937. * Starts the particle system and begins to emit
  32938. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  32939. */
  32940. start(delay?: number): void;
  32941. /**
  32942. * Stops the particle system.
  32943. * @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.
  32944. */
  32945. stop(stopSubEmitters?: boolean): void;
  32946. /**
  32947. * Remove all active particles
  32948. */
  32949. reset(): void;
  32950. /**
  32951. * @hidden (for internal use only)
  32952. */
  32953. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  32954. /**
  32955. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  32956. * Its lifetime will start back at 0.
  32957. */
  32958. recycleParticle: (particle: Particle) => void;
  32959. private _stopSubEmitters;
  32960. private _createParticle;
  32961. private _removeFromRoot;
  32962. private _emitFromParticle;
  32963. private _update;
  32964. /** @hidden */
  32965. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  32966. /** @hidden */
  32967. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  32968. /** @hidden */
  32969. private _getEffect;
  32970. /**
  32971. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  32972. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  32973. */
  32974. animate(preWarmOnly?: boolean): void;
  32975. private _appendParticleVertices;
  32976. /**
  32977. * Rebuilds the particle system.
  32978. */
  32979. rebuild(): void;
  32980. /**
  32981. * Is this system ready to be used/rendered
  32982. * @return true if the system is ready
  32983. */
  32984. isReady(): boolean;
  32985. private _render;
  32986. /**
  32987. * Renders the particle system in its current state.
  32988. * @returns the current number of particles
  32989. */
  32990. render(): number;
  32991. /**
  32992. * Disposes the particle system and free the associated resources
  32993. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  32994. */
  32995. dispose(disposeTexture?: boolean): void;
  32996. /**
  32997. * Clones the particle system.
  32998. * @param name The name of the cloned object
  32999. * @param newEmitter The new emitter to use
  33000. * @returns the cloned particle system
  33001. */
  33002. clone(name: string, newEmitter: any): ParticleSystem;
  33003. /**
  33004. * Serializes the particle system to a JSON object.
  33005. * @returns the JSON object
  33006. */
  33007. serialize(): any;
  33008. /** @hidden */
  33009. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  33010. /** @hidden */
  33011. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  33012. /**
  33013. * Parses a JSON object to create a particle system.
  33014. * @param parsedParticleSystem The JSON object to parse
  33015. * @param scene The scene to create the particle system in
  33016. * @param rootUrl The root url to use to load external dependencies like texture
  33017. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  33018. * @returns the Parsed particle system
  33019. */
  33020. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  33021. }
  33022. }
  33023. declare module BABYLON {
  33024. interface Engine {
  33025. /**
  33026. * Create an effect to use with particle systems.
  33027. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  33028. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  33029. * @param uniformsNames defines a list of attribute names
  33030. * @param samplers defines an array of string used to represent textures
  33031. * @param defines defines the string containing the defines to use to compile the shaders
  33032. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  33033. * @param onCompiled defines a function to call when the effect creation is successful
  33034. * @param onError defines a function to call when the effect creation has failed
  33035. * @returns the new Effect
  33036. */
  33037. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  33038. }
  33039. interface Mesh {
  33040. /**
  33041. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  33042. * @returns an array of IParticleSystem
  33043. */
  33044. getEmittedParticleSystems(): IParticleSystem[];
  33045. /**
  33046. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  33047. * @returns an array of IParticleSystem
  33048. */
  33049. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  33050. }
  33051. }
  33052. declare module BABYLON {
  33053. /**
  33054. * Represents a set of particle systems working together to create a specific effect
  33055. */
  33056. class ParticleSystemSet implements IDisposable {
  33057. private _emitterCreationOptions;
  33058. private _emitterNode;
  33059. /**
  33060. * Gets the particle system list
  33061. */
  33062. systems: IParticleSystem[];
  33063. /**
  33064. * Gets the emitter node used with this set
  33065. */
  33066. readonly emitterNode: Nullable<TransformNode>;
  33067. /**
  33068. * Creates a new emitter mesh as a sphere
  33069. * @param options defines the options used to create the sphere
  33070. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  33071. * @param scene defines the hosting scene
  33072. */
  33073. setEmitterAsSphere(options: {
  33074. diameter: number;
  33075. segments: number;
  33076. color: Color3;
  33077. }, renderingGroupId: number, scene: Scene): void;
  33078. /**
  33079. * Starts all particle systems of the set
  33080. * @param emitter defines an optional mesh to use as emitter for the particle systems
  33081. */
  33082. start(emitter?: AbstractMesh): void;
  33083. /**
  33084. * Release all associated resources
  33085. */
  33086. dispose(): void;
  33087. /**
  33088. * Serialize the set into a JSON compatible object
  33089. * @returns a JSON compatible representation of the set
  33090. */
  33091. serialize(): any;
  33092. /**
  33093. * Parse a new ParticleSystemSet from a serialized source
  33094. * @param data defines a JSON compatible representation of the set
  33095. * @param scene defines the hosting scene
  33096. * @param gpu defines if we want GPU particles or CPU particles
  33097. * @returns a new ParticleSystemSet
  33098. */
  33099. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  33100. }
  33101. }
  33102. declare module BABYLON {
  33103. /**
  33104. * Represents one particle of a solid particle system.
  33105. */
  33106. class SolidParticle {
  33107. /**
  33108. * particle global index
  33109. */
  33110. idx: number;
  33111. /**
  33112. * The color of the particle
  33113. */
  33114. color: Nullable<Color4>;
  33115. /**
  33116. * The world space position of the particle.
  33117. */
  33118. position: Vector3;
  33119. /**
  33120. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  33121. */
  33122. rotation: Vector3;
  33123. /**
  33124. * The world space rotation quaternion of the particle.
  33125. */
  33126. rotationQuaternion: Nullable<Quaternion>;
  33127. /**
  33128. * The scaling of the particle.
  33129. */
  33130. scaling: Vector3;
  33131. /**
  33132. * The uvs of the particle.
  33133. */
  33134. uvs: Vector4;
  33135. /**
  33136. * The current speed of the particle.
  33137. */
  33138. velocity: Vector3;
  33139. /**
  33140. * The pivot point in the particle local space.
  33141. */
  33142. pivot: Vector3;
  33143. /**
  33144. * Must the particle be translated from its pivot point in its local space ?
  33145. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  33146. * Default : false
  33147. */
  33148. translateFromPivot: boolean;
  33149. /**
  33150. * Is the particle active or not ?
  33151. */
  33152. alive: boolean;
  33153. /**
  33154. * Is the particle visible or not ?
  33155. */
  33156. isVisible: boolean;
  33157. /**
  33158. * Index of this particle in the global "positions" array (Internal use)
  33159. * @hidden
  33160. */
  33161. _pos: number;
  33162. /**
  33163. * @hidden Index of this particle in the global "indices" array (Internal use)
  33164. */
  33165. _ind: number;
  33166. /**
  33167. * @hidden ModelShape of this particle (Internal use)
  33168. */
  33169. _model: ModelShape;
  33170. /**
  33171. * ModelShape id of this particle
  33172. */
  33173. shapeId: number;
  33174. /**
  33175. * Index of the particle in its shape id (Internal use)
  33176. */
  33177. idxInShape: number;
  33178. /**
  33179. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  33180. */
  33181. _modelBoundingInfo: BoundingInfo;
  33182. /**
  33183. * @hidden Particle BoundingInfo object (Internal use)
  33184. */
  33185. _boundingInfo: BoundingInfo;
  33186. /**
  33187. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  33188. */
  33189. _sps: SolidParticleSystem;
  33190. /**
  33191. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  33192. */
  33193. _stillInvisible: boolean;
  33194. /**
  33195. * @hidden Last computed particle rotation matrix
  33196. */
  33197. _rotationMatrix: number[];
  33198. /**
  33199. * Parent particle Id, if any.
  33200. * Default null.
  33201. */
  33202. parentId: Nullable<number>;
  33203. /**
  33204. * @hidden Internal global position in the SPS.
  33205. */
  33206. _globalPosition: Vector3;
  33207. /**
  33208. * Creates a Solid Particle object.
  33209. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  33210. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  33211. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  33212. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  33213. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  33214. * @param shapeId (integer) is the model shape identifier in the SPS.
  33215. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  33216. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  33217. */
  33218. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  33219. /**
  33220. * Legacy support, changed scale to scaling
  33221. */
  33222. /**
  33223. * Legacy support, changed scale to scaling
  33224. */
  33225. scale: Vector3;
  33226. /**
  33227. * Legacy support, changed quaternion to rotationQuaternion
  33228. */
  33229. /**
  33230. * Legacy support, changed quaternion to rotationQuaternion
  33231. */
  33232. quaternion: Nullable<Quaternion>;
  33233. /**
  33234. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  33235. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  33236. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  33237. * @returns true if it intersects
  33238. */
  33239. intersectsMesh(target: Mesh | SolidParticle): boolean;
  33240. /**
  33241. * get the rotation matrix of the particle
  33242. * @hidden
  33243. */
  33244. getRotationMatrix(m: Matrix): void;
  33245. }
  33246. /**
  33247. * Represents the shape of the model used by one particle of a solid particle system.
  33248. * SPS internal tool, don't use it manually.
  33249. */
  33250. class ModelShape {
  33251. /**
  33252. * The shape id
  33253. * @hidden
  33254. */
  33255. shapeID: number;
  33256. /**
  33257. * flat array of model positions (internal use)
  33258. * @hidden
  33259. */
  33260. _shape: Vector3[];
  33261. /**
  33262. * flat array of model UVs (internal use)
  33263. * @hidden
  33264. */
  33265. _shapeUV: number[];
  33266. /**
  33267. * length of the shape in the model indices array (internal use)
  33268. * @hidden
  33269. */
  33270. _indicesLength: number;
  33271. /**
  33272. * Custom position function (internal use)
  33273. * @hidden
  33274. */
  33275. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  33276. /**
  33277. * Custom vertex function (internal use)
  33278. * @hidden
  33279. */
  33280. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  33281. /**
  33282. * 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.
  33283. * SPS internal tool, don't use it manually.
  33284. * @hidden
  33285. */
  33286. 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>);
  33287. }
  33288. /**
  33289. * Represents a Depth Sorted Particle in the solid particle system.
  33290. */
  33291. class DepthSortedParticle {
  33292. /**
  33293. * Index of the particle in the "indices" array
  33294. */
  33295. ind: number;
  33296. /**
  33297. * Length of the particle shape in the "indices" array
  33298. */
  33299. indicesLength: number;
  33300. /**
  33301. * Squared distance from the particle to the camera
  33302. */
  33303. sqDistance: number;
  33304. }
  33305. }
  33306. declare module BABYLON {
  33307. /**
  33308. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  33309. *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.
  33310. * The SPS is also a particle system. It provides some methods to manage the particles.
  33311. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  33312. *
  33313. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  33314. */
  33315. class SolidParticleSystem implements IDisposable {
  33316. /**
  33317. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  33318. * Example : var p = SPS.particles[i];
  33319. */
  33320. particles: SolidParticle[];
  33321. /**
  33322. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  33323. */
  33324. nbParticles: number;
  33325. /**
  33326. * If the particles must ever face the camera (default false). Useful for planar particles.
  33327. */
  33328. billboard: boolean;
  33329. /**
  33330. * Recompute normals when adding a shape
  33331. */
  33332. recomputeNormals: boolean;
  33333. /**
  33334. * This a counter ofr your own usage. It's not set by any SPS functions.
  33335. */
  33336. counter: number;
  33337. /**
  33338. * The SPS name. This name is also given to the underlying mesh.
  33339. */
  33340. name: string;
  33341. /**
  33342. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  33343. */
  33344. mesh: Mesh;
  33345. /**
  33346. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  33347. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  33348. */
  33349. vars: any;
  33350. /**
  33351. * This array is populated when the SPS is set as 'pickable'.
  33352. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  33353. * Each element of this array is an object `{idx: int, faceId: int}`.
  33354. * `idx` is the picked particle index in the `SPS.particles` array
  33355. * `faceId` is the picked face index counted within this particle.
  33356. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  33357. */
  33358. pickedParticles: {
  33359. idx: number;
  33360. faceId: number;
  33361. }[];
  33362. /**
  33363. * This array is populated when `enableDepthSort` is set to true.
  33364. * Each element of this array is an instance of the class DepthSortedParticle.
  33365. */
  33366. depthSortedParticles: DepthSortedParticle[];
  33367. /**
  33368. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  33369. * @hidden
  33370. */
  33371. _bSphereOnly: boolean;
  33372. /**
  33373. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  33374. * @hidden
  33375. */
  33376. _bSphereRadiusFactor: number;
  33377. private _scene;
  33378. private _positions;
  33379. private _indices;
  33380. private _normals;
  33381. private _colors;
  33382. private _uvs;
  33383. private _indices32;
  33384. private _positions32;
  33385. private _normals32;
  33386. private _fixedNormal32;
  33387. private _colors32;
  33388. private _uvs32;
  33389. private _index;
  33390. private _updatable;
  33391. private _pickable;
  33392. private _isVisibilityBoxLocked;
  33393. private _alwaysVisible;
  33394. private _depthSort;
  33395. private _shapeCounter;
  33396. private _copy;
  33397. private _color;
  33398. private _computeParticleColor;
  33399. private _computeParticleTexture;
  33400. private _computeParticleRotation;
  33401. private _computeParticleVertex;
  33402. private _computeBoundingBox;
  33403. private _depthSortParticles;
  33404. private _camera;
  33405. private _mustUnrotateFixedNormals;
  33406. private _particlesIntersect;
  33407. private _needs32Bits;
  33408. /**
  33409. * Creates a SPS (Solid Particle System) object.
  33410. * @param name (String) is the SPS name, this will be the underlying mesh name.
  33411. * @param scene (Scene) is the scene in which the SPS is added.
  33412. * @param updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  33413. * @param isPickable (optional boolean, default false) : if the solid particles must be pickable.
  33414. * @param enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  33415. * @param particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  33416. * @param boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  33417. * @param bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  33418. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  33419. */
  33420. constructor(name: string, scene: Scene, options?: {
  33421. updatable?: boolean;
  33422. isPickable?: boolean;
  33423. enableDepthSort?: boolean;
  33424. particleIntersection?: boolean;
  33425. boundingSphereOnly?: boolean;
  33426. bSphereRadiusFactor?: number;
  33427. });
  33428. /**
  33429. * Builds the SPS underlying mesh. Returns a standard Mesh.
  33430. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  33431. * @returns the created mesh
  33432. */
  33433. buildMesh(): Mesh;
  33434. /**
  33435. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  33436. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  33437. * Thus the particles generated from `digest()` have their property `position` set yet.
  33438. * @param mesh ( Mesh ) is the mesh to be digested
  33439. * @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
  33440. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  33441. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  33442. * @returns the current SPS
  33443. */
  33444. digest(mesh: Mesh, options?: {
  33445. facetNb?: number;
  33446. number?: number;
  33447. delta?: number;
  33448. }): SolidParticleSystem;
  33449. private _unrotateFixedNormals;
  33450. private _resetCopy;
  33451. private _meshBuilder;
  33452. private _posToShape;
  33453. private _uvsToShapeUV;
  33454. private _addParticle;
  33455. /**
  33456. * Adds some particles to the SPS from the model shape. Returns the shape id.
  33457. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  33458. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  33459. * @param nb (positive integer) the number of particles to be created from this model
  33460. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  33461. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  33462. * @returns the number of shapes in the system
  33463. */
  33464. addShape(mesh: Mesh, nb: number, options?: {
  33465. positionFunction?: any;
  33466. vertexFunction?: any;
  33467. }): number;
  33468. private _rebuildParticle;
  33469. /**
  33470. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  33471. * @returns the SPS.
  33472. */
  33473. rebuildMesh(): SolidParticleSystem;
  33474. /**
  33475. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  33476. * This method calls `updateParticle()` for each particle of the SPS.
  33477. * For an animated SPS, it is usually called within the render loop.
  33478. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  33479. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  33480. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  33481. * @returns the SPS.
  33482. */
  33483. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  33484. /**
  33485. * Disposes the SPS.
  33486. */
  33487. dispose(): void;
  33488. /**
  33489. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  33490. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  33491. * @returns the SPS.
  33492. */
  33493. refreshVisibleSize(): SolidParticleSystem;
  33494. /**
  33495. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  33496. * @param size the size (float) of the visibility box
  33497. * note : this doesn't lock the SPS mesh bounding box.
  33498. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  33499. */
  33500. setVisibilityBox(size: number): void;
  33501. /**
  33502. * Gets whether the SPS as always visible or not
  33503. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  33504. */
  33505. /**
  33506. * Sets the SPS as always visible or not
  33507. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  33508. */
  33509. isAlwaysVisible: boolean;
  33510. /**
  33511. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  33512. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  33513. */
  33514. /**
  33515. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  33516. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  33517. */
  33518. isVisibilityBoxLocked: boolean;
  33519. /**
  33520. * Tells to `setParticles()` to compute the particle rotations or not.
  33521. * Default value : true. The SPS is faster when it's set to false.
  33522. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  33523. */
  33524. /**
  33525. * Gets if `setParticles()` computes the particle rotations or not.
  33526. * Default value : true. The SPS is faster when it's set to false.
  33527. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  33528. */
  33529. computeParticleRotation: boolean;
  33530. /**
  33531. * Tells to `setParticles()` to compute the particle colors or not.
  33532. * Default value : true. The SPS is faster when it's set to false.
  33533. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  33534. */
  33535. /**
  33536. * Gets if `setParticles()` computes the particle colors or not.
  33537. * Default value : true. The SPS is faster when it's set to false.
  33538. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  33539. */
  33540. computeParticleColor: boolean;
  33541. /**
  33542. * Gets if `setParticles()` computes the particle textures or not.
  33543. * Default value : true. The SPS is faster when it's set to false.
  33544. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  33545. */
  33546. computeParticleTexture: boolean;
  33547. /**
  33548. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  33549. * Default value : false. The SPS is faster when it's set to false.
  33550. * Note : the particle custom vertex positions aren't stored values.
  33551. */
  33552. /**
  33553. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  33554. * Default value : false. The SPS is faster when it's set to false.
  33555. * Note : the particle custom vertex positions aren't stored values.
  33556. */
  33557. computeParticleVertex: boolean;
  33558. /**
  33559. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  33560. */
  33561. /**
  33562. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  33563. */
  33564. computeBoundingBox: boolean;
  33565. /**
  33566. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  33567. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  33568. * Default : `true`
  33569. */
  33570. /**
  33571. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  33572. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  33573. * Default : `true`
  33574. */
  33575. depthSortParticles: boolean;
  33576. /**
  33577. * This function does nothing. It may be overwritten to set all the particle first values.
  33578. * The SPS doesn't call this function, you may have to call it by your own.
  33579. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  33580. */
  33581. initParticles(): void;
  33582. /**
  33583. * This function does nothing. It may be overwritten to recycle a particle.
  33584. * The SPS doesn't call this function, you may have to call it by your own.
  33585. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  33586. * @param particle The particle to recycle
  33587. * @returns the recycled particle
  33588. */
  33589. recycleParticle(particle: SolidParticle): SolidParticle;
  33590. /**
  33591. * Updates a particle : this function should be overwritten by the user.
  33592. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  33593. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  33594. * @example : just set a particle position or velocity and recycle conditions
  33595. * @param particle The particle to update
  33596. * @returns the updated particle
  33597. */
  33598. updateParticle(particle: SolidParticle): SolidParticle;
  33599. /**
  33600. * Updates a vertex of a particle : it can be overwritten by the user.
  33601. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  33602. * @param particle the current particle
  33603. * @param vertex the current index of the current particle
  33604. * @param pt the index of the current vertex in the particle shape
  33605. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  33606. * @example : just set a vertex particle position
  33607. * @returns the updated vertex
  33608. */
  33609. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  33610. /**
  33611. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  33612. * This does nothing and may be overwritten by the user.
  33613. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  33614. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  33615. * @param update the boolean update value actually passed to setParticles()
  33616. */
  33617. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  33618. /**
  33619. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  33620. * This will be passed three parameters.
  33621. * This does nothing and may be overwritten by the user.
  33622. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  33623. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  33624. * @param update the boolean update value actually passed to setParticles()
  33625. */
  33626. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  33627. }
  33628. }
  33629. declare module BABYLON {
  33630. /**
  33631. * Type of sub emitter
  33632. */
  33633. enum SubEmitterType {
  33634. /**
  33635. * Attached to the particle over it's lifetime
  33636. */
  33637. ATTACHED = 0,
  33638. /**
  33639. * Created when the particle dies
  33640. */
  33641. END = 1
  33642. }
  33643. /**
  33644. * Sub emitter class used to emit particles from an existing particle
  33645. */
  33646. class SubEmitter {
  33647. /**
  33648. * the particle system to be used by the sub emitter
  33649. */
  33650. particleSystem: ParticleSystem;
  33651. /**
  33652. * Type of the submitter (Default: END)
  33653. */
  33654. type: SubEmitterType;
  33655. /**
  33656. * 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)
  33657. * Note: This only is supported when using an emitter of type Mesh
  33658. */
  33659. inheritDirection: boolean;
  33660. /**
  33661. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  33662. */
  33663. inheritedVelocityAmount: number;
  33664. /**
  33665. * Creates a sub emitter
  33666. * @param particleSystem the particle system to be used by the sub emitter
  33667. */
  33668. constructor(
  33669. /**
  33670. * the particle system to be used by the sub emitter
  33671. */
  33672. particleSystem: ParticleSystem);
  33673. /**
  33674. * Clones the sub emitter
  33675. * @returns the cloned sub emitter
  33676. */
  33677. clone(): SubEmitter;
  33678. /**
  33679. * Serialize current object to a JSON object
  33680. * @returns the serialized object
  33681. */
  33682. serialize(): any;
  33683. /**
  33684. * Creates a new SubEmitter from a serialized JSON version
  33685. * @param serializationObject defines the JSON object to read from
  33686. * @param scene defines the hosting scene
  33687. * @param rootUrl defines the rootUrl for data loading
  33688. * @returns a new SubEmitter
  33689. */
  33690. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  33691. /** Release associated resources */
  33692. dispose(): void;
  33693. }
  33694. }
  33695. declare module BABYLON {
  33696. interface Scene {
  33697. /**
  33698. * The list of reflection probes added to the scene
  33699. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  33700. */
  33701. reflectionProbes: Array<ReflectionProbe>;
  33702. }
  33703. /**
  33704. * Class used to generate realtime reflection / refraction cube textures
  33705. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  33706. */
  33707. class ReflectionProbe {
  33708. /** defines the name of the probe */
  33709. name: string;
  33710. private _scene;
  33711. private _renderTargetTexture;
  33712. private _projectionMatrix;
  33713. private _viewMatrix;
  33714. private _target;
  33715. private _add;
  33716. private _attachedMesh;
  33717. private _invertYAxis;
  33718. /** Gets or sets probe position (center of the cube map) */
  33719. position: Vector3;
  33720. /**
  33721. * Creates a new reflection probe
  33722. * @param name defines the name of the probe
  33723. * @param size defines the texture resolution (for each face)
  33724. * @param scene defines the hosting scene
  33725. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  33726. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  33727. */
  33728. constructor(
  33729. /** defines the name of the probe */
  33730. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  33731. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  33732. samples: number;
  33733. /** Gets or sets the refresh rate to use (on every frame by default) */
  33734. refreshRate: number;
  33735. /**
  33736. * Gets the hosting scene
  33737. * @returns a Scene
  33738. */
  33739. getScene(): Scene;
  33740. /** Gets the internal CubeTexture used to render to */
  33741. readonly cubeTexture: RenderTargetTexture;
  33742. /** Gets the list of meshes to render */
  33743. readonly renderList: Nullable<AbstractMesh[]>;
  33744. /**
  33745. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  33746. * @param mesh defines the mesh to attach to
  33747. */
  33748. attachToMesh(mesh: AbstractMesh): void;
  33749. /**
  33750. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  33751. * @param renderingGroupId The rendering group id corresponding to its index
  33752. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  33753. */
  33754. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  33755. /**
  33756. * Clean all associated resources
  33757. */
  33758. dispose(): void;
  33759. }
  33760. }
  33761. declare module BABYLON {
  33762. /**
  33763. * Postprocess used to generate anaglyphic rendering
  33764. */
  33765. class AnaglyphPostProcess extends PostProcess {
  33766. private _passedProcess;
  33767. /**
  33768. * Creates a new AnaglyphPostProcess
  33769. * @param name defines postprocess name
  33770. * @param options defines creation options or target ratio scale
  33771. * @param rigCameras defines cameras using this postprocess
  33772. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  33773. * @param engine defines hosting engine
  33774. * @param reusable defines if the postprocess will be reused multiple times per frame
  33775. */
  33776. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  33777. }
  33778. }
  33779. declare module BABYLON {
  33780. /**
  33781. * Post process used to render in black and white
  33782. */
  33783. class BlackAndWhitePostProcess extends PostProcess {
  33784. /**
  33785. * Linear about to convert he result to black and white (default: 1)
  33786. */
  33787. degree: number;
  33788. /**
  33789. * Creates a black and white post process
  33790. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  33791. * @param name The name of the effect.
  33792. * @param options The required width/height ratio to downsize to before computing the render pass.
  33793. * @param camera The camera to apply the render pass to.
  33794. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  33795. * @param engine The engine which the post process will be applied. (default: current engine)
  33796. * @param reusable If the post process can be reused on the same frame. (default: false)
  33797. */
  33798. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  33799. }
  33800. }
  33801. declare module BABYLON {
  33802. /**
  33803. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  33804. */
  33805. class BloomEffect extends PostProcessRenderEffect {
  33806. private bloomScale;
  33807. /**
  33808. * @hidden Internal
  33809. */
  33810. _effects: Array<PostProcess>;
  33811. /**
  33812. * @hidden Internal
  33813. */
  33814. _downscale: ExtractHighlightsPostProcess;
  33815. private _blurX;
  33816. private _blurY;
  33817. private _merge;
  33818. /**
  33819. * The luminance threshold to find bright areas of the image to bloom.
  33820. */
  33821. threshold: number;
  33822. /**
  33823. * The strength of the bloom.
  33824. */
  33825. weight: number;
  33826. /**
  33827. * Specifies the size of the bloom blur kernel, relative to the final output size
  33828. */
  33829. kernel: number;
  33830. /**
  33831. * Creates a new instance of @see BloomEffect
  33832. * @param scene The scene the effect belongs to.
  33833. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  33834. * @param bloomKernel The size of the kernel to be used when applying the blur.
  33835. * @param bloomWeight The the strength of bloom.
  33836. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  33837. * @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)
  33838. */
  33839. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  33840. /**
  33841. * Disposes each of the internal effects for a given camera.
  33842. * @param camera The camera to dispose the effect on.
  33843. */
  33844. disposeEffects(camera: Camera): void;
  33845. /**
  33846. * @hidden Internal
  33847. */
  33848. _updateEffects(): void;
  33849. /**
  33850. * Internal
  33851. * @returns if all the contained post processes are ready.
  33852. * @hidden
  33853. */
  33854. _isReady(): boolean;
  33855. }
  33856. }
  33857. declare module BABYLON {
  33858. /**
  33859. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  33860. */
  33861. class BloomMergePostProcess extends PostProcess {
  33862. /** Weight of the bloom to be added to the original input. */
  33863. weight: number;
  33864. /**
  33865. * Creates a new instance of @see BloomMergePostProcess
  33866. * @param name The name of the effect.
  33867. * @param originalFromInput Post process which's input will be used for the merge.
  33868. * @param blurred Blurred highlights post process which's output will be used.
  33869. * @param weight Weight of the bloom to be added to the original input.
  33870. * @param options The required width/height ratio to downsize to before computing the render pass.
  33871. * @param camera The camera to apply the render pass to.
  33872. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  33873. * @param engine The engine which the post process will be applied. (default: current engine)
  33874. * @param reusable If the post process can be reused on the same frame. (default: false)
  33875. * @param textureType Type of textures used when performing the post process. (default: 0)
  33876. * @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)
  33877. */
  33878. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  33879. /** Weight of the bloom to be added to the original input. */
  33880. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  33881. }
  33882. }
  33883. declare module BABYLON {
  33884. /**
  33885. * The Blur Post Process which blurs an image based on a kernel and direction.
  33886. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  33887. */
  33888. class BlurPostProcess extends PostProcess {
  33889. /** The direction in which to blur the image. */
  33890. direction: Vector2;
  33891. private blockCompilation;
  33892. protected _kernel: number;
  33893. protected _idealKernel: number;
  33894. protected _packedFloat: boolean;
  33895. private _staticDefines;
  33896. /**
  33897. * Sets the length in pixels of the blur sample region
  33898. */
  33899. /**
  33900. * Gets the length in pixels of the blur sample region
  33901. */
  33902. kernel: number;
  33903. /**
  33904. * Sets wether or not the blur needs to unpack/repack floats
  33905. */
  33906. /**
  33907. * Gets wether or not the blur is unpacking/repacking floats
  33908. */
  33909. packedFloat: boolean;
  33910. /**
  33911. * Creates a new instance BlurPostProcess
  33912. * @param name The name of the effect.
  33913. * @param direction The direction in which to blur the image.
  33914. * @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.
  33915. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  33916. * @param camera The camera to apply the render pass to.
  33917. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  33918. * @param engine The engine which the post process will be applied. (default: current engine)
  33919. * @param reusable If the post process can be reused on the same frame. (default: false)
  33920. * @param textureType Type of textures used when performing the post process. (default: 0)
  33921. * @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)
  33922. */
  33923. constructor(name: string,
  33924. /** The direction in which to blur the image. */
  33925. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  33926. /**
  33927. * Updates the effect with the current post process compile time values and recompiles the shader.
  33928. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  33929. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  33930. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  33931. * @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
  33932. * @param onCompiled Called when the shader has been compiled.
  33933. * @param onError Called if there is an error when compiling a shader.
  33934. */
  33935. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  33936. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  33937. /**
  33938. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  33939. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  33940. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  33941. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  33942. * The gaps between physical kernels are compensated for in the weighting of the samples
  33943. * @param idealKernel Ideal blur kernel.
  33944. * @return Nearest best kernel.
  33945. */
  33946. protected _nearestBestKernel(idealKernel: number): number;
  33947. /**
  33948. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  33949. * @param x The point on the Gaussian distribution to sample.
  33950. * @return the value of the Gaussian function at x.
  33951. */
  33952. protected _gaussianWeight(x: number): number;
  33953. /**
  33954. * Generates a string that can be used as a floating point number in GLSL.
  33955. * @param x Value to print.
  33956. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  33957. * @return GLSL float string.
  33958. */
  33959. protected _glslFloat(x: number, decimalFigures?: number): string;
  33960. }
  33961. }
  33962. declare module BABYLON {
  33963. /**
  33964. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  33965. */
  33966. class ChromaticAberrationPostProcess extends PostProcess {
  33967. /**
  33968. * The amount of seperation of rgb channels (default: 30)
  33969. */
  33970. aberrationAmount: number;
  33971. /**
  33972. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  33973. */
  33974. radialIntensity: number;
  33975. /**
  33976. * 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))
  33977. */
  33978. direction: Vector2;
  33979. /**
  33980. * 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))
  33981. */
  33982. centerPosition: Vector2;
  33983. /**
  33984. * Creates a new instance ChromaticAberrationPostProcess
  33985. * @param name The name of the effect.
  33986. * @param screenWidth The width of the screen to apply the effect on.
  33987. * @param screenHeight The height of the screen to apply the effect on.
  33988. * @param options The required width/height ratio to downsize to before computing the render pass.
  33989. * @param camera The camera to apply the render pass to.
  33990. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  33991. * @param engine The engine which the post process will be applied. (default: current engine)
  33992. * @param reusable If the post process can be reused on the same frame. (default: false)
  33993. * @param textureType Type of textures used when performing the post process. (default: 0)
  33994. * @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)
  33995. */
  33996. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  33997. }
  33998. }
  33999. declare module BABYLON {
  34000. /**
  34001. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  34002. */
  34003. class CircleOfConfusionPostProcess extends PostProcess {
  34004. /**
  34005. * 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.
  34006. */
  34007. lensSize: number;
  34008. /**
  34009. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  34010. */
  34011. fStop: number;
  34012. /**
  34013. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  34014. */
  34015. focusDistance: number;
  34016. /**
  34017. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  34018. */
  34019. focalLength: number;
  34020. private _depthTexture;
  34021. /**
  34022. * Creates a new instance CircleOfConfusionPostProcess
  34023. * @param name The name of the effect.
  34024. * @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.
  34025. * @param options The required width/height ratio to downsize to before computing the render pass.
  34026. * @param camera The camera to apply the render pass to.
  34027. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34028. * @param engine The engine which the post process will be applied. (default: current engine)
  34029. * @param reusable If the post process can be reused on the same frame. (default: false)
  34030. * @param textureType Type of textures used when performing the post process. (default: 0)
  34031. * @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)
  34032. */
  34033. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  34034. /**
  34035. * 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.
  34036. */
  34037. depthTexture: RenderTargetTexture;
  34038. }
  34039. }
  34040. declare module BABYLON {
  34041. /**
  34042. *
  34043. * This post-process allows the modification of rendered colors by using
  34044. * a 'look-up table' (LUT). This effect is also called Color Grading.
  34045. *
  34046. * The object needs to be provided an url to a texture containing the color
  34047. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  34048. * Use an image editing software to tweak the LUT to match your needs.
  34049. *
  34050. * For an example of a color LUT, see here:
  34051. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  34052. * For explanations on color grading, see here:
  34053. * @see http://udn.epicgames.com/Three/ColorGrading.html
  34054. *
  34055. */
  34056. class ColorCorrectionPostProcess extends PostProcess {
  34057. private _colorTableTexture;
  34058. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  34059. }
  34060. }
  34061. declare module BABYLON {
  34062. /**
  34063. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  34064. * input texture to perform effects such as edge detection or sharpening
  34065. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  34066. */
  34067. class ConvolutionPostProcess extends PostProcess {
  34068. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  34069. kernel: number[];
  34070. /**
  34071. * Creates a new instance ConvolutionPostProcess
  34072. * @param name The name of the effect.
  34073. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  34074. * @param options The required width/height ratio to downsize to before computing the render pass.
  34075. * @param camera The camera to apply the render pass to.
  34076. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34077. * @param engine The engine which the post process will be applied. (default: current engine)
  34078. * @param reusable If the post process can be reused on the same frame. (default: false)
  34079. * @param textureType Type of textures used when performing the post process. (default: 0)
  34080. */
  34081. constructor(name: string,
  34082. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  34083. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  34084. /**
  34085. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  34086. */
  34087. static EdgeDetect0Kernel: number[];
  34088. /**
  34089. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  34090. */
  34091. static EdgeDetect1Kernel: number[];
  34092. /**
  34093. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  34094. */
  34095. static EdgeDetect2Kernel: number[];
  34096. /**
  34097. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  34098. */
  34099. static SharpenKernel: number[];
  34100. /**
  34101. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  34102. */
  34103. static EmbossKernel: number[];
  34104. /**
  34105. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  34106. */
  34107. static GaussianKernel: number[];
  34108. }
  34109. }
  34110. declare module BABYLON {
  34111. /**
  34112. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  34113. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  34114. * based on samples that have a large difference in distance than the center pixel.
  34115. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  34116. */
  34117. class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  34118. direction: Vector2;
  34119. /**
  34120. * Creates a new instance CircleOfConfusionPostProcess
  34121. * @param name The name of the effect.
  34122. * @param scene The scene the effect belongs to.
  34123. * @param direction The direction the blur should be applied.
  34124. * @param kernel The size of the kernel used to blur.
  34125. * @param options The required width/height ratio to downsize to before computing the render pass.
  34126. * @param camera The camera to apply the render pass to.
  34127. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  34128. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  34129. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34130. * @param engine The engine which the post process will be applied. (default: current engine)
  34131. * @param reusable If the post process can be reused on the same frame. (default: false)
  34132. * @param textureType Type of textures used when performing the post process. (default: 0)
  34133. * @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)
  34134. */
  34135. 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);
  34136. }
  34137. }
  34138. declare module BABYLON {
  34139. /**
  34140. * Specifies the level of max blur that should be applied when using the depth of field effect
  34141. */
  34142. enum DepthOfFieldEffectBlurLevel {
  34143. /**
  34144. * Subtle blur
  34145. */
  34146. Low = 0,
  34147. /**
  34148. * Medium blur
  34149. */
  34150. Medium = 1,
  34151. /**
  34152. * Large blur
  34153. */
  34154. High = 2
  34155. }
  34156. /**
  34157. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  34158. */
  34159. class DepthOfFieldEffect extends PostProcessRenderEffect {
  34160. private _circleOfConfusion;
  34161. /**
  34162. * @hidden Internal, blurs from high to low
  34163. */
  34164. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  34165. private _depthOfFieldBlurY;
  34166. private _dofMerge;
  34167. /**
  34168. * @hidden Internal post processes in depth of field effect
  34169. */
  34170. _effects: Array<PostProcess>;
  34171. /**
  34172. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  34173. */
  34174. focalLength: number;
  34175. /**
  34176. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  34177. */
  34178. fStop: number;
  34179. /**
  34180. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  34181. */
  34182. focusDistance: number;
  34183. /**
  34184. * 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.
  34185. */
  34186. lensSize: number;
  34187. /**
  34188. * Creates a new instance DepthOfFieldEffect
  34189. * @param scene The scene the effect belongs to.
  34190. * @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.
  34191. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  34192. * @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)
  34193. */
  34194. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  34195. /**
  34196. * 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.
  34197. */
  34198. depthTexture: RenderTargetTexture;
  34199. /**
  34200. * Disposes each of the internal effects for a given camera.
  34201. * @param camera The camera to dispose the effect on.
  34202. */
  34203. disposeEffects(camera: Camera): void;
  34204. /**
  34205. * @hidden Internal
  34206. */
  34207. _updateEffects(): void;
  34208. /**
  34209. * Internal
  34210. * @returns if all the contained post processes are ready.
  34211. * @hidden
  34212. */
  34213. _isReady(): boolean;
  34214. }
  34215. }
  34216. declare module BABYLON {
  34217. /**
  34218. * Options to be set when merging outputs from the default pipeline.
  34219. */
  34220. class DepthOfFieldMergePostProcessOptions {
  34221. /**
  34222. * The original image to merge on top of
  34223. */
  34224. originalFromInput: PostProcess;
  34225. /**
  34226. * Parameters to perform the merge of the depth of field effect
  34227. */
  34228. depthOfField?: {
  34229. circleOfConfusion: PostProcess;
  34230. blurSteps: Array<PostProcess>;
  34231. };
  34232. /**
  34233. * Parameters to perform the merge of bloom effect
  34234. */
  34235. bloom?: {
  34236. blurred: PostProcess;
  34237. weight: number;
  34238. };
  34239. }
  34240. /**
  34241. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  34242. */
  34243. class DepthOfFieldMergePostProcess extends PostProcess {
  34244. private blurSteps;
  34245. /**
  34246. * Creates a new instance of DepthOfFieldMergePostProcess
  34247. * @param name The name of the effect.
  34248. * @param originalFromInput Post process which's input will be used for the merge.
  34249. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  34250. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  34251. * @param options The required width/height ratio to downsize to before computing the render pass.
  34252. * @param camera The camera to apply the render pass to.
  34253. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34254. * @param engine The engine which the post process will be applied. (default: current engine)
  34255. * @param reusable If the post process can be reused on the same frame. (default: false)
  34256. * @param textureType Type of textures used when performing the post process. (default: 0)
  34257. * @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)
  34258. */
  34259. 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);
  34260. /**
  34261. * Updates the effect with the current post process compile time values and recompiles the shader.
  34262. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  34263. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  34264. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  34265. * @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
  34266. * @param onCompiled Called when the shader has been compiled.
  34267. * @param onError Called if there is an error when compiling a shader.
  34268. */
  34269. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  34270. }
  34271. }
  34272. declare module BABYLON {
  34273. /**
  34274. * DisplayPassPostProcess which produces an output the same as it's input
  34275. */
  34276. class DisplayPassPostProcess extends PostProcess {
  34277. /**
  34278. * Creates the DisplayPassPostProcess
  34279. * @param name The name of the effect.
  34280. * @param options The required width/height ratio to downsize to before computing the render pass.
  34281. * @param camera The camera to apply the render pass to.
  34282. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34283. * @param engine The engine which the post process will be applied. (default: current engine)
  34284. * @param reusable If the post process can be reused on the same frame. (default: false)
  34285. */
  34286. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  34287. }
  34288. }
  34289. declare module BABYLON {
  34290. /**
  34291. * 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.
  34292. */
  34293. class ExtractHighlightsPostProcess extends PostProcess {
  34294. /**
  34295. * The luminance threshold, pixels below this value will be set to black.
  34296. */
  34297. threshold: number;
  34298. /** @hidden */
  34299. _exposure: number;
  34300. /**
  34301. * Post process which has the input texture to be used when performing highlight extraction
  34302. * @hidden
  34303. */
  34304. _inputPostProcess: Nullable<PostProcess>;
  34305. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  34306. }
  34307. }
  34308. declare module BABYLON {
  34309. /**
  34310. * Applies a kernel filter to the image
  34311. */
  34312. class FilterPostProcess extends PostProcess {
  34313. /** The matrix to be applied to the image */
  34314. kernelMatrix: Matrix;
  34315. /**
  34316. *
  34317. * @param name The name of the effect.
  34318. * @param kernelMatrix The matrix to be applied to the image
  34319. * @param options The required width/height ratio to downsize to before computing the render pass.
  34320. * @param camera The camera to apply the render pass to.
  34321. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34322. * @param engine The engine which the post process will be applied. (default: current engine)
  34323. * @param reusable If the post process can be reused on the same frame. (default: false)
  34324. */
  34325. constructor(name: string,
  34326. /** The matrix to be applied to the image */
  34327. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  34328. }
  34329. }
  34330. declare module BABYLON {
  34331. /**
  34332. * Fxaa post process
  34333. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  34334. */
  34335. class FxaaPostProcess extends PostProcess {
  34336. /** @hidden */
  34337. texelWidth: number;
  34338. /** @hidden */
  34339. texelHeight: number;
  34340. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  34341. private _getDefines;
  34342. }
  34343. }
  34344. declare module BABYLON {
  34345. /**
  34346. * The GrainPostProcess adds noise to the image at mid luminance levels
  34347. */
  34348. class GrainPostProcess extends PostProcess {
  34349. /**
  34350. * The intensity of the grain added (default: 30)
  34351. */
  34352. intensity: number;
  34353. /**
  34354. * If the grain should be randomized on every frame
  34355. */
  34356. animated: boolean;
  34357. /**
  34358. * Creates a new instance of @see GrainPostProcess
  34359. * @param name The name of the effect.
  34360. * @param options The required width/height ratio to downsize to before computing the render pass.
  34361. * @param camera The camera to apply the render pass to.
  34362. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34363. * @param engine The engine which the post process will be applied. (default: current engine)
  34364. * @param reusable If the post process can be reused on the same frame. (default: false)
  34365. * @param textureType Type of textures used when performing the post process. (default: 0)
  34366. * @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)
  34367. */
  34368. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  34369. }
  34370. }
  34371. declare module BABYLON {
  34372. /**
  34373. * Extracts highlights from the image
  34374. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  34375. */
  34376. class HighlightsPostProcess extends PostProcess {
  34377. /**
  34378. * Extracts highlights from the image
  34379. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  34380. * @param name The name of the effect.
  34381. * @param options The required width/height ratio to downsize to before computing the render pass.
  34382. * @param camera The camera to apply the render pass to.
  34383. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34384. * @param engine The engine which the post process will be applied. (default: current engine)
  34385. * @param reusable If the post process can be reused on the same frame. (default: false)
  34386. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  34387. */
  34388. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  34389. }
  34390. }
  34391. declare module BABYLON {
  34392. /**
  34393. * ImageProcessingPostProcess
  34394. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  34395. */
  34396. class ImageProcessingPostProcess extends PostProcess {
  34397. /**
  34398. * Default configuration related to image processing available in the PBR Material.
  34399. */
  34400. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  34401. /**
  34402. * Gets the image processing configuration used either in this material.
  34403. */
  34404. /**
  34405. * Sets the Default image processing configuration used either in the this material.
  34406. *
  34407. * If sets to null, the scene one is in use.
  34408. */
  34409. imageProcessingConfiguration: ImageProcessingConfiguration;
  34410. /**
  34411. * Keep track of the image processing observer to allow dispose and replace.
  34412. */
  34413. private _imageProcessingObserver;
  34414. /**
  34415. * Attaches a new image processing configuration to the PBR Material.
  34416. * @param configuration
  34417. */
  34418. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  34419. /**
  34420. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  34421. */
  34422. /**
  34423. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  34424. */
  34425. colorCurves: Nullable<ColorCurves>;
  34426. /**
  34427. * Gets wether the color curves effect is enabled.
  34428. */
  34429. /**
  34430. * Sets wether the color curves effect is enabled.
  34431. */
  34432. colorCurvesEnabled: boolean;
  34433. /**
  34434. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  34435. */
  34436. /**
  34437. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  34438. */
  34439. colorGradingTexture: Nullable<BaseTexture>;
  34440. /**
  34441. * Gets wether the color grading effect is enabled.
  34442. */
  34443. /**
  34444. * Gets wether the color grading effect is enabled.
  34445. */
  34446. colorGradingEnabled: boolean;
  34447. /**
  34448. * Gets exposure used in the effect.
  34449. */
  34450. /**
  34451. * Sets exposure used in the effect.
  34452. */
  34453. exposure: number;
  34454. /**
  34455. * Gets wether tonemapping is enabled or not.
  34456. */
  34457. /**
  34458. * Sets wether tonemapping is enabled or not
  34459. */
  34460. toneMappingEnabled: boolean;
  34461. /**
  34462. * Gets contrast used in the effect.
  34463. */
  34464. /**
  34465. * Sets contrast used in the effect.
  34466. */
  34467. contrast: number;
  34468. /**
  34469. * Gets Vignette stretch size.
  34470. */
  34471. /**
  34472. * Sets Vignette stretch size.
  34473. */
  34474. vignetteStretch: number;
  34475. /**
  34476. * Gets Vignette centre X Offset.
  34477. */
  34478. /**
  34479. * Sets Vignette centre X Offset.
  34480. */
  34481. vignetteCentreX: number;
  34482. /**
  34483. * Gets Vignette centre Y Offset.
  34484. */
  34485. /**
  34486. * Sets Vignette centre Y Offset.
  34487. */
  34488. vignetteCentreY: number;
  34489. /**
  34490. * Gets Vignette weight or intensity of the vignette effect.
  34491. */
  34492. /**
  34493. * Sets Vignette weight or intensity of the vignette effect.
  34494. */
  34495. vignetteWeight: number;
  34496. /**
  34497. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  34498. * if vignetteEnabled is set to true.
  34499. */
  34500. /**
  34501. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  34502. * if vignetteEnabled is set to true.
  34503. */
  34504. vignetteColor: Color4;
  34505. /**
  34506. * Gets Camera field of view used by the Vignette effect.
  34507. */
  34508. /**
  34509. * Sets Camera field of view used by the Vignette effect.
  34510. */
  34511. vignetteCameraFov: number;
  34512. /**
  34513. * Gets the vignette blend mode allowing different kind of effect.
  34514. */
  34515. /**
  34516. * Sets the vignette blend mode allowing different kind of effect.
  34517. */
  34518. vignetteBlendMode: number;
  34519. /**
  34520. * Gets wether the vignette effect is enabled.
  34521. */
  34522. /**
  34523. * Sets wether the vignette effect is enabled.
  34524. */
  34525. vignetteEnabled: boolean;
  34526. private _fromLinearSpace;
  34527. /**
  34528. * Gets wether the input of the processing is in Gamma or Linear Space.
  34529. */
  34530. /**
  34531. * Sets wether the input of the processing is in Gamma or Linear Space.
  34532. */
  34533. fromLinearSpace: boolean;
  34534. /**
  34535. * Defines cache preventing GC.
  34536. */
  34537. private _defines;
  34538. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  34539. /**
  34540. * "ImageProcessingPostProcess"
  34541. * @returns "ImageProcessingPostProcess"
  34542. */
  34543. getClassName(): string;
  34544. protected _updateParameters(): void;
  34545. dispose(camera?: Camera): void;
  34546. }
  34547. }
  34548. declare module BABYLON {
  34549. /**
  34550. * PassPostProcess which produces an output the same as it's input
  34551. */
  34552. class PassPostProcess extends PostProcess {
  34553. /**
  34554. * Creates the PassPostProcess
  34555. * @param name The name of the effect.
  34556. * @param options The required width/height ratio to downsize to before computing the render pass.
  34557. * @param camera The camera to apply the render pass to.
  34558. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34559. * @param engine The engine which the post process will be applied. (default: current engine)
  34560. * @param reusable If the post process can be reused on the same frame. (default: false)
  34561. * @param textureType The type of texture to be used when performing the post processing.
  34562. * @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)
  34563. */
  34564. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  34565. }
  34566. }
  34567. declare module BABYLON {
  34568. /**
  34569. * Size options for a post process
  34570. */
  34571. type PostProcessOptions = {
  34572. width: number;
  34573. height: number;
  34574. };
  34575. /**
  34576. * PostProcess can be used to apply a shader to a texture after it has been rendered
  34577. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  34578. */
  34579. class PostProcess {
  34580. /** Name of the PostProcess. */
  34581. name: string;
  34582. /**
  34583. * Width of the texture to apply the post process on
  34584. */
  34585. width: number;
  34586. /**
  34587. * Height of the texture to apply the post process on
  34588. */
  34589. height: number;
  34590. /**
  34591. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  34592. * @hidden
  34593. */
  34594. _outputTexture: Nullable<InternalTexture>;
  34595. /**
  34596. * Sampling mode used by the shader
  34597. * See https://doc.babylonjs.com/classes/3.1/texture
  34598. */
  34599. renderTargetSamplingMode: number;
  34600. /**
  34601. * Clear color to use when screen clearing
  34602. */
  34603. clearColor: Color4;
  34604. /**
  34605. * If the buffer needs to be cleared before applying the post process. (default: true)
  34606. * Should be set to false if shader will overwrite all previous pixels.
  34607. */
  34608. autoClear: boolean;
  34609. /**
  34610. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  34611. */
  34612. alphaMode: number;
  34613. /**
  34614. * Sets the setAlphaBlendConstants of the babylon engine
  34615. */
  34616. alphaConstants: Color4;
  34617. /**
  34618. * Animations to be used for the post processing
  34619. */
  34620. animations: Animation[];
  34621. /**
  34622. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  34623. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  34624. */
  34625. enablePixelPerfectMode: boolean;
  34626. /**
  34627. * Force the postprocess to be applied without taking in account viewport
  34628. */
  34629. forceFullscreenViewport: boolean;
  34630. /**
  34631. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  34632. *
  34633. * | Value | Type | Description |
  34634. * | ----- | ----------------------------------- | ----------- |
  34635. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  34636. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  34637. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  34638. *
  34639. */
  34640. scaleMode: number;
  34641. /**
  34642. * Force textures to be a power of two (default: false)
  34643. */
  34644. alwaysForcePOT: boolean;
  34645. private _samples;
  34646. /**
  34647. * Number of sample textures (default: 1)
  34648. */
  34649. samples: number;
  34650. /**
  34651. * Modify the scale of the post process to be the same as the viewport (default: false)
  34652. */
  34653. adaptScaleToCurrentViewport: boolean;
  34654. private _camera;
  34655. private _scene;
  34656. private _engine;
  34657. private _options;
  34658. private _reusable;
  34659. private _textureType;
  34660. /**
  34661. * Smart array of input and output textures for the post process.
  34662. * @hidden
  34663. */
  34664. _textures: SmartArray<InternalTexture>;
  34665. /**
  34666. * The index in _textures that corresponds to the output texture.
  34667. * @hidden
  34668. */
  34669. _currentRenderTextureInd: number;
  34670. private _effect;
  34671. private _samplers;
  34672. private _fragmentUrl;
  34673. private _vertexUrl;
  34674. private _parameters;
  34675. private _scaleRatio;
  34676. protected _indexParameters: any;
  34677. private _shareOutputWithPostProcess;
  34678. private _texelSize;
  34679. private _forcedOutputTexture;
  34680. /**
  34681. * An event triggered when the postprocess is activated.
  34682. */
  34683. onActivateObservable: Observable<Camera>;
  34684. private _onActivateObserver;
  34685. /**
  34686. * A function that is added to the onActivateObservable
  34687. */
  34688. onActivate: Nullable<(camera: Camera) => void>;
  34689. /**
  34690. * An event triggered when the postprocess changes its size.
  34691. */
  34692. onSizeChangedObservable: Observable<PostProcess>;
  34693. private _onSizeChangedObserver;
  34694. /**
  34695. * A function that is added to the onSizeChangedObservable
  34696. */
  34697. onSizeChanged: (postProcess: PostProcess) => void;
  34698. /**
  34699. * An event triggered when the postprocess applies its effect.
  34700. */
  34701. onApplyObservable: Observable<Effect>;
  34702. private _onApplyObserver;
  34703. /**
  34704. * A function that is added to the onApplyObservable
  34705. */
  34706. onApply: (effect: Effect) => void;
  34707. /**
  34708. * An event triggered before rendering the postprocess
  34709. */
  34710. onBeforeRenderObservable: Observable<Effect>;
  34711. private _onBeforeRenderObserver;
  34712. /**
  34713. * A function that is added to the onBeforeRenderObservable
  34714. */
  34715. onBeforeRender: (effect: Effect) => void;
  34716. /**
  34717. * An event triggered after rendering the postprocess
  34718. */
  34719. onAfterRenderObservable: Observable<Effect>;
  34720. private _onAfterRenderObserver;
  34721. /**
  34722. * A function that is added to the onAfterRenderObservable
  34723. */
  34724. onAfterRender: (efect: Effect) => void;
  34725. /**
  34726. * 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
  34727. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  34728. */
  34729. inputTexture: InternalTexture;
  34730. /**
  34731. * Gets the camera which post process is applied to.
  34732. * @returns The camera the post process is applied to.
  34733. */
  34734. getCamera(): Camera;
  34735. /**
  34736. * Gets the texel size of the postprocess.
  34737. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  34738. */
  34739. readonly texelSize: Vector2;
  34740. /**
  34741. * Creates a new instance PostProcess
  34742. * @param name The name of the PostProcess.
  34743. * @param fragmentUrl The url of the fragment shader to be used.
  34744. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  34745. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  34746. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  34747. * @param camera The camera to apply the render pass to.
  34748. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34749. * @param engine The engine which the post process will be applied. (default: current engine)
  34750. * @param reusable If the post process can be reused on the same frame. (default: false)
  34751. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  34752. * @param textureType Type of textures used when performing the post process. (default: 0)
  34753. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  34754. * @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
  34755. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  34756. */
  34757. constructor(
  34758. /** Name of the PostProcess. */
  34759. 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);
  34760. /**
  34761. * Gets the engine which this post process belongs to.
  34762. * @returns The engine the post process was enabled with.
  34763. */
  34764. getEngine(): Engine;
  34765. /**
  34766. * The effect that is created when initializing the post process.
  34767. * @returns The created effect corrisponding the the postprocess.
  34768. */
  34769. getEffect(): Effect;
  34770. /**
  34771. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  34772. * @param postProcess The post process to share the output with.
  34773. * @returns This post process.
  34774. */
  34775. shareOutputWith(postProcess: PostProcess): PostProcess;
  34776. /**
  34777. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  34778. * This should be called if the post process that shares output with this post process is disabled/disposed.
  34779. */
  34780. useOwnOutput(): void;
  34781. /**
  34782. * Updates the effect with the current post process compile time values and recompiles the shader.
  34783. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  34784. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  34785. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  34786. * @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
  34787. * @param onCompiled Called when the shader has been compiled.
  34788. * @param onError Called if there is an error when compiling a shader.
  34789. */
  34790. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  34791. /**
  34792. * The post process is reusable if it can be used multiple times within one frame.
  34793. * @returns If the post process is reusable
  34794. */
  34795. isReusable(): boolean;
  34796. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  34797. markTextureDirty(): void;
  34798. /**
  34799. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  34800. * 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.
  34801. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  34802. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  34803. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  34804. * @returns The target texture that was bound to be written to.
  34805. */
  34806. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  34807. /**
  34808. * If the post process is supported.
  34809. */
  34810. readonly isSupported: boolean;
  34811. /**
  34812. * The aspect ratio of the output texture.
  34813. */
  34814. readonly aspectRatio: number;
  34815. /**
  34816. * Get a value indicating if the post-process is ready to be used
  34817. * @returns true if the post-process is ready (shader is compiled)
  34818. */
  34819. isReady(): boolean;
  34820. /**
  34821. * Binds all textures and uniforms to the shader, this will be run on every pass.
  34822. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  34823. */
  34824. apply(): Nullable<Effect>;
  34825. private _disposeTextures;
  34826. /**
  34827. * Disposes the post process.
  34828. * @param camera The camera to dispose the post process on.
  34829. */
  34830. dispose(camera?: Camera): void;
  34831. }
  34832. }
  34833. declare module BABYLON {
  34834. /**
  34835. * PostProcessManager is used to manage one or more post processes or post process pipelines
  34836. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  34837. */
  34838. class PostProcessManager {
  34839. private _scene;
  34840. private _indexBuffer;
  34841. private _vertexBuffers;
  34842. /**
  34843. * Creates a new instance PostProcess
  34844. * @param scene The scene that the post process is associated with.
  34845. */
  34846. constructor(scene: Scene);
  34847. private _prepareBuffers;
  34848. private _buildIndexBuffer;
  34849. /**
  34850. * Rebuilds the vertex buffers of the manager.
  34851. * @hidden
  34852. */
  34853. _rebuild(): void;
  34854. /**
  34855. * Prepares a frame to be run through a post process.
  34856. * @param sourceTexture The input texture to the post procesess. (default: null)
  34857. * @param postProcesses An array of post processes to be run. (default: null)
  34858. * @returns True if the post processes were able to be run.
  34859. * @hidden
  34860. */
  34861. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  34862. /**
  34863. * Manually render a set of post processes to a texture.
  34864. * @param postProcesses An array of post processes to be run.
  34865. * @param targetTexture The target texture to render to.
  34866. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  34867. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  34868. * @param lodLevel defines which lod of the texture to render to
  34869. */
  34870. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  34871. /**
  34872. * Finalize the result of the output of the postprocesses.
  34873. * @param doNotPresent If true the result will not be displayed to the screen.
  34874. * @param targetTexture The target texture to render to.
  34875. * @param faceIndex The index of the face to bind the target texture to.
  34876. * @param postProcesses The array of post processes to render.
  34877. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  34878. * @hidden
  34879. */
  34880. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  34881. /**
  34882. * Disposes of the post process manager.
  34883. */
  34884. dispose(): void;
  34885. }
  34886. }
  34887. declare module BABYLON {
  34888. /**
  34889. * Post process which applies a refractin texture
  34890. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  34891. */
  34892. class RefractionPostProcess extends PostProcess {
  34893. /** the base color of the refraction (used to taint the rendering) */
  34894. color: Color3;
  34895. /** simulated refraction depth */
  34896. depth: number;
  34897. /** the coefficient of the base color (0 to remove base color tainting) */
  34898. colorLevel: number;
  34899. private _refTexture;
  34900. private _ownRefractionTexture;
  34901. /**
  34902. * Gets or sets the refraction texture
  34903. * Please note that you are responsible for disposing the texture if you set it manually
  34904. */
  34905. refractionTexture: Texture;
  34906. /**
  34907. * Initializes the RefractionPostProcess
  34908. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  34909. * @param name The name of the effect.
  34910. * @param refractionTextureUrl Url of the refraction texture to use
  34911. * @param color the base color of the refraction (used to taint the rendering)
  34912. * @param depth simulated refraction depth
  34913. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  34914. * @param camera The camera to apply the render pass to.
  34915. * @param options The required width/height ratio to downsize to before computing the render pass.
  34916. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34917. * @param engine The engine which the post process will be applied. (default: current engine)
  34918. * @param reusable If the post process can be reused on the same frame. (default: false)
  34919. */
  34920. constructor(name: string, refractionTextureUrl: string,
  34921. /** the base color of the refraction (used to taint the rendering) */
  34922. color: Color3,
  34923. /** simulated refraction depth */
  34924. depth: number,
  34925. /** the coefficient of the base color (0 to remove base color tainting) */
  34926. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  34927. /**
  34928. * Disposes of the post process
  34929. * @param camera Camera to dispose post process on
  34930. */
  34931. dispose(camera: Camera): void;
  34932. }
  34933. }
  34934. declare module BABYLON {
  34935. /**
  34936. * The SharpenPostProcess applies a sharpen kernel to every pixel
  34937. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  34938. */
  34939. class SharpenPostProcess extends PostProcess {
  34940. /**
  34941. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  34942. */
  34943. colorAmount: number;
  34944. /**
  34945. * How much sharpness should be applied (default: 0.3)
  34946. */
  34947. edgeAmount: number;
  34948. /**
  34949. * Creates a new instance ConvolutionPostProcess
  34950. * @param name The name of the effect.
  34951. * @param options The required width/height ratio to downsize to before computing the render pass.
  34952. * @param camera The camera to apply the render pass to.
  34953. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34954. * @param engine The engine which the post process will be applied. (default: current engine)
  34955. * @param reusable If the post process can be reused on the same frame. (default: false)
  34956. * @param textureType Type of textures used when performing the post process. (default: 0)
  34957. * @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)
  34958. */
  34959. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  34960. }
  34961. }
  34962. declare module BABYLON {
  34963. /**
  34964. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  34965. */
  34966. class StereoscopicInterlacePostProcess extends PostProcess {
  34967. private _stepSize;
  34968. private _passedProcess;
  34969. /**
  34970. * Initializes a StereoscopicInterlacePostProcess
  34971. * @param name The name of the effect.
  34972. * @param rigCameras The rig cameras to be appled to the post process
  34973. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  34974. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34975. * @param engine The engine which the post process will be applied. (default: current engine)
  34976. * @param reusable If the post process can be reused on the same frame. (default: false)
  34977. */
  34978. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  34979. }
  34980. }
  34981. declare module BABYLON {
  34982. /** Defines operator used for tonemapping */
  34983. enum TonemappingOperator {
  34984. /** Hable */
  34985. Hable = 0,
  34986. /** Reinhard */
  34987. Reinhard = 1,
  34988. /** HejiDawson */
  34989. HejiDawson = 2,
  34990. /** Photographic */
  34991. Photographic = 3
  34992. }
  34993. /**
  34994. * Defines a post process to apply tone mapping
  34995. */
  34996. class TonemapPostProcess extends PostProcess {
  34997. private _operator;
  34998. /** Defines the required exposure adjustement */
  34999. exposureAdjustment: number;
  35000. /**
  35001. * Creates a new TonemapPostProcess
  35002. * @param name defines the name of the postprocess
  35003. * @param _operator defines the operator to use
  35004. * @param exposureAdjustment defines the required exposure adjustement
  35005. * @param camera defines the camera to use (can be null)
  35006. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  35007. * @param engine defines the hosting engine (can be ignore if camera is set)
  35008. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  35009. */
  35010. constructor(name: string, _operator: TonemappingOperator,
  35011. /** Defines the required exposure adjustement */
  35012. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  35013. }
  35014. }
  35015. declare module BABYLON {
  35016. /**
  35017. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  35018. */
  35019. class VolumetricLightScatteringPostProcess extends PostProcess {
  35020. private _volumetricLightScatteringPass;
  35021. private _volumetricLightScatteringRTT;
  35022. private _viewPort;
  35023. private _screenCoordinates;
  35024. private _cachedDefines;
  35025. /**
  35026. * If not undefined, the mesh position is computed from the attached node position
  35027. */
  35028. attachedNode: {
  35029. position: Vector3;
  35030. };
  35031. /**
  35032. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  35033. */
  35034. customMeshPosition: Vector3;
  35035. /**
  35036. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  35037. */
  35038. useCustomMeshPosition: boolean;
  35039. /**
  35040. * If the post-process should inverse the light scattering direction
  35041. */
  35042. invert: boolean;
  35043. /**
  35044. * The internal mesh used by the post-process
  35045. */
  35046. mesh: Mesh;
  35047. /**
  35048. * @hidden
  35049. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  35050. */
  35051. useDiffuseColor: boolean;
  35052. /**
  35053. * Array containing the excluded meshes not rendered in the internal pass
  35054. */
  35055. excludedMeshes: AbstractMesh[];
  35056. /**
  35057. * Controls the overall intensity of the post-process
  35058. */
  35059. exposure: number;
  35060. /**
  35061. * Dissipates each sample's contribution in range [0, 1]
  35062. */
  35063. decay: number;
  35064. /**
  35065. * Controls the overall intensity of each sample
  35066. */
  35067. weight: number;
  35068. /**
  35069. * Controls the density of each sample
  35070. */
  35071. density: number;
  35072. /**
  35073. * @constructor
  35074. * @param name The post-process name
  35075. * @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)
  35076. * @param camera The camera that the post-process will be attached to
  35077. * @param mesh The mesh used to create the light scattering
  35078. * @param samples The post-process quality, default 100
  35079. * @param samplingModeThe post-process filtering mode
  35080. * @param engine The babylon engine
  35081. * @param reusable If the post-process is reusable
  35082. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  35083. */
  35084. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  35085. /**
  35086. * Returns the string "VolumetricLightScatteringPostProcess"
  35087. * @returns "VolumetricLightScatteringPostProcess"
  35088. */
  35089. getClassName(): string;
  35090. private _isReady;
  35091. /**
  35092. * Sets the new light position for light scattering effect
  35093. * @param position The new custom light position
  35094. */
  35095. setCustomMeshPosition(position: Vector3): void;
  35096. /**
  35097. * Returns the light position for light scattering effect
  35098. * @return Vector3 The custom light position
  35099. */
  35100. getCustomMeshPosition(): Vector3;
  35101. /**
  35102. * Disposes the internal assets and detaches the post-process from the camera
  35103. */
  35104. dispose(camera: Camera): void;
  35105. /**
  35106. * Returns the render target texture used by the post-process
  35107. * @return the render target texture used by the post-process
  35108. */
  35109. getPass(): RenderTargetTexture;
  35110. private _meshExcluded;
  35111. private _createPass;
  35112. private _updateMeshScreenCoordinates;
  35113. /**
  35114. * Creates a default mesh for the Volumeric Light Scattering post-process
  35115. * @param name The mesh name
  35116. * @param scene The scene where to create the mesh
  35117. * @return the default mesh
  35118. */
  35119. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  35120. }
  35121. }
  35122. declare module BABYLON {
  35123. /**
  35124. * VRDistortionCorrectionPostProcess used for mobile VR
  35125. */
  35126. class VRDistortionCorrectionPostProcess extends PostProcess {
  35127. private _isRightEye;
  35128. private _distortionFactors;
  35129. private _postProcessScaleFactor;
  35130. private _lensCenterOffset;
  35131. private _scaleIn;
  35132. private _scaleFactor;
  35133. private _lensCenter;
  35134. /**
  35135. * Initializes the VRDistortionCorrectionPostProcess
  35136. * @param name The name of the effect.
  35137. * @param camera The camera to apply the render pass to.
  35138. * @param isRightEye If this is for the right eye distortion
  35139. * @param vrMetrics All the required metrics for the VR camera
  35140. */
  35141. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  35142. }
  35143. }
  35144. declare module BABYLON {
  35145. interface Scene {
  35146. /** @hidden (Backing field) */
  35147. _boundingBoxRenderer: BoundingBoxRenderer;
  35148. /** @hidden (Backing field) */
  35149. _forceShowBoundingBoxes: boolean;
  35150. /**
  35151. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  35152. */
  35153. forceShowBoundingBoxes: boolean;
  35154. /**
  35155. * Gets the bounding box renderer associated with the scene
  35156. * @returns a BoundingBoxRenderer
  35157. */
  35158. getBoundingBoxRenderer(): BoundingBoxRenderer;
  35159. }
  35160. interface AbstractMesh {
  35161. /** @hidden (Backing field) */
  35162. _showBoundingBox: boolean;
  35163. /**
  35164. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  35165. */
  35166. showBoundingBox: boolean;
  35167. }
  35168. /**
  35169. * Component responsible of rendering the bounding box of the meshes in a scene.
  35170. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  35171. */
  35172. class BoundingBoxRenderer implements ISceneComponent {
  35173. /**
  35174. * The component name helpfull to identify the component in the list of scene components.
  35175. */
  35176. readonly name: string;
  35177. /**
  35178. * The scene the component belongs to.
  35179. */
  35180. scene: Scene;
  35181. /**
  35182. * Color of the bounding box lines placed in front of an object
  35183. */
  35184. frontColor: Color3;
  35185. /**
  35186. * Color of the bounding box lines placed behind an object
  35187. */
  35188. backColor: Color3;
  35189. /**
  35190. * Defines if the renderer should show the back lines or not
  35191. */
  35192. showBackLines: boolean;
  35193. /**
  35194. * @hidden
  35195. */
  35196. renderList: SmartArray<BoundingBox>;
  35197. private _colorShader;
  35198. private _vertexBuffers;
  35199. private _indexBuffer;
  35200. /**
  35201. * Instantiates a new bounding box renderer in a scene.
  35202. * @param scene the scene the renderer renders in
  35203. */
  35204. constructor(scene: Scene);
  35205. /**
  35206. * Registers the component in a given scene
  35207. */
  35208. register(): void;
  35209. private _evaluateSubMesh;
  35210. private _activeMesh;
  35211. private _prepareRessources;
  35212. private _createIndexBuffer;
  35213. /**
  35214. * Rebuilds the elements related to this component in case of
  35215. * context lost for instance.
  35216. */
  35217. rebuild(): void;
  35218. /**
  35219. * @hidden
  35220. */
  35221. reset(): void;
  35222. /**
  35223. * Render the bounding boxes of a specific rendering group
  35224. * @param renderingGroupId defines the rendering group to render
  35225. */
  35226. render(renderingGroupId: number): void;
  35227. /**
  35228. * In case of occlusion queries, we can render the occlusion bounding box through this method
  35229. * @param mesh Define the mesh to render the occlusion bounding box for
  35230. */
  35231. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  35232. /**
  35233. * Dispose and release the resources attached to this renderer.
  35234. */
  35235. dispose(): void;
  35236. }
  35237. }
  35238. declare module BABYLON {
  35239. /**
  35240. * This represents a depth renderer in Babylon.
  35241. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  35242. */
  35243. class DepthRenderer {
  35244. private _scene;
  35245. private _depthMap;
  35246. private _effect;
  35247. private _cachedDefines;
  35248. private _camera;
  35249. /**
  35250. * Specifiess that the depth renderer will only be used within
  35251. * the camera it is created for.
  35252. * This can help forcing its rendering during the camera processing.
  35253. */
  35254. useOnlyInActiveCamera: boolean;
  35255. /**
  35256. * Instantiates a depth renderer
  35257. * @param scene The scene the renderer belongs to
  35258. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  35259. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  35260. */
  35261. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  35262. /**
  35263. * Creates the depth rendering effect and checks if the effect is ready.
  35264. * @param subMesh The submesh to be used to render the depth map of
  35265. * @param useInstances If multiple world instances should be used
  35266. * @returns if the depth renderer is ready to render the depth map
  35267. */
  35268. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  35269. /**
  35270. * Gets the texture which the depth map will be written to.
  35271. * @returns The depth map texture
  35272. */
  35273. getDepthMap(): RenderTargetTexture;
  35274. /**
  35275. * Disposes of the depth renderer.
  35276. */
  35277. dispose(): void;
  35278. }
  35279. }
  35280. declare module BABYLON {
  35281. interface Scene {
  35282. /** @hidden (Backing field) */
  35283. _depthRenderer: {
  35284. [id: string]: DepthRenderer;
  35285. };
  35286. /**
  35287. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  35288. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  35289. * @returns the created depth renderer
  35290. */
  35291. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  35292. /**
  35293. * Disables a depth renderer for a given camera
  35294. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  35295. */
  35296. disableDepthRenderer(camera?: Nullable<Camera>): void;
  35297. }
  35298. /**
  35299. * Defines the Depth Renderer scene component responsible to manage a depth buffer usefull
  35300. * in several rendering techniques.
  35301. */
  35302. class DepthRendererSceneComponent implements ISceneComponent {
  35303. /**
  35304. * The component name helpfull to identify the component in the list of scene components.
  35305. */
  35306. readonly name: string;
  35307. /**
  35308. * The scene the component belongs to.
  35309. */
  35310. scene: Scene;
  35311. /**
  35312. * Creates a new instance of the component for the given scene
  35313. * @param scene Defines the scene to register the component in
  35314. */
  35315. constructor(scene: Scene);
  35316. /**
  35317. * Registers the component in a given scene
  35318. */
  35319. register(): void;
  35320. /**
  35321. * Rebuilds the elements related to this component in case of
  35322. * context lost for instance.
  35323. */
  35324. rebuild(): void;
  35325. /**
  35326. * Disposes the component and the associated ressources
  35327. */
  35328. dispose(): void;
  35329. private _gatherRenderTargets;
  35330. private _gatherActiveCameraRenderTargets;
  35331. }
  35332. }
  35333. declare module BABYLON {
  35334. interface AbstractMesh {
  35335. /**
  35336. * Disables the mesh edge rendering mode
  35337. * @returns the currentAbstractMesh
  35338. */
  35339. disableEdgesRendering(): AbstractMesh;
  35340. /**
  35341. * Enables the edge rendering mode on the mesh.
  35342. * This mode makes the mesh edges visible
  35343. * @param epsilon defines the maximal distance between two angles to detect a face
  35344. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  35345. * @returns the currentAbstractMesh
  35346. * @see https://www.babylonjs-playground.com/#19O9TU#0
  35347. */
  35348. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  35349. /**
  35350. * Gets the edgesRenderer associated with the mesh
  35351. */
  35352. edgesRenderer: Nullable<EdgesRenderer>;
  35353. }
  35354. interface LinesMesh {
  35355. /**
  35356. * Enables the edge rendering mode on the mesh.
  35357. * This mode makes the mesh edges visible
  35358. * @param epsilon defines the maximal distance between two angles to detect a face
  35359. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  35360. * @returns the currentAbstractMesh
  35361. * @see https://www.babylonjs-playground.com/#19O9TU#0
  35362. */
  35363. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  35364. }
  35365. /**
  35366. * Defines the minimum contract an Edges renderer should follow.
  35367. */
  35368. interface IEdgesRenderer extends IDisposable {
  35369. /**
  35370. * Gets or sets a boolean indicating if the edgesRenderer is active
  35371. */
  35372. isEnabled: boolean;
  35373. /**
  35374. * Renders the edges of the attached mesh,
  35375. */
  35376. render(): void;
  35377. /**
  35378. * Checks wether or not the edges renderer is ready to render.
  35379. * @return true if ready, otherwise false.
  35380. */
  35381. isReady(): boolean;
  35382. }
  35383. /**
  35384. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  35385. */
  35386. class EdgesRenderer implements IEdgesRenderer {
  35387. /**
  35388. * Define the size of the edges with an orthographic camera
  35389. */
  35390. edgesWidthScalerForOrthographic: number;
  35391. /**
  35392. * Define the size of the edges with a perspective camera
  35393. */
  35394. edgesWidthScalerForPerspective: number;
  35395. protected _source: AbstractMesh;
  35396. protected _linesPositions: number[];
  35397. protected _linesNormals: number[];
  35398. protected _linesIndices: number[];
  35399. protected _epsilon: number;
  35400. protected _indicesCount: number;
  35401. protected _lineShader: ShaderMaterial;
  35402. protected _ib: WebGLBuffer;
  35403. protected _buffers: {
  35404. [key: string]: Nullable<VertexBuffer>;
  35405. };
  35406. protected _checkVerticesInsteadOfIndices: boolean;
  35407. private _meshRebuildObserver;
  35408. private _meshDisposeObserver;
  35409. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  35410. isEnabled: boolean;
  35411. /**
  35412. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  35413. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  35414. * @param source Mesh used to create edges
  35415. * @param epsilon sum of angles in adjacency to check for edge
  35416. * @param checkVerticesInsteadOfIndices
  35417. * @param generateEdgesLines - should generate Lines or only prepare resources.
  35418. */
  35419. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  35420. protected _prepareRessources(): void;
  35421. /** @hidden */
  35422. _rebuild(): void;
  35423. /**
  35424. * Releases the required resources for the edges renderer
  35425. */
  35426. dispose(): void;
  35427. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  35428. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  35429. /**
  35430. * Checks if the pair of p0 and p1 is en edge
  35431. * @param faceIndex
  35432. * @param edge
  35433. * @param faceNormals
  35434. * @param p0
  35435. * @param p1
  35436. * @private
  35437. */
  35438. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  35439. /**
  35440. * Generates lines edges from adjacencjes
  35441. * @private
  35442. */
  35443. _generateEdgesLines(): void;
  35444. /**
  35445. * Checks wether or not the edges renderer is ready to render.
  35446. * @return true if ready, otherwise false.
  35447. */
  35448. isReady(): boolean;
  35449. /**
  35450. * Renders the edges of the attached mesh,
  35451. */
  35452. render(): void;
  35453. }
  35454. }
  35455. declare module BABYLON {
  35456. /**
  35457. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  35458. */
  35459. class GeometryBufferRenderer {
  35460. private _scene;
  35461. private _multiRenderTarget;
  35462. private _ratio;
  35463. private _enablePosition;
  35464. protected _effect: Effect;
  35465. protected _cachedDefines: string;
  35466. /**
  35467. * Set the render list (meshes to be rendered) used in the G buffer.
  35468. */
  35469. renderList: Mesh[];
  35470. /**
  35471. * Gets wether or not G buffer are supported by the running hardware.
  35472. * This requires draw buffer supports
  35473. */
  35474. readonly isSupported: boolean;
  35475. /**
  35476. * Gets wether or not position are enabled for the G buffer.
  35477. */
  35478. /**
  35479. * Sets wether or not position are enabled for the G buffer.
  35480. */
  35481. enablePosition: boolean;
  35482. /**
  35483. * Gets the scene associated with the buffer.
  35484. */
  35485. readonly scene: Scene;
  35486. /**
  35487. * Gets the ratio used by the buffer during its creation.
  35488. * How big is the buffer related to the main canvas.
  35489. */
  35490. readonly ratio: number;
  35491. /**
  35492. * Creates a new G Buffer for the scene
  35493. * @param scene The scene the buffer belongs to
  35494. * @param ratio How big is the buffer related to the main canvas.
  35495. */
  35496. constructor(scene: Scene, ratio?: number);
  35497. /**
  35498. * Checks wether everything is ready to render a submesh to the G buffer.
  35499. * @param subMesh the submesh to check readiness for
  35500. * @param useInstances is the mesh drawn using instance or not
  35501. * @returns true if ready otherwise false
  35502. */
  35503. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  35504. /**
  35505. * Gets the current underlying G Buffer.
  35506. * @returns the buffer
  35507. */
  35508. getGBuffer(): MultiRenderTarget;
  35509. /**
  35510. * Gets the number of samples used to render the buffer (anti aliasing).
  35511. */
  35512. /**
  35513. * Sets the number of samples used to render the buffer (anti aliasing).
  35514. */
  35515. samples: number;
  35516. /**
  35517. * Disposes the renderer and frees up associated resources.
  35518. */
  35519. dispose(): void;
  35520. protected _createRenderTargets(): void;
  35521. }
  35522. }
  35523. declare module BABYLON {
  35524. interface Scene {
  35525. /** @hidden (Backing field) */
  35526. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  35527. /**
  35528. * Gets or Sets the current geometry buffer associated to the scene.
  35529. */
  35530. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  35531. /**
  35532. * Enables a GeometryBufferRender and associates it with the scene
  35533. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  35534. * @returns the GeometryBufferRenderer
  35535. */
  35536. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  35537. /**
  35538. * Disables the GeometryBufferRender associated with the scene
  35539. */
  35540. disableGeometryBufferRenderer(): void;
  35541. }
  35542. /**
  35543. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  35544. * in several rendering techniques.
  35545. */
  35546. class GeometryBufferRendererSceneComponent implements ISceneComponent {
  35547. /**
  35548. * The component name helpful to identify the component in the list of scene components.
  35549. */
  35550. readonly name: string;
  35551. /**
  35552. * The scene the component belongs to.
  35553. */
  35554. scene: Scene;
  35555. /**
  35556. * Creates a new instance of the component for the given scene
  35557. * @param scene Defines the scene to register the component in
  35558. */
  35559. constructor(scene: Scene);
  35560. /**
  35561. * Registers the component in a given scene
  35562. */
  35563. register(): void;
  35564. /**
  35565. * Rebuilds the elements related to this component in case of
  35566. * context lost for instance.
  35567. */
  35568. rebuild(): void;
  35569. /**
  35570. * Disposes the component and the associated ressources
  35571. */
  35572. dispose(): void;
  35573. private _gatherRenderTargets;
  35574. }
  35575. }
  35576. declare module BABYLON {
  35577. /**
  35578. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  35579. */
  35580. class LineEdgesRenderer extends EdgesRenderer {
  35581. /**
  35582. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  35583. * @param source LineMesh used to generate edges
  35584. * @param epsilon not important (specified angle for edge detection)
  35585. * @param checkVerticesInsteadOfIndices not important for LineMesh
  35586. */
  35587. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  35588. /**
  35589. * Always create the edge since its a line so only important things are p0 and p1
  35590. * @param faceIndex not important for LineMesh
  35591. * @param edge not important for LineMesh
  35592. * @param faceNormals not important for LineMesh
  35593. * @param p0 beginnig of line
  35594. * @param p1 end of line
  35595. */
  35596. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  35597. /**
  35598. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  35599. */
  35600. _generateEdgesLines(): void;
  35601. }
  35602. }
  35603. declare module BABYLON {
  35604. interface Scene {
  35605. /** @hidden */
  35606. _outlineRenderer: OutlineRenderer;
  35607. /**
  35608. * Gets the outline renderer associated with the scene
  35609. * @returns a OutlineRenderer
  35610. */
  35611. getOutlineRenderer(): OutlineRenderer;
  35612. }
  35613. interface AbstractMesh {
  35614. /** @hidden (Backing field) */
  35615. _renderOutline: boolean;
  35616. /**
  35617. * Gets or sets a boolean indicating if the outline must be rendered as well
  35618. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  35619. */
  35620. renderOutline: boolean;
  35621. /** @hidden (Backing field) */
  35622. _renderOverlay: boolean;
  35623. /**
  35624. * Gets or sets a boolean indicating if the overlay must be rendered as well
  35625. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  35626. */
  35627. renderOverlay: boolean;
  35628. }
  35629. /**
  35630. * This class is responsible to draw bothe outline/overlay of meshes.
  35631. * It should not be used directly but through the available method on mesh.
  35632. */
  35633. class OutlineRenderer implements ISceneComponent {
  35634. /**
  35635. * The name of the component. Each component must have a unique name.
  35636. */
  35637. name: string;
  35638. /**
  35639. * The scene the component belongs to.
  35640. */
  35641. scene: Scene;
  35642. /**
  35643. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  35644. */
  35645. zOffset: number;
  35646. private _engine;
  35647. private _effect;
  35648. private _cachedDefines;
  35649. private _savedDepthWrite;
  35650. /**
  35651. * Instantiates a new outline renderer. (There could be only one per scene).
  35652. * @param scene Defines the scene it belongs to
  35653. */
  35654. constructor(scene: Scene);
  35655. /**
  35656. * Register the component to one instance of a scene.
  35657. */
  35658. register(): void;
  35659. /**
  35660. * Rebuilds the elements related to this component in case of
  35661. * context lost for instance.
  35662. */
  35663. rebuild(): void;
  35664. /**
  35665. * Disposes the component and the associated ressources.
  35666. */
  35667. dispose(): void;
  35668. /**
  35669. * Renders the outline in the canvas.
  35670. * @param subMesh Defines the sumesh to render
  35671. * @param batch Defines the batch of meshes in case of instances
  35672. * @param useOverlay Defines if the rendering is for the overlay or the outline
  35673. */
  35674. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  35675. /**
  35676. * Returns whether or not the outline renderer is ready for a given submesh.
  35677. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  35678. * @param subMesh Defines the submesh to check readyness for
  35679. * @param useInstances Defines wheter wee are trying to render instances or not
  35680. * @returns true if ready otherwise false
  35681. */
  35682. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  35683. private _beforeRenderingMesh;
  35684. private _afterRenderingMesh;
  35685. }
  35686. }
  35687. declare module BABYLON {
  35688. /**
  35689. * This represents the object necessary to create a rendering group.
  35690. * This is exclusively used and created by the rendering manager.
  35691. * To modify the behavior, you use the available helpers in your scene or meshes.
  35692. * @hidden
  35693. */
  35694. class RenderingGroup {
  35695. index: number;
  35696. private _scene;
  35697. private _opaqueSubMeshes;
  35698. private _transparentSubMeshes;
  35699. private _alphaTestSubMeshes;
  35700. private _depthOnlySubMeshes;
  35701. private _particleSystems;
  35702. private _spriteManagers;
  35703. private _opaqueSortCompareFn;
  35704. private _alphaTestSortCompareFn;
  35705. private _transparentSortCompareFn;
  35706. private _renderOpaque;
  35707. private _renderAlphaTest;
  35708. private _renderTransparent;
  35709. private _edgesRenderers;
  35710. onBeforeTransparentRendering: () => void;
  35711. /**
  35712. * Set the opaque sort comparison function.
  35713. * If null the sub meshes will be render in the order they were created
  35714. */
  35715. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  35716. /**
  35717. * Set the alpha test sort comparison function.
  35718. * If null the sub meshes will be render in the order they were created
  35719. */
  35720. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  35721. /**
  35722. * Set the transparent sort comparison function.
  35723. * If null the sub meshes will be render in the order they were created
  35724. */
  35725. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  35726. /**
  35727. * Creates a new rendering group.
  35728. * @param index The rendering group index
  35729. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  35730. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  35731. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  35732. */
  35733. 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>);
  35734. /**
  35735. * Render all the sub meshes contained in the group.
  35736. * @param customRenderFunction Used to override the default render behaviour of the group.
  35737. * @returns true if rendered some submeshes.
  35738. */
  35739. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  35740. /**
  35741. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  35742. * @param subMeshes The submeshes to render
  35743. */
  35744. private renderOpaqueSorted;
  35745. /**
  35746. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  35747. * @param subMeshes The submeshes to render
  35748. */
  35749. private renderAlphaTestSorted;
  35750. /**
  35751. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  35752. * @param subMeshes The submeshes to render
  35753. */
  35754. private renderTransparentSorted;
  35755. /**
  35756. * Renders the submeshes in a specified order.
  35757. * @param subMeshes The submeshes to sort before render
  35758. * @param sortCompareFn The comparison function use to sort
  35759. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  35760. * @param transparent Specifies to activate blending if true
  35761. */
  35762. private static renderSorted;
  35763. /**
  35764. * Renders the submeshes in the order they were dispatched (no sort applied).
  35765. * @param subMeshes The submeshes to render
  35766. */
  35767. private static renderUnsorted;
  35768. /**
  35769. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  35770. * are rendered back to front if in the same alpha index.
  35771. *
  35772. * @param a The first submesh
  35773. * @param b The second submesh
  35774. * @returns The result of the comparison
  35775. */
  35776. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  35777. /**
  35778. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  35779. * are rendered back to front.
  35780. *
  35781. * @param a The first submesh
  35782. * @param b The second submesh
  35783. * @returns The result of the comparison
  35784. */
  35785. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  35786. /**
  35787. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  35788. * are rendered front to back (prevent overdraw).
  35789. *
  35790. * @param a The first submesh
  35791. * @param b The second submesh
  35792. * @returns The result of the comparison
  35793. */
  35794. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  35795. /**
  35796. * Resets the different lists of submeshes to prepare a new frame.
  35797. */
  35798. prepare(): void;
  35799. dispose(): void;
  35800. /**
  35801. * Inserts the submesh in its correct queue depending on its material.
  35802. * @param subMesh The submesh to dispatch
  35803. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  35804. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  35805. */
  35806. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  35807. dispatchSprites(spriteManager: ISpriteManager): void;
  35808. dispatchParticles(particleSystem: IParticleSystem): void;
  35809. private _renderParticles;
  35810. private _renderSprites;
  35811. }
  35812. }
  35813. declare module BABYLON {
  35814. /**
  35815. * Interface describing the different options available in the rendering manager
  35816. * regarding Auto Clear between groups.
  35817. */
  35818. interface IRenderingManagerAutoClearSetup {
  35819. /**
  35820. * Defines whether or not autoclear is enable.
  35821. */
  35822. autoClear: boolean;
  35823. /**
  35824. * Defines whether or not to autoclear the depth buffer.
  35825. */
  35826. depth: boolean;
  35827. /**
  35828. * Defines whether or not to autoclear the stencil buffer.
  35829. */
  35830. stencil: boolean;
  35831. }
  35832. /**
  35833. * This is the manager responsible of all the rendering for meshes sprites and particles.
  35834. * It is enable to manage the different groups as well as the different necessary sort functions.
  35835. * This should not be used directly aside of the few static configurations
  35836. */
  35837. class RenderingManager {
  35838. /**
  35839. * The max id used for rendering groups (not included)
  35840. */
  35841. static MAX_RENDERINGGROUPS: number;
  35842. /**
  35843. * The min id used for rendering groups (included)
  35844. */
  35845. static MIN_RENDERINGGROUPS: number;
  35846. /**
  35847. * Used to globally prevent autoclearing scenes.
  35848. */
  35849. static AUTOCLEAR: boolean;
  35850. /**
  35851. * @hidden
  35852. */
  35853. _useSceneAutoClearSetup: boolean;
  35854. private _scene;
  35855. private _renderingGroups;
  35856. private _depthStencilBufferAlreadyCleaned;
  35857. private _autoClearDepthStencil;
  35858. private _customOpaqueSortCompareFn;
  35859. private _customAlphaTestSortCompareFn;
  35860. private _customTransparentSortCompareFn;
  35861. private _renderingGroupInfo;
  35862. /**
  35863. * Instantiates a new rendering group for a particular scene
  35864. * @param scene Defines the scene the groups belongs to
  35865. */
  35866. constructor(scene: Scene);
  35867. private _clearDepthStencilBuffer;
  35868. /**
  35869. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  35870. * @hidden
  35871. */
  35872. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  35873. /**
  35874. * Resets the different information of the group to prepare a new frame
  35875. * @hidden
  35876. */
  35877. reset(): void;
  35878. /**
  35879. * Dispose and release the group and its associated resources.
  35880. * @hidden
  35881. */
  35882. dispose(): void;
  35883. /**
  35884. * Clear the info related to rendering groups preventing retention points during dispose.
  35885. */
  35886. freeRenderingGroups(): void;
  35887. private _prepareRenderingGroup;
  35888. /**
  35889. * Add a sprite manager to the rendering manager in order to render it this frame.
  35890. * @param spriteManager Define the sprite manager to render
  35891. */
  35892. dispatchSprites(spriteManager: ISpriteManager): void;
  35893. /**
  35894. * Add a particle system to the rendering manager in order to render it this frame.
  35895. * @param particleSystem Define the particle system to render
  35896. */
  35897. dispatchParticles(particleSystem: IParticleSystem): void;
  35898. /**
  35899. * Add a submesh to the manager in order to render it this frame
  35900. * @param subMesh The submesh to dispatch
  35901. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  35902. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  35903. */
  35904. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  35905. /**
  35906. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  35907. * This allowed control for front to back rendering or reversly depending of the special needs.
  35908. *
  35909. * @param renderingGroupId The rendering group id corresponding to its index
  35910. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  35911. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  35912. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  35913. */
  35914. 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;
  35915. /**
  35916. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  35917. *
  35918. * @param renderingGroupId The rendering group id corresponding to its index
  35919. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  35920. * @param depth Automatically clears depth between groups if true and autoClear is true.
  35921. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  35922. */
  35923. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  35924. /**
  35925. * Gets the current auto clear configuration for one rendering group of the rendering
  35926. * manager.
  35927. * @param index the rendering group index to get the information for
  35928. * @returns The auto clear setup for the requested rendering group
  35929. */
  35930. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  35931. }
  35932. }
  35933. declare module BABYLON {
  35934. /**
  35935. * Renders a layer on top of an existing scene
  35936. */
  35937. class UtilityLayerRenderer implements IDisposable {
  35938. /** the original scene that will be rendered on top of */
  35939. originalScene: Scene;
  35940. private _pointerCaptures;
  35941. private _lastPointerEvents;
  35942. private static _DefaultUtilityLayer;
  35943. private static _DefaultKeepDepthUtilityLayer;
  35944. /**
  35945. * 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)
  35946. */
  35947. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  35948. /**
  35949. * 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)
  35950. */
  35951. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  35952. /**
  35953. * The scene that is rendered on top of the original scene
  35954. */
  35955. utilityLayerScene: Scene;
  35956. /**
  35957. * If the utility layer should automatically be rendered on top of existing scene
  35958. */
  35959. shouldRender: boolean;
  35960. /**
  35961. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  35962. */
  35963. onlyCheckPointerDownEvents: boolean;
  35964. /**
  35965. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  35966. */
  35967. processAllEvents: boolean;
  35968. /**
  35969. * Observable raised when the pointer move from the utility layer scene to the main scene
  35970. */
  35971. onPointerOutObservable: Observable<number>;
  35972. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  35973. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  35974. private _afterRenderObserver;
  35975. private _sceneDisposeObserver;
  35976. private _originalPointerObserver;
  35977. /**
  35978. * Instantiates a UtilityLayerRenderer
  35979. * @param originalScene the original scene that will be rendered on top of
  35980. */
  35981. constructor(
  35982. /** the original scene that will be rendered on top of */
  35983. originalScene: Scene);
  35984. private _notifyObservers;
  35985. /**
  35986. * Renders the utility layers scene on top of the original scene
  35987. */
  35988. render(): void;
  35989. /**
  35990. * Disposes of the renderer
  35991. */
  35992. dispose(): void;
  35993. private _updateCamera;
  35994. }
  35995. }
  35996. declare module BABYLON {
  35997. /**
  35998. * Class used to represent a sprite
  35999. * @see http://doc.babylonjs.com/babylon101/sprites
  36000. */
  36001. class Sprite {
  36002. /** defines the name */
  36003. name: string;
  36004. /** Gets or sets the current world position */
  36005. position: Vector3;
  36006. /** Gets or sets the main color */
  36007. color: Color4;
  36008. /** Gets or sets the width */
  36009. width: number;
  36010. /** Gets or sets the height */
  36011. height: number;
  36012. /** Gets or sets rotation angle */
  36013. angle: number;
  36014. /** Gets or sets the cell index in the sprite sheet */
  36015. cellIndex: number;
  36016. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  36017. invertU: number;
  36018. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  36019. invertV: number;
  36020. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  36021. disposeWhenFinishedAnimating: boolean;
  36022. /** Gets the list of attached animations */
  36023. animations: Animation[];
  36024. /** Gets or sets a boolean indicating if the sprite can be picked */
  36025. isPickable: boolean;
  36026. /**
  36027. * Gets or sets the associated action manager
  36028. */
  36029. actionManager: Nullable<ActionManager>;
  36030. private _animationStarted;
  36031. private _loopAnimation;
  36032. private _fromIndex;
  36033. private _toIndex;
  36034. private _delay;
  36035. private _direction;
  36036. private _manager;
  36037. private _time;
  36038. private _onAnimationEnd;
  36039. /**
  36040. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  36041. */
  36042. isVisible: boolean;
  36043. /**
  36044. * Gets or sets the sprite size
  36045. */
  36046. size: number;
  36047. /**
  36048. * Creates a new Sprite
  36049. * @param name defines the name
  36050. * @param manager defines the manager
  36051. */
  36052. constructor(
  36053. /** defines the name */
  36054. name: string, manager: ISpriteManager);
  36055. /**
  36056. * Starts an animation
  36057. * @param from defines the initial key
  36058. * @param to defines the end key
  36059. * @param loop defines if the animation must loop
  36060. * @param delay defines the start delay (in ms)
  36061. * @param onAnimationEnd defines a callback to call when animation ends
  36062. */
  36063. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  36064. /** Stops current animation (if any) */
  36065. stopAnimation(): void;
  36066. /** @hidden */
  36067. _animate(deltaTime: number): void;
  36068. /** Release associated resources */
  36069. dispose(): void;
  36070. }
  36071. }
  36072. declare module BABYLON {
  36073. /**
  36074. * Defines the minimum interface to fullfil in order to be a sprite manager.
  36075. */
  36076. interface ISpriteManager extends IDisposable {
  36077. /**
  36078. * Restricts the camera to viewing objects with the same layerMask.
  36079. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  36080. */
  36081. layerMask: number;
  36082. /**
  36083. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  36084. */
  36085. isPickable: boolean;
  36086. /**
  36087. * Specifies the rendering group id for this mesh (0 by default)
  36088. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  36089. */
  36090. renderingGroupId: number;
  36091. /**
  36092. * Defines the list of sprites managed by the manager.
  36093. */
  36094. sprites: Array<Sprite>;
  36095. /**
  36096. * Tests the intersection of a sprite with a specific ray.
  36097. * @param ray The ray we are sending to test the collision
  36098. * @param camera The camera space we are sending rays in
  36099. * @param predicate A predicate allowing excluding sprites from the list of object to test
  36100. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  36101. * @returns picking info or null.
  36102. */
  36103. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  36104. /**
  36105. * Renders the list of sprites on screen.
  36106. */
  36107. render(): void;
  36108. }
  36109. /**
  36110. * Class used to manage multiple sprites on the same spritesheet
  36111. * @see http://doc.babylonjs.com/babylon101/sprites
  36112. */
  36113. class SpriteManager implements ISpriteManager {
  36114. /** defines the manager's name */
  36115. name: string;
  36116. /** Gets the list of sprites */
  36117. sprites: Sprite[];
  36118. /** Gets or sets the rendering group id (0 by default) */
  36119. renderingGroupId: number;
  36120. /** Gets or sets camera layer mask */
  36121. layerMask: number;
  36122. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  36123. fogEnabled: boolean;
  36124. /** Gets or sets a boolean indicating if the sprites are pickable */
  36125. isPickable: boolean;
  36126. /** Defines the default width of a cell in the spritesheet */
  36127. cellWidth: number;
  36128. /** Defines the default height of a cell in the spritesheet */
  36129. cellHeight: number;
  36130. /**
  36131. * An event triggered when the manager is disposed.
  36132. */
  36133. onDisposeObservable: Observable<SpriteManager>;
  36134. private _onDisposeObserver;
  36135. /**
  36136. * Callback called when the manager is disposed
  36137. */
  36138. onDispose: () => void;
  36139. private _capacity;
  36140. private _spriteTexture;
  36141. private _epsilon;
  36142. private _scene;
  36143. private _vertexData;
  36144. private _buffer;
  36145. private _vertexBuffers;
  36146. private _indexBuffer;
  36147. private _effectBase;
  36148. private _effectFog;
  36149. /**
  36150. * Gets or sets the spritesheet texture
  36151. */
  36152. texture: Texture;
  36153. /**
  36154. * Creates a new sprite manager
  36155. * @param name defines the manager's name
  36156. * @param imgUrl defines the sprite sheet url
  36157. * @param capacity defines the maximum allowed number of sprites
  36158. * @param cellSize defines the size of a sprite cell
  36159. * @param scene defines the hosting scene
  36160. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  36161. * @param samplingMode defines the smapling mode to use with spritesheet
  36162. */
  36163. constructor(
  36164. /** defines the manager's name */
  36165. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  36166. private _appendSpriteVertex;
  36167. /**
  36168. * Intersects the sprites with a ray
  36169. * @param ray defines the ray to intersect with
  36170. * @param camera defines the current active camera
  36171. * @param predicate defines a predicate used to select candidate sprites
  36172. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  36173. * @returns null if no hit or a PickingInfo
  36174. */
  36175. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  36176. /**
  36177. * Render all child sprites
  36178. */
  36179. render(): void;
  36180. /**
  36181. * Release associated resources
  36182. */
  36183. dispose(): void;
  36184. }
  36185. }
  36186. declare module BABYLON {
  36187. interface Scene {
  36188. /** @hidden */
  36189. _pointerOverSprite: Nullable<Sprite>;
  36190. /** @hidden */
  36191. _pickedDownSprite: Nullable<Sprite>;
  36192. /** @hidden */
  36193. _tempSpritePickingRay: Nullable<Ray>;
  36194. /**
  36195. * All of the sprite managers added to this scene
  36196. * @see http://doc.babylonjs.com/babylon101/sprites
  36197. */
  36198. spriteManagers: Array<ISpriteManager>;
  36199. /**
  36200. * An event triggered when sprites rendering is about to start
  36201. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  36202. */
  36203. onBeforeSpritesRenderingObservable: Observable<Scene>;
  36204. /**
  36205. * An event triggered when sprites rendering is done
  36206. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  36207. */
  36208. onAfterSpritesRenderingObservable: Observable<Scene>;
  36209. /** @hidden */
  36210. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  36211. /** Launch a ray to try to pick a sprite in the scene
  36212. * @param x position on screen
  36213. * @param y position on screen
  36214. * @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
  36215. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  36216. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  36217. * @returns a PickingInfo
  36218. */
  36219. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  36220. /** Use the given ray to pick a sprite in the scene
  36221. * @param ray The ray (in world space) to use to pick meshes
  36222. * @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
  36223. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  36224. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  36225. * @returns a PickingInfo
  36226. */
  36227. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  36228. /**
  36229. * Force the sprite under the pointer
  36230. * @param sprite defines the sprite to use
  36231. */
  36232. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  36233. /**
  36234. * Gets the sprite under the pointer
  36235. * @returns a Sprite or null if no sprite is under the pointer
  36236. */
  36237. getPointerOverSprite(): Nullable<Sprite>;
  36238. }
  36239. /**
  36240. * Defines the sprite scene component responsible to manage sprites
  36241. * in a given scene.
  36242. */
  36243. class SpriteSceneComponent implements ISceneComponent {
  36244. /**
  36245. * The component name helpfull to identify the component in the list of scene components.
  36246. */
  36247. readonly name: string;
  36248. /**
  36249. * The scene the component belongs to.
  36250. */
  36251. scene: Scene;
  36252. /** @hidden */
  36253. private _spritePredicate;
  36254. /**
  36255. * Creates a new instance of the component for the given scene
  36256. * @param scene Defines the scene to register the component in
  36257. */
  36258. constructor(scene: Scene);
  36259. /**
  36260. * Registers the component in a given scene
  36261. */
  36262. register(): void;
  36263. /**
  36264. * Rebuilds the elements related to this component in case of
  36265. * context lost for instance.
  36266. */
  36267. rebuild(): void;
  36268. /**
  36269. * Disposes the component and the associated ressources.
  36270. */
  36271. dispose(): void;
  36272. private _pickSpriteButKeepRay;
  36273. private _pointerMove;
  36274. private _pointerDown;
  36275. private _pointerUp;
  36276. }
  36277. }
  36278. declare module BABYLON {
  36279. /**
  36280. * @hidden
  36281. **/
  36282. class _AlphaState {
  36283. private _isAlphaBlendDirty;
  36284. private _isBlendFunctionParametersDirty;
  36285. private _isBlendEquationParametersDirty;
  36286. private _isBlendConstantsDirty;
  36287. private _alphaBlend;
  36288. private _blendFunctionParameters;
  36289. private _blendEquationParameters;
  36290. private _blendConstants;
  36291. /**
  36292. * Initializes the state.
  36293. */
  36294. constructor();
  36295. readonly isDirty: boolean;
  36296. alphaBlend: boolean;
  36297. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  36298. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  36299. setAlphaEquationParameters(rgb: number, alpha: number): void;
  36300. reset(): void;
  36301. apply(gl: WebGLRenderingContext): void;
  36302. }
  36303. }
  36304. declare module BABYLON {
  36305. /**
  36306. * @hidden
  36307. **/
  36308. class _DepthCullingState {
  36309. private _isDepthTestDirty;
  36310. private _isDepthMaskDirty;
  36311. private _isDepthFuncDirty;
  36312. private _isCullFaceDirty;
  36313. private _isCullDirty;
  36314. private _isZOffsetDirty;
  36315. private _isFrontFaceDirty;
  36316. private _depthTest;
  36317. private _depthMask;
  36318. private _depthFunc;
  36319. private _cull;
  36320. private _cullFace;
  36321. private _zOffset;
  36322. private _frontFace;
  36323. /**
  36324. * Initializes the state.
  36325. */
  36326. constructor();
  36327. readonly isDirty: boolean;
  36328. zOffset: number;
  36329. cullFace: Nullable<number>;
  36330. cull: Nullable<boolean>;
  36331. depthFunc: Nullable<number>;
  36332. depthMask: boolean;
  36333. depthTest: boolean;
  36334. frontFace: Nullable<number>;
  36335. reset(): void;
  36336. apply(gl: WebGLRenderingContext): void;
  36337. }
  36338. }
  36339. declare module BABYLON {
  36340. /**
  36341. * @hidden
  36342. **/
  36343. class _StencilState {
  36344. private _isStencilTestDirty;
  36345. private _isStencilMaskDirty;
  36346. private _isStencilFuncDirty;
  36347. private _isStencilOpDirty;
  36348. private _stencilTest;
  36349. private _stencilMask;
  36350. private _stencilFunc;
  36351. private _stencilFuncRef;
  36352. private _stencilFuncMask;
  36353. private _stencilOpStencilFail;
  36354. private _stencilOpDepthFail;
  36355. private _stencilOpStencilDepthPass;
  36356. readonly isDirty: boolean;
  36357. stencilFunc: number;
  36358. stencilFuncRef: number;
  36359. stencilFuncMask: number;
  36360. stencilOpStencilFail: number;
  36361. stencilOpDepthFail: number;
  36362. stencilOpStencilDepthPass: number;
  36363. stencilMask: number;
  36364. stencilTest: boolean;
  36365. constructor();
  36366. reset(): void;
  36367. apply(gl: WebGLRenderingContext): void;
  36368. }
  36369. }
  36370. declare module BABYLON {
  36371. /**
  36372. * Class used to evalaute queries containing `and` and `or` operators
  36373. */
  36374. class AndOrNotEvaluator {
  36375. /**
  36376. * Evaluate a query
  36377. * @param query defines the query to evaluate
  36378. * @param evaluateCallback defines the callback used to filter result
  36379. * @returns true if the query matches
  36380. */
  36381. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  36382. private static _HandleParenthesisContent;
  36383. private static _SimplifyNegation;
  36384. }
  36385. }
  36386. declare module BABYLON {
  36387. /**
  36388. * Defines the list of states available for a task inside a AssetsManager
  36389. */
  36390. enum AssetTaskState {
  36391. /**
  36392. * Initialization
  36393. */
  36394. INIT = 0,
  36395. /**
  36396. * Running
  36397. */
  36398. RUNNING = 1,
  36399. /**
  36400. * Done
  36401. */
  36402. DONE = 2,
  36403. /**
  36404. * Error
  36405. */
  36406. ERROR = 3
  36407. }
  36408. /**
  36409. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  36410. */
  36411. abstract class AbstractAssetTask {
  36412. /**
  36413. * Task name
  36414. */ name: string;
  36415. /**
  36416. * Callback called when the task is successful
  36417. */
  36418. onSuccess: (task: any) => void;
  36419. /**
  36420. * Callback called when the task is not successful
  36421. */
  36422. onError: (task: any, message?: string, exception?: any) => void;
  36423. /**
  36424. * Creates a new AssetsManager
  36425. * @param name defines the name of the task
  36426. */
  36427. constructor(
  36428. /**
  36429. * Task name
  36430. */ name: string);
  36431. private _isCompleted;
  36432. private _taskState;
  36433. private _errorObject;
  36434. /**
  36435. * Get if the task is completed
  36436. */
  36437. readonly isCompleted: boolean;
  36438. /**
  36439. * Gets the current state of the task
  36440. */
  36441. readonly taskState: AssetTaskState;
  36442. /**
  36443. * Gets the current error object (if task is in error)
  36444. */
  36445. readonly errorObject: {
  36446. message?: string;
  36447. exception?: any;
  36448. };
  36449. /**
  36450. * Internal only
  36451. * @hidden
  36452. */
  36453. _setErrorObject(message?: string, exception?: any): void;
  36454. /**
  36455. * Execute the current task
  36456. * @param scene defines the scene where you want your assets to be loaded
  36457. * @param onSuccess is a callback called when the task is successfully executed
  36458. * @param onError is a callback called if an error occurs
  36459. */
  36460. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  36461. /**
  36462. * Execute the current task
  36463. * @param scene defines the scene where you want your assets to be loaded
  36464. * @param onSuccess is a callback called when the task is successfully executed
  36465. * @param onError is a callback called if an error occurs
  36466. */
  36467. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  36468. /**
  36469. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  36470. * This can be used with failed tasks that have the reason for failure fixed.
  36471. */
  36472. reset(): void;
  36473. private onErrorCallback;
  36474. private onDoneCallback;
  36475. }
  36476. /**
  36477. * Define the interface used by progress events raised during assets loading
  36478. */
  36479. interface IAssetsProgressEvent {
  36480. /**
  36481. * Defines the number of remaining tasks to process
  36482. */
  36483. remainingCount: number;
  36484. /**
  36485. * Defines the total number of tasks
  36486. */
  36487. totalCount: number;
  36488. /**
  36489. * Defines the task that was just processed
  36490. */
  36491. task: AbstractAssetTask;
  36492. }
  36493. /**
  36494. * Class used to share progress information about assets loading
  36495. */
  36496. class AssetsProgressEvent implements IAssetsProgressEvent {
  36497. /**
  36498. * Defines the number of remaining tasks to process
  36499. */
  36500. remainingCount: number;
  36501. /**
  36502. * Defines the total number of tasks
  36503. */
  36504. totalCount: number;
  36505. /**
  36506. * Defines the task that was just processed
  36507. */
  36508. task: AbstractAssetTask;
  36509. /**
  36510. * Creates a AssetsProgressEvent
  36511. * @param remainingCount defines the number of remaining tasks to process
  36512. * @param totalCount defines the total number of tasks
  36513. * @param task defines the task that was just processed
  36514. */
  36515. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  36516. }
  36517. /**
  36518. * Define a task used by AssetsManager to load meshes
  36519. */
  36520. class MeshAssetTask extends AbstractAssetTask {
  36521. /**
  36522. * Defines the name of the task
  36523. */
  36524. name: string;
  36525. /**
  36526. * Defines the list of mesh's names you want to load
  36527. */
  36528. meshesNames: any;
  36529. /**
  36530. * Defines the root url to use as a base to load your meshes and associated resources
  36531. */
  36532. rootUrl: string;
  36533. /**
  36534. * Defines the filename of the scene to load from
  36535. */
  36536. sceneFilename: string;
  36537. /**
  36538. * Gets the list of loaded meshes
  36539. */
  36540. loadedMeshes: Array<AbstractMesh>;
  36541. /**
  36542. * Gets the list of loaded particle systems
  36543. */
  36544. loadedParticleSystems: Array<IParticleSystem>;
  36545. /**
  36546. * Gets the list of loaded skeletons
  36547. */
  36548. loadedSkeletons: Array<Skeleton>;
  36549. /**
  36550. * Callback called when the task is successful
  36551. */
  36552. onSuccess: (task: MeshAssetTask) => void;
  36553. /**
  36554. * Callback called when the task is successful
  36555. */
  36556. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  36557. /**
  36558. * Creates a new MeshAssetTask
  36559. * @param name defines the name of the task
  36560. * @param meshesNames defines the list of mesh's names you want to load
  36561. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  36562. * @param sceneFilename defines the filename of the scene to load from
  36563. */
  36564. constructor(
  36565. /**
  36566. * Defines the name of the task
  36567. */
  36568. name: string,
  36569. /**
  36570. * Defines the list of mesh's names you want to load
  36571. */
  36572. meshesNames: any,
  36573. /**
  36574. * Defines the root url to use as a base to load your meshes and associated resources
  36575. */
  36576. rootUrl: string,
  36577. /**
  36578. * Defines the filename of the scene to load from
  36579. */
  36580. sceneFilename: string);
  36581. /**
  36582. * Execute the current task
  36583. * @param scene defines the scene where you want your assets to be loaded
  36584. * @param onSuccess is a callback called when the task is successfully executed
  36585. * @param onError is a callback called if an error occurs
  36586. */
  36587. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  36588. }
  36589. /**
  36590. * Define a task used by AssetsManager to load text content
  36591. */
  36592. class TextFileAssetTask extends AbstractAssetTask {
  36593. /**
  36594. * Defines the name of the task
  36595. */
  36596. name: string;
  36597. /**
  36598. * Defines the location of the file to load
  36599. */
  36600. url: string;
  36601. /**
  36602. * Gets the loaded text string
  36603. */
  36604. text: string;
  36605. /**
  36606. * Callback called when the task is successful
  36607. */
  36608. onSuccess: (task: TextFileAssetTask) => void;
  36609. /**
  36610. * Callback called when the task is successful
  36611. */
  36612. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  36613. /**
  36614. * Creates a new TextFileAssetTask object
  36615. * @param name defines the name of the task
  36616. * @param url defines the location of the file to load
  36617. */
  36618. constructor(
  36619. /**
  36620. * Defines the name of the task
  36621. */
  36622. name: string,
  36623. /**
  36624. * Defines the location of the file to load
  36625. */
  36626. url: string);
  36627. /**
  36628. * Execute the current task
  36629. * @param scene defines the scene where you want your assets to be loaded
  36630. * @param onSuccess is a callback called when the task is successfully executed
  36631. * @param onError is a callback called if an error occurs
  36632. */
  36633. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  36634. }
  36635. /**
  36636. * Define a task used by AssetsManager to load binary data
  36637. */
  36638. class BinaryFileAssetTask extends AbstractAssetTask {
  36639. /**
  36640. * Defines the name of the task
  36641. */
  36642. name: string;
  36643. /**
  36644. * Defines the location of the file to load
  36645. */
  36646. url: string;
  36647. /**
  36648. * Gets the lodaded data (as an array buffer)
  36649. */
  36650. data: ArrayBuffer;
  36651. /**
  36652. * Callback called when the task is successful
  36653. */
  36654. onSuccess: (task: BinaryFileAssetTask) => void;
  36655. /**
  36656. * Callback called when the task is successful
  36657. */
  36658. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  36659. /**
  36660. * Creates a new BinaryFileAssetTask object
  36661. * @param name defines the name of the new task
  36662. * @param url defines the location of the file to load
  36663. */
  36664. constructor(
  36665. /**
  36666. * Defines the name of the task
  36667. */
  36668. name: string,
  36669. /**
  36670. * Defines the location of the file to load
  36671. */
  36672. url: string);
  36673. /**
  36674. * Execute the current task
  36675. * @param scene defines the scene where you want your assets to be loaded
  36676. * @param onSuccess is a callback called when the task is successfully executed
  36677. * @param onError is a callback called if an error occurs
  36678. */
  36679. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  36680. }
  36681. /**
  36682. * Define a task used by AssetsManager to load images
  36683. */
  36684. class ImageAssetTask extends AbstractAssetTask {
  36685. /**
  36686. * Defines the name of the task
  36687. */
  36688. name: string;
  36689. /**
  36690. * Defines the location of the image to load
  36691. */
  36692. url: string;
  36693. /**
  36694. * Gets the loaded images
  36695. */
  36696. image: HTMLImageElement;
  36697. /**
  36698. * Callback called when the task is successful
  36699. */
  36700. onSuccess: (task: ImageAssetTask) => void;
  36701. /**
  36702. * Callback called when the task is successful
  36703. */
  36704. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  36705. /**
  36706. * Creates a new ImageAssetTask
  36707. * @param name defines the name of the task
  36708. * @param url defines the location of the image to load
  36709. */
  36710. constructor(
  36711. /**
  36712. * Defines the name of the task
  36713. */
  36714. name: string,
  36715. /**
  36716. * Defines the location of the image to load
  36717. */
  36718. url: string);
  36719. /**
  36720. * Execute the current task
  36721. * @param scene defines the scene where you want your assets to be loaded
  36722. * @param onSuccess is a callback called when the task is successfully executed
  36723. * @param onError is a callback called if an error occurs
  36724. */
  36725. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  36726. }
  36727. /**
  36728. * Defines the interface used by texture loading tasks
  36729. */
  36730. interface ITextureAssetTask<TEX extends BaseTexture> {
  36731. /**
  36732. * Gets the loaded texture
  36733. */
  36734. texture: TEX;
  36735. }
  36736. /**
  36737. * Define a task used by AssetsManager to load 2D textures
  36738. */
  36739. class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  36740. /**
  36741. * Defines the name of the task
  36742. */
  36743. name: string;
  36744. /**
  36745. * Defines the location of the file to load
  36746. */
  36747. url: string;
  36748. /**
  36749. * Defines if mipmap should not be generated (default is false)
  36750. */
  36751. noMipmap?: boolean | undefined;
  36752. /**
  36753. * Defines if texture must be inverted on Y axis (default is false)
  36754. */
  36755. invertY?: boolean | undefined;
  36756. /**
  36757. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  36758. */
  36759. samplingMode: number;
  36760. /**
  36761. * Gets the loaded texture
  36762. */
  36763. texture: Texture;
  36764. /**
  36765. * Callback called when the task is successful
  36766. */
  36767. onSuccess: (task: TextureAssetTask) => void;
  36768. /**
  36769. * Callback called when the task is successful
  36770. */
  36771. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  36772. /**
  36773. * Creates a new TextureAssetTask object
  36774. * @param name defines the name of the task
  36775. * @param url defines the location of the file to load
  36776. * @param noMipmap defines if mipmap should not be generated (default is false)
  36777. * @param invertY defines if texture must be inverted on Y axis (default is false)
  36778. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  36779. */
  36780. constructor(
  36781. /**
  36782. * Defines the name of the task
  36783. */
  36784. name: string,
  36785. /**
  36786. * Defines the location of the file to load
  36787. */
  36788. url: string,
  36789. /**
  36790. * Defines if mipmap should not be generated (default is false)
  36791. */
  36792. noMipmap?: boolean | undefined,
  36793. /**
  36794. * Defines if texture must be inverted on Y axis (default is false)
  36795. */
  36796. invertY?: boolean | undefined,
  36797. /**
  36798. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  36799. */
  36800. samplingMode?: number);
  36801. /**
  36802. * Execute the current task
  36803. * @param scene defines the scene where you want your assets to be loaded
  36804. * @param onSuccess is a callback called when the task is successfully executed
  36805. * @param onError is a callback called if an error occurs
  36806. */
  36807. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  36808. }
  36809. /**
  36810. * Define a task used by AssetsManager to load cube textures
  36811. */
  36812. class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  36813. /**
  36814. * Defines the name of the task
  36815. */
  36816. name: string;
  36817. /**
  36818. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  36819. */
  36820. url: string;
  36821. /**
  36822. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  36823. */
  36824. extensions?: string[] | undefined;
  36825. /**
  36826. * Defines if mipmaps should not be generated (default is false)
  36827. */
  36828. noMipmap?: boolean | undefined;
  36829. /**
  36830. * Defines the explicit list of files (undefined by default)
  36831. */
  36832. files?: string[] | undefined;
  36833. /**
  36834. * Gets the loaded texture
  36835. */
  36836. texture: CubeTexture;
  36837. /**
  36838. * Callback called when the task is successful
  36839. */
  36840. onSuccess: (task: CubeTextureAssetTask) => void;
  36841. /**
  36842. * Callback called when the task is successful
  36843. */
  36844. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  36845. /**
  36846. * Creates a new CubeTextureAssetTask
  36847. * @param name defines the name of the task
  36848. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  36849. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  36850. * @param noMipmap defines if mipmaps should not be generated (default is false)
  36851. * @param files defines the explicit list of files (undefined by default)
  36852. */
  36853. constructor(
  36854. /**
  36855. * Defines the name of the task
  36856. */
  36857. name: string,
  36858. /**
  36859. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  36860. */
  36861. url: string,
  36862. /**
  36863. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  36864. */
  36865. extensions?: string[] | undefined,
  36866. /**
  36867. * Defines if mipmaps should not be generated (default is false)
  36868. */
  36869. noMipmap?: boolean | undefined,
  36870. /**
  36871. * Defines the explicit list of files (undefined by default)
  36872. */
  36873. files?: string[] | undefined);
  36874. /**
  36875. * Execute the current task
  36876. * @param scene defines the scene where you want your assets to be loaded
  36877. * @param onSuccess is a callback called when the task is successfully executed
  36878. * @param onError is a callback called if an error occurs
  36879. */
  36880. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  36881. }
  36882. /**
  36883. * Define a task used by AssetsManager to load HDR cube textures
  36884. */
  36885. class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  36886. /**
  36887. * Defines the name of the task
  36888. */
  36889. name: string;
  36890. /**
  36891. * Defines the location of the file to load
  36892. */
  36893. url: string;
  36894. /**
  36895. * Defines the desired size (the more it increases the longer the generation will be)
  36896. */
  36897. size: number;
  36898. /**
  36899. * Defines if mipmaps should not be generated (default is false)
  36900. */
  36901. noMipmap: boolean;
  36902. /**
  36903. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  36904. */
  36905. generateHarmonics: boolean;
  36906. /**
  36907. * 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)
  36908. */
  36909. gammaSpace: boolean;
  36910. /**
  36911. * Internal Use Only
  36912. */
  36913. reserved: boolean;
  36914. /**
  36915. * Gets the loaded texture
  36916. */
  36917. texture: HDRCubeTexture;
  36918. /**
  36919. * Callback called when the task is successful
  36920. */
  36921. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  36922. /**
  36923. * Callback called when the task is successful
  36924. */
  36925. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  36926. /**
  36927. * Creates a new HDRCubeTextureAssetTask object
  36928. * @param name defines the name of the task
  36929. * @param url defines the location of the file to load
  36930. * @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.
  36931. * @param noMipmap defines if mipmaps should not be generated (default is false)
  36932. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  36933. * @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)
  36934. * @param reserved Internal use only
  36935. */
  36936. constructor(
  36937. /**
  36938. * Defines the name of the task
  36939. */
  36940. name: string,
  36941. /**
  36942. * Defines the location of the file to load
  36943. */
  36944. url: string,
  36945. /**
  36946. * Defines the desired size (the more it increases the longer the generation will be)
  36947. */
  36948. size: number,
  36949. /**
  36950. * Defines if mipmaps should not be generated (default is false)
  36951. */
  36952. noMipmap?: boolean,
  36953. /**
  36954. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  36955. */
  36956. generateHarmonics?: boolean,
  36957. /**
  36958. * 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)
  36959. */
  36960. gammaSpace?: boolean,
  36961. /**
  36962. * Internal Use Only
  36963. */
  36964. reserved?: boolean);
  36965. /**
  36966. * Execute the current task
  36967. * @param scene defines the scene where you want your assets to be loaded
  36968. * @param onSuccess is a callback called when the task is successfully executed
  36969. * @param onError is a callback called if an error occurs
  36970. */
  36971. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  36972. }
  36973. /**
  36974. * This class can be used to easily import assets into a scene
  36975. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  36976. */
  36977. class AssetsManager {
  36978. private _scene;
  36979. private _isLoading;
  36980. protected _tasks: AbstractAssetTask[];
  36981. protected _waitingTasksCount: number;
  36982. protected _totalTasksCount: number;
  36983. /**
  36984. * Callback called when all tasks are processed
  36985. */
  36986. onFinish: (tasks: AbstractAssetTask[]) => void;
  36987. /**
  36988. * Callback called when a task is successful
  36989. */
  36990. onTaskSuccess: (task: AbstractAssetTask) => void;
  36991. /**
  36992. * Callback called when a task had an error
  36993. */
  36994. onTaskError: (task: AbstractAssetTask) => void;
  36995. /**
  36996. * Callback called when a task is done (whatever the result is)
  36997. */
  36998. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  36999. /**
  37000. * Observable called when all tasks are processed
  37001. */
  37002. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  37003. /**
  37004. * Observable called when a task had an error
  37005. */
  37006. onTaskErrorObservable: Observable<AbstractAssetTask>;
  37007. /**
  37008. * Observable called when a task is successful
  37009. */
  37010. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  37011. /**
  37012. * Observable called when a task is done (whatever the result is)
  37013. */
  37014. onProgressObservable: Observable<IAssetsProgressEvent>;
  37015. /**
  37016. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  37017. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37018. */
  37019. useDefaultLoadingScreen: boolean;
  37020. /**
  37021. * Creates a new AssetsManager
  37022. * @param scene defines the scene to work on
  37023. */
  37024. constructor(scene: Scene);
  37025. /**
  37026. * Add a MeshAssetTask to the list of active tasks
  37027. * @param taskName defines the name of the new task
  37028. * @param meshesNames defines the name of meshes to load
  37029. * @param rootUrl defines the root url to use to locate files
  37030. * @param sceneFilename defines the filename of the scene file
  37031. * @returns a new MeshAssetTask object
  37032. */
  37033. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  37034. /**
  37035. * Add a TextFileAssetTask to the list of active tasks
  37036. * @param taskName defines the name of the new task
  37037. * @param url defines the url of the file to load
  37038. * @returns a new TextFileAssetTask object
  37039. */
  37040. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  37041. /**
  37042. * Add a BinaryFileAssetTask to the list of active tasks
  37043. * @param taskName defines the name of the new task
  37044. * @param url defines the url of the file to load
  37045. * @returns a new BinaryFileAssetTask object
  37046. */
  37047. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  37048. /**
  37049. * Add a ImageAssetTask to the list of active tasks
  37050. * @param taskName defines the name of the new task
  37051. * @param url defines the url of the file to load
  37052. * @returns a new ImageAssetTask object
  37053. */
  37054. addImageTask(taskName: string, url: string): ImageAssetTask;
  37055. /**
  37056. * Add a TextureAssetTask to the list of active tasks
  37057. * @param taskName defines the name of the new task
  37058. * @param url defines the url of the file to load
  37059. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  37060. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  37061. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  37062. * @returns a new TextureAssetTask object
  37063. */
  37064. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  37065. /**
  37066. * Add a CubeTextureAssetTask to the list of active tasks
  37067. * @param taskName defines the name of the new task
  37068. * @param url defines the url of the file to load
  37069. * @param extensions defines the extension to use to load the cube map (can be null)
  37070. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  37071. * @param files defines the list of files to load (can be null)
  37072. * @returns a new CubeTextureAssetTask object
  37073. */
  37074. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  37075. /**
  37076. *
  37077. * Add a HDRCubeTextureAssetTask to the list of active tasks
  37078. * @param taskName defines the name of the new task
  37079. * @param url defines the url of the file to load
  37080. * @param size defines the size you want for the cubemap (can be null)
  37081. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  37082. * @param generateHarmonics defines if you want to automatically generate (true by default)
  37083. * @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)
  37084. * @param reserved Internal use only
  37085. * @returns a new HDRCubeTextureAssetTask object
  37086. */
  37087. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  37088. /**
  37089. * Remove a task from the assets manager.
  37090. * @param task the task to remove
  37091. */
  37092. removeTask(task: AbstractAssetTask): void;
  37093. private _decreaseWaitingTasksCount;
  37094. private _runTask;
  37095. /**
  37096. * Reset the AssetsManager and remove all tasks
  37097. * @return the current instance of the AssetsManager
  37098. */
  37099. reset(): AssetsManager;
  37100. /**
  37101. * Start the loading process
  37102. * @return the current instance of the AssetsManager
  37103. */
  37104. load(): AssetsManager;
  37105. }
  37106. }
  37107. declare module BABYLON {
  37108. /**
  37109. * Class used to enable access to IndexedDB
  37110. * @see @https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API
  37111. */
  37112. class Database {
  37113. private callbackManifestChecked;
  37114. private currentSceneUrl;
  37115. private db;
  37116. private _enableSceneOffline;
  37117. private _enableTexturesOffline;
  37118. private manifestVersionFound;
  37119. private mustUpdateRessources;
  37120. private hasReachedQuota;
  37121. private isSupported;
  37122. private idbFactory;
  37123. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  37124. static IsUASupportingBlobStorage: boolean;
  37125. /** Gets a boolean indicating if Database storate is enabled */
  37126. static IDBStorageEnabled: boolean;
  37127. /**
  37128. * Gets a boolean indicating if scene must be saved in the database
  37129. */
  37130. readonly enableSceneOffline: boolean;
  37131. /**
  37132. * Gets a boolean indicating if textures must be saved in the database
  37133. */
  37134. readonly enableTexturesOffline: boolean;
  37135. /**
  37136. * Creates a new Database
  37137. * @param urlToScene defines the url to load the scene
  37138. * @param callbackManifestChecked defines the callback to use when manifest is checked
  37139. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  37140. */
  37141. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  37142. private static _ParseURL;
  37143. private static _ReturnFullUrlLocation;
  37144. private _checkManifestFile;
  37145. /**
  37146. * Open the database and make it available
  37147. * @param successCallback defines the callback to call on success
  37148. * @param errorCallback defines the callback to call on error
  37149. */
  37150. openAsync(successCallback: () => void, errorCallback: () => void): void;
  37151. /**
  37152. * Loads an image from the database
  37153. * @param url defines the url to load from
  37154. * @param image defines the target DOM image
  37155. */
  37156. loadImageFromDB(url: string, image: HTMLImageElement): void;
  37157. private _loadImageFromDBAsync;
  37158. private _saveImageIntoDBAsync;
  37159. private _checkVersionFromDB;
  37160. private _loadVersionFromDBAsync;
  37161. private _saveVersionIntoDBAsync;
  37162. /**
  37163. * Loads a file from database
  37164. * @param url defines the URL to load from
  37165. * @param sceneLoaded defines a callback to call on success
  37166. * @param progressCallBack defines a callback to call when progress changed
  37167. * @param errorCallback defines a callback to call on error
  37168. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  37169. */
  37170. loadFileFromDB(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  37171. private _loadFileFromDBAsync;
  37172. private _saveFileIntoDBAsync;
  37173. }
  37174. }
  37175. declare module BABYLON {
  37176. /**
  37177. * Direct draw surface info
  37178. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  37179. */
  37180. interface DDSInfo {
  37181. /**
  37182. * Width of the texture
  37183. */
  37184. width: number;
  37185. /**
  37186. * Width of the texture
  37187. */
  37188. height: number;
  37189. /**
  37190. * Number of Mipmaps for the texture
  37191. * @see https://en.wikipedia.org/wiki/Mipmap
  37192. */
  37193. mipmapCount: number;
  37194. /**
  37195. * If the textures format is a known fourCC format
  37196. * @see https://www.fourcc.org/
  37197. */
  37198. isFourCC: boolean;
  37199. /**
  37200. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  37201. */
  37202. isRGB: boolean;
  37203. /**
  37204. * If the texture is a lumincance format
  37205. */
  37206. isLuminance: boolean;
  37207. /**
  37208. * If this is a cube texture
  37209. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  37210. */
  37211. isCube: boolean;
  37212. /**
  37213. * If the texture is a compressed format eg. FOURCC_DXT1
  37214. */
  37215. isCompressed: boolean;
  37216. /**
  37217. * The dxgiFormat of the texture
  37218. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  37219. */
  37220. dxgiFormat: number;
  37221. /**
  37222. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  37223. */
  37224. textureType: number;
  37225. /**
  37226. * Sphericle polynomial created for the dds texture
  37227. */
  37228. sphericalPolynomial?: SphericalPolynomial;
  37229. }
  37230. /**
  37231. * Class used to provide DDS decompression tools
  37232. */
  37233. class DDSTools {
  37234. /**
  37235. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  37236. */
  37237. static StoreLODInAlphaChannel: boolean;
  37238. /**
  37239. * Gets DDS information from an array buffer
  37240. * @param arrayBuffer defines the array buffer to read data from
  37241. * @returns the DDS information
  37242. */
  37243. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  37244. private static _FloatView;
  37245. private static _Int32View;
  37246. private static _ToHalfFloat;
  37247. private static _FromHalfFloat;
  37248. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  37249. private static _GetHalfFloatRGBAArrayBuffer;
  37250. private static _GetFloatRGBAArrayBuffer;
  37251. private static _GetFloatAsUIntRGBAArrayBuffer;
  37252. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  37253. private static _GetRGBAArrayBuffer;
  37254. private static _ExtractLongWordOrder;
  37255. private static _GetRGBArrayBuffer;
  37256. private static _GetLuminanceArrayBuffer;
  37257. /**
  37258. * Uploads DDS Levels to a Babylon Texture
  37259. * @hidden
  37260. */
  37261. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  37262. }
  37263. }
  37264. declare module BABYLON {
  37265. function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  37266. function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37267. function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37268. function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37269. function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37270. function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37271. function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37272. function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37273. function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37274. function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37275. function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37276. function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37277. /**
  37278. * Decorator used to define property that can be serialized as reference to a camera
  37279. * @param sourceName defines the name of the property to decorate
  37280. */
  37281. function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37282. /**
  37283. * Class used to help serialization objects
  37284. */
  37285. class SerializationHelper {
  37286. /**
  37287. * Static function used to serialized a specific entity
  37288. * @param entity defines the entity to serialize
  37289. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  37290. * @returns a JSON compatible object representing the serialization of the entity
  37291. */
  37292. static Serialize<T>(entity: T, serializationObject?: any): any;
  37293. /**
  37294. * Creates a new entity from a serialization data object
  37295. * @param creationFunction defines a function used to instanciated the new entity
  37296. * @param source defines the source serialization data
  37297. * @param scene defines the hosting scene
  37298. * @param rootUrl defines the root url for resources
  37299. * @returns a new entity
  37300. */
  37301. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  37302. /**
  37303. * Clones an object
  37304. * @param creationFunction defines the function used to instanciate the new object
  37305. * @param source defines the source object
  37306. * @returns the cloned object
  37307. */
  37308. static Clone<T>(creationFunction: () => T, source: T): T;
  37309. /**
  37310. * Instanciates a new object based on a source one (some data will be shared between both object)
  37311. * @param creationFunction defines the function used to instanciate the new object
  37312. * @param source defines the source object
  37313. * @returns the new object
  37314. */
  37315. static Instanciate<T>(creationFunction: () => T, source: T): T;
  37316. }
  37317. }
  37318. declare module BABYLON {
  37319. /**
  37320. * Wrapper class for promise with external resolve and reject.
  37321. */
  37322. class Deferred<T> {
  37323. /**
  37324. * The promise associated with this deferred object.
  37325. */
  37326. readonly promise: Promise<T>;
  37327. private _resolve;
  37328. private _reject;
  37329. /**
  37330. * The resolve method of the promise associated with this deferred object.
  37331. */
  37332. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  37333. /**
  37334. * The reject method of the promise associated with this deferred object.
  37335. */
  37336. readonly reject: (reason?: any) => void;
  37337. /**
  37338. * Constructor for this deferred object.
  37339. */
  37340. constructor();
  37341. }
  37342. }
  37343. declare module BABYLON {
  37344. /**
  37345. * Raw texture data and descriptor sufficient for WebGL texture upload
  37346. */
  37347. interface EnvironmentTextureInfo {
  37348. /**
  37349. * Version of the environment map
  37350. */
  37351. version: number;
  37352. /**
  37353. * Width of image
  37354. */
  37355. width: number;
  37356. /**
  37357. * Irradiance information stored in the file.
  37358. */
  37359. irradiance: any;
  37360. /**
  37361. * Specular information stored in the file.
  37362. */
  37363. specular: any;
  37364. }
  37365. /**
  37366. * Sets of helpers addressing the serialization and deserialization of environment texture
  37367. * stored in a BabylonJS env file.
  37368. * Those files are usually stored as .env files.
  37369. */
  37370. class EnvironmentTextureTools {
  37371. /**
  37372. * Magic number identifying the env file.
  37373. */
  37374. private static _MagicBytes;
  37375. /**
  37376. * Gets the environment info from an env file.
  37377. * @param data The array buffer containing the .env bytes.
  37378. * @returns the environment file info (the json header) if successfully parsed.
  37379. */
  37380. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  37381. /**
  37382. * Creates an environment texture from a loaded cube texture.
  37383. * @param texture defines the cube texture to convert in env file
  37384. * @return a promise containing the environment data if succesfull.
  37385. */
  37386. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  37387. /**
  37388. * Creates a JSON representation of the spherical data.
  37389. * @param texture defines the texture containing the polynomials
  37390. * @return the JSON representation of the spherical info
  37391. */
  37392. private static _CreateEnvTextureIrradiance;
  37393. /**
  37394. * Uploads the texture info contained in the env file to the GPU.
  37395. * @param texture defines the internal texture to upload to
  37396. * @param arrayBuffer defines the buffer cotaining the data to load
  37397. * @param info defines the texture info retrieved through the GetEnvInfo method
  37398. * @returns a promise
  37399. */
  37400. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  37401. /**
  37402. * Uploads the levels of image data to the GPU.
  37403. * @param texture defines the internal texture to upload to
  37404. * @param imageData defines the array buffer views of image data [mipmap][face]
  37405. * @returns a promise
  37406. */
  37407. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  37408. /**
  37409. * Uploads spherical polynomials information to the texture.
  37410. * @param texture defines the texture we are trying to upload the information to
  37411. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  37412. */
  37413. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  37414. }
  37415. }
  37416. declare module BABYLON {
  37417. /**
  37418. * Class used to help managing file picking and drag'n'drop
  37419. */
  37420. class FilesInput {
  37421. /**
  37422. * List of files ready to be loaded
  37423. */
  37424. static FilesToLoad: {
  37425. [key: string]: File;
  37426. };
  37427. /**
  37428. * Callback called when a file is processed
  37429. */
  37430. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  37431. private _engine;
  37432. private _currentScene;
  37433. private _sceneLoadedCallback;
  37434. private _progressCallback;
  37435. private _additionalRenderLoopLogicCallback;
  37436. private _textureLoadingCallback;
  37437. private _startingProcessingFilesCallback;
  37438. private _onReloadCallback;
  37439. private _errorCallback;
  37440. private _elementToMonitor;
  37441. private _sceneFileToLoad;
  37442. private _filesToLoad;
  37443. /**
  37444. * Creates a new FilesInput
  37445. * @param engine defines the rendering engine
  37446. * @param scene defines the hosting scene
  37447. * @param sceneLoadedCallback callback called when scene is loaded
  37448. * @param progressCallback callback called to track progress
  37449. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  37450. * @param textureLoadingCallback callback called when a texture is loading
  37451. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  37452. * @param onReloadCallback callback called when a reload is requested
  37453. * @param errorCallback callback call if an error occurs
  37454. */
  37455. 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);
  37456. private _dragEnterHandler;
  37457. private _dragOverHandler;
  37458. private _dropHandler;
  37459. /**
  37460. * Calls this function to listen to drag'n'drop events on a specific DOM element
  37461. * @param elementToMonitor defines the DOM element to track
  37462. */
  37463. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  37464. /**
  37465. * Release all associated resources
  37466. */
  37467. dispose(): void;
  37468. private renderFunction;
  37469. private drag;
  37470. private drop;
  37471. private _traverseFolder;
  37472. private _processFiles;
  37473. /**
  37474. * Load files from a drop event
  37475. * @param event defines the drop event to use as source
  37476. */
  37477. loadFiles(event: any): void;
  37478. private _processReload;
  37479. /**
  37480. * Reload the current scene from the loaded files
  37481. */
  37482. reload(): void;
  37483. }
  37484. }
  37485. declare module BABYLON {
  37486. /**
  37487. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  37488. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  37489. */
  37490. class KhronosTextureContainer {
  37491. /** contents of the KTX container file */
  37492. arrayBuffer: any;
  37493. private static HEADER_LEN;
  37494. private static COMPRESSED_2D;
  37495. private static COMPRESSED_3D;
  37496. private static TEX_2D;
  37497. private static TEX_3D;
  37498. /**
  37499. * Gets the openGL type
  37500. */
  37501. glType: number;
  37502. /**
  37503. * Gets the openGL type size
  37504. */
  37505. glTypeSize: number;
  37506. /**
  37507. * Gets the openGL format
  37508. */
  37509. glFormat: number;
  37510. /**
  37511. * Gets the openGL internal format
  37512. */
  37513. glInternalFormat: number;
  37514. /**
  37515. * Gets the base internal format
  37516. */
  37517. glBaseInternalFormat: number;
  37518. /**
  37519. * Gets image width in pixel
  37520. */
  37521. pixelWidth: number;
  37522. /**
  37523. * Gets image height in pixel
  37524. */
  37525. pixelHeight: number;
  37526. /**
  37527. * Gets image depth in pixels
  37528. */
  37529. pixelDepth: number;
  37530. /**
  37531. * Gets the number of array elements
  37532. */
  37533. numberOfArrayElements: number;
  37534. /**
  37535. * Gets the number of faces
  37536. */
  37537. numberOfFaces: number;
  37538. /**
  37539. * Gets the number of mipmap levels
  37540. */
  37541. numberOfMipmapLevels: number;
  37542. /**
  37543. * Gets the bytes of key value data
  37544. */
  37545. bytesOfKeyValueData: number;
  37546. /**
  37547. * Gets the load type
  37548. */
  37549. loadType: number;
  37550. /**
  37551. * Creates a new KhronosTextureContainer
  37552. * @param arrayBuffer contents of the KTX container file
  37553. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  37554. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  37555. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  37556. */
  37557. constructor(
  37558. /** contents of the KTX container file */
  37559. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  37560. /**
  37561. * Revert the endianness of a value.
  37562. * Not as fast hardware based, but will probably never need to use
  37563. * @param val defines the value to convert
  37564. * @returns the new value
  37565. */
  37566. switchEndianness(val: number): number;
  37567. /**
  37568. * Uploads KTX content to a Babylon Texture.
  37569. * It is assumed that the texture has already been created & is currently bound
  37570. * @hidden
  37571. */
  37572. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  37573. private _upload2DCompressedLevels;
  37574. }
  37575. }
  37576. declare module BABYLON {
  37577. /**
  37578. * A class serves as a medium between the observable and its observers
  37579. */
  37580. class EventState {
  37581. /**
  37582. * Create a new EventState
  37583. * @param mask defines the mask associated with this state
  37584. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  37585. * @param target defines the original target of the state
  37586. * @param currentTarget defines the current target of the state
  37587. */
  37588. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  37589. /**
  37590. * Initialize the current event state
  37591. * @param mask defines the mask associated with this state
  37592. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  37593. * @param target defines the original target of the state
  37594. * @param currentTarget defines the current target of the state
  37595. * @returns the current event state
  37596. */
  37597. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  37598. /**
  37599. * An Observer can set this property to true to prevent subsequent observers of being notified
  37600. */
  37601. skipNextObservers: boolean;
  37602. /**
  37603. * Get the mask value that were used to trigger the event corresponding to this EventState object
  37604. */
  37605. mask: number;
  37606. /**
  37607. * The object that originally notified the event
  37608. */
  37609. target?: any;
  37610. /**
  37611. * The current object in the bubbling phase
  37612. */
  37613. currentTarget?: any;
  37614. /**
  37615. * This will be populated with the return value of the last function that was executed.
  37616. * If it is the first function in the callback chain it will be the event data.
  37617. */
  37618. lastReturnValue?: any;
  37619. }
  37620. /**
  37621. * Represent an Observer registered to a given Observable object.
  37622. */
  37623. class Observer<T> {
  37624. /**
  37625. * Defines the callback to call when the observer is notified
  37626. */
  37627. callback: (eventData: T, eventState: EventState) => void;
  37628. /**
  37629. * Defines the mask of the observer (used to filter notifications)
  37630. */
  37631. mask: number;
  37632. /**
  37633. * Defines the current scope used to restore the JS context
  37634. */
  37635. scope: any;
  37636. /** @hidden */
  37637. _willBeUnregistered: boolean;
  37638. /**
  37639. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  37640. */
  37641. unregisterOnNextCall: boolean;
  37642. /**
  37643. * Creates a new observer
  37644. * @param callback defines the callback to call when the observer is notified
  37645. * @param mask defines the mask of the observer (used to filter notifications)
  37646. * @param scope defines the current scope used to restore the JS context
  37647. */
  37648. constructor(
  37649. /**
  37650. * Defines the callback to call when the observer is notified
  37651. */
  37652. callback: (eventData: T, eventState: EventState) => void,
  37653. /**
  37654. * Defines the mask of the observer (used to filter notifications)
  37655. */
  37656. mask: number,
  37657. /**
  37658. * Defines the current scope used to restore the JS context
  37659. */
  37660. scope?: any);
  37661. }
  37662. /**
  37663. * Represent a list of observers registered to multiple Observables object.
  37664. */
  37665. class MultiObserver<T> {
  37666. private _observers;
  37667. private _observables;
  37668. /**
  37669. * Release associated resources
  37670. */
  37671. dispose(): void;
  37672. /**
  37673. * Raise a callback when one of the observable will notify
  37674. * @param observables defines a list of observables to watch
  37675. * @param callback defines the callback to call on notification
  37676. * @param mask defines the mask used to filter notifications
  37677. * @param scope defines the current scope used to restore the JS context
  37678. * @returns the new MultiObserver
  37679. */
  37680. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  37681. }
  37682. /**
  37683. * The Observable class is a simple implementation of the Observable pattern.
  37684. *
  37685. * 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.
  37686. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  37687. * 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).
  37688. * 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.
  37689. */
  37690. class Observable<T> {
  37691. private _observers;
  37692. private _eventState;
  37693. private _onObserverAdded;
  37694. /**
  37695. * Creates a new observable
  37696. * @param onObserverAdded defines a callback to call when a new observer is added
  37697. */
  37698. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  37699. /**
  37700. * Create a new Observer with the specified callback
  37701. * @param callback the callback that will be executed for that Observer
  37702. * @param mask the mask used to filter observers
  37703. * @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.
  37704. * @param scope optional scope for the callback to be called from
  37705. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  37706. * @returns the new observer created for the callback
  37707. */
  37708. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  37709. /**
  37710. * Create a new Observer with the specified callback and unregisters after the next notification
  37711. * @param callback the callback that will be executed for that Observer
  37712. * @returns the new observer created for the callback
  37713. */
  37714. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  37715. /**
  37716. * Remove an Observer from the Observable object
  37717. * @param observer the instance of the Observer to remove
  37718. * @returns false if it doesn't belong to this Observable
  37719. */
  37720. remove(observer: Nullable<Observer<T>>): boolean;
  37721. /**
  37722. * Remove a callback from the Observable object
  37723. * @param callback the callback to remove
  37724. * @param scope optional scope. If used only the callbacks with this scope will be removed
  37725. * @returns false if it doesn't belong to this Observable
  37726. */
  37727. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  37728. private _deferUnregister;
  37729. private _remove;
  37730. /**
  37731. * Notify all Observers by calling their respective callback with the given data
  37732. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  37733. * @param eventData defines the data to send to all observers
  37734. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  37735. * @param target defines the original target of the state
  37736. * @param currentTarget defines the current target of the state
  37737. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  37738. */
  37739. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  37740. /**
  37741. * Calling this will execute each callback, expecting it to be a promise or return a value.
  37742. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  37743. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  37744. * and it is crucial that all callbacks will be executed.
  37745. * The order of the callbacks is kept, callbacks are not executed parallel.
  37746. *
  37747. * @param eventData The data to be sent to each callback
  37748. * @param mask is used to filter observers defaults to -1
  37749. * @param target defines the callback target (see EventState)
  37750. * @param currentTarget defines he current object in the bubbling phase
  37751. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  37752. */
  37753. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  37754. /**
  37755. * Notify a specific observer
  37756. * @param observer defines the observer to notify
  37757. * @param eventData defines the data to be sent to each callback
  37758. * @param mask is used to filter observers defaults to -1
  37759. */
  37760. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  37761. /**
  37762. * Gets a boolean indicating if the observable has at least one observer
  37763. * @returns true is the Observable has at least one Observer registered
  37764. */
  37765. hasObservers(): boolean;
  37766. /**
  37767. * Clear the list of observers
  37768. */
  37769. clear(): void;
  37770. /**
  37771. * Clone the current observable
  37772. * @returns a new observable
  37773. */
  37774. clone(): Observable<T>;
  37775. /**
  37776. * Does this observable handles observer registered with a given mask
  37777. * @param mask defines the mask to be tested
  37778. * @return whether or not one observer registered with the given mask is handeled
  37779. **/
  37780. hasSpecificMask(mask?: number): boolean;
  37781. }
  37782. }
  37783. declare module BABYLON {
  37784. /**
  37785. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  37786. */
  37787. class PerformanceMonitor {
  37788. private _enabled;
  37789. private _rollingFrameTime;
  37790. private _lastFrameTimeMs;
  37791. /**
  37792. * constructor
  37793. * @param frameSampleSize The number of samples required to saturate the sliding window
  37794. */
  37795. constructor(frameSampleSize?: number);
  37796. /**
  37797. * Samples current frame
  37798. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  37799. */
  37800. sampleFrame(timeMs?: number): void;
  37801. /**
  37802. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  37803. */
  37804. readonly averageFrameTime: number;
  37805. /**
  37806. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  37807. */
  37808. readonly averageFrameTimeVariance: number;
  37809. /**
  37810. * Returns the frame time of the most recent frame
  37811. */
  37812. readonly instantaneousFrameTime: number;
  37813. /**
  37814. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  37815. */
  37816. readonly averageFPS: number;
  37817. /**
  37818. * Returns the average framerate in frames per second using the most recent frame time
  37819. */
  37820. readonly instantaneousFPS: number;
  37821. /**
  37822. * Returns true if enough samples have been taken to completely fill the sliding window
  37823. */
  37824. readonly isSaturated: boolean;
  37825. /**
  37826. * Enables contributions to the sliding window sample set
  37827. */
  37828. enable(): void;
  37829. /**
  37830. * Disables contributions to the sliding window sample set
  37831. * Samples will not be interpolated over the disabled period
  37832. */
  37833. disable(): void;
  37834. /**
  37835. * Returns true if sampling is enabled
  37836. */
  37837. readonly isEnabled: boolean;
  37838. /**
  37839. * Resets performance monitor
  37840. */
  37841. reset(): void;
  37842. }
  37843. /**
  37844. * RollingAverage
  37845. *
  37846. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  37847. */
  37848. class RollingAverage {
  37849. /**
  37850. * Current average
  37851. */
  37852. average: number;
  37853. /**
  37854. * Current variance
  37855. */
  37856. variance: number;
  37857. protected _samples: Array<number>;
  37858. protected _sampleCount: number;
  37859. protected _pos: number;
  37860. protected _m2: number;
  37861. /**
  37862. * constructor
  37863. * @param length The number of samples required to saturate the sliding window
  37864. */
  37865. constructor(length: number);
  37866. /**
  37867. * Adds a sample to the sample set
  37868. * @param v The sample value
  37869. */
  37870. add(v: number): void;
  37871. /**
  37872. * Returns previously added values or null if outside of history or outside the sliding window domain
  37873. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  37874. * @return Value previously recorded with add() or null if outside of range
  37875. */
  37876. history(i: number): number;
  37877. /**
  37878. * Returns true if enough samples have been taken to completely fill the sliding window
  37879. * @return true if sample-set saturated
  37880. */
  37881. isSaturated(): boolean;
  37882. /**
  37883. * Resets the rolling average (equivalent to 0 samples taken so far)
  37884. */
  37885. reset(): void;
  37886. /**
  37887. * Wraps a value around the sample range boundaries
  37888. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  37889. * @return Wrapped position in sample range
  37890. */
  37891. protected _wrapPosition(i: number): number;
  37892. }
  37893. }
  37894. declare module BABYLON {
  37895. /**
  37896. * Helper class that provides a small promise polyfill
  37897. */
  37898. class PromisePolyfill {
  37899. /**
  37900. * Static function used to check if the polyfill is required
  37901. * If this is the case then the function will inject the polyfill to window.Promise
  37902. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  37903. */
  37904. static Apply(force?: boolean): void;
  37905. }
  37906. }
  37907. declare module BABYLON {
  37908. /**
  37909. * Defines the root class used to create scene optimization to use with SceneOptimizer
  37910. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  37911. */
  37912. class SceneOptimization {
  37913. /**
  37914. * Defines the priority of this optimization (0 by default which means first in the list)
  37915. */
  37916. priority: number;
  37917. /**
  37918. * Gets a string describing the action executed by the current optimization
  37919. * @returns description string
  37920. */
  37921. getDescription(): string;
  37922. /**
  37923. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  37924. * @param scene defines the current scene where to apply this optimization
  37925. * @param optimizer defines the current optimizer
  37926. * @returns true if everything that can be done was applied
  37927. */
  37928. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  37929. /**
  37930. * Creates the SceneOptimization object
  37931. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  37932. * @param desc defines the description associated with the optimization
  37933. */
  37934. constructor(
  37935. /**
  37936. * Defines the priority of this optimization (0 by default which means first in the list)
  37937. */
  37938. priority?: number);
  37939. }
  37940. /**
  37941. * Defines an optimization used to reduce the size of render target textures
  37942. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  37943. */
  37944. class TextureOptimization extends SceneOptimization {
  37945. /**
  37946. * Defines the priority of this optimization (0 by default which means first in the list)
  37947. */
  37948. priority: number;
  37949. /**
  37950. * 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
  37951. */
  37952. maximumSize: number;
  37953. /**
  37954. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  37955. */
  37956. step: number;
  37957. /**
  37958. * Gets a string describing the action executed by the current optimization
  37959. * @returns description string
  37960. */
  37961. getDescription(): string;
  37962. /**
  37963. * Creates the TextureOptimization object
  37964. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  37965. * @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
  37966. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  37967. */
  37968. constructor(
  37969. /**
  37970. * Defines the priority of this optimization (0 by default which means first in the list)
  37971. */
  37972. priority?: number,
  37973. /**
  37974. * 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
  37975. */
  37976. maximumSize?: number,
  37977. /**
  37978. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  37979. */
  37980. step?: number);
  37981. /**
  37982. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  37983. * @param scene defines the current scene where to apply this optimization
  37984. * @param optimizer defines the current optimizer
  37985. * @returns true if everything that can be done was applied
  37986. */
  37987. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  37988. }
  37989. /**
  37990. * Defines an optimization used to increase or decrease the rendering resolution
  37991. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  37992. */
  37993. class HardwareScalingOptimization extends SceneOptimization {
  37994. /**
  37995. * Defines the priority of this optimization (0 by default which means first in the list)
  37996. */
  37997. priority: number;
  37998. /**
  37999. * Defines the maximum scale to use (2 by default)
  38000. */
  38001. maximumScale: number;
  38002. /**
  38003. * Defines the step to use between two passes (0.5 by default)
  38004. */
  38005. step: number;
  38006. private _currentScale;
  38007. private _directionOffset;
  38008. /**
  38009. * Gets a string describing the action executed by the current optimization
  38010. * @return description string
  38011. */
  38012. getDescription(): string;
  38013. /**
  38014. * Creates the HardwareScalingOptimization object
  38015. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  38016. * @param maximumScale defines the maximum scale to use (2 by default)
  38017. * @param step defines the step to use between two passes (0.5 by default)
  38018. */
  38019. constructor(
  38020. /**
  38021. * Defines the priority of this optimization (0 by default which means first in the list)
  38022. */
  38023. priority?: number,
  38024. /**
  38025. * Defines the maximum scale to use (2 by default)
  38026. */
  38027. maximumScale?: number,
  38028. /**
  38029. * Defines the step to use between two passes (0.5 by default)
  38030. */
  38031. step?: number);
  38032. /**
  38033. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38034. * @param scene defines the current scene where to apply this optimization
  38035. * @param optimizer defines the current optimizer
  38036. * @returns true if everything that can be done was applied
  38037. */
  38038. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38039. }
  38040. /**
  38041. * Defines an optimization used to remove shadows
  38042. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38043. */
  38044. class ShadowsOptimization extends SceneOptimization {
  38045. /**
  38046. * Gets a string describing the action executed by the current optimization
  38047. * @return description string
  38048. */
  38049. getDescription(): string;
  38050. /**
  38051. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38052. * @param scene defines the current scene where to apply this optimization
  38053. * @param optimizer defines the current optimizer
  38054. * @returns true if everything that can be done was applied
  38055. */
  38056. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38057. }
  38058. /**
  38059. * Defines an optimization used to turn post-processes off
  38060. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38061. */
  38062. class PostProcessesOptimization extends SceneOptimization {
  38063. /**
  38064. * Gets a string describing the action executed by the current optimization
  38065. * @return description string
  38066. */
  38067. getDescription(): string;
  38068. /**
  38069. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38070. * @param scene defines the current scene where to apply this optimization
  38071. * @param optimizer defines the current optimizer
  38072. * @returns true if everything that can be done was applied
  38073. */
  38074. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38075. }
  38076. /**
  38077. * Defines an optimization used to turn lens flares off
  38078. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38079. */
  38080. class LensFlaresOptimization extends SceneOptimization {
  38081. /**
  38082. * Gets a string describing the action executed by the current optimization
  38083. * @return description string
  38084. */
  38085. getDescription(): string;
  38086. /**
  38087. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38088. * @param scene defines the current scene where to apply this optimization
  38089. * @param optimizer defines the current optimizer
  38090. * @returns true if everything that can be done was applied
  38091. */
  38092. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38093. }
  38094. /**
  38095. * Defines an optimization based on user defined callback.
  38096. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38097. */
  38098. class CustomOptimization extends SceneOptimization {
  38099. /**
  38100. * Callback called to apply the custom optimization.
  38101. */
  38102. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  38103. /**
  38104. * Callback called to get custom description
  38105. */
  38106. onGetDescription: () => string;
  38107. /**
  38108. * Gets a string describing the action executed by the current optimization
  38109. * @returns description string
  38110. */
  38111. getDescription(): string;
  38112. /**
  38113. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38114. * @param scene defines the current scene where to apply this optimization
  38115. * @param optimizer defines the current optimizer
  38116. * @returns true if everything that can be done was applied
  38117. */
  38118. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38119. }
  38120. /**
  38121. * Defines an optimization used to turn particles off
  38122. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38123. */
  38124. class ParticlesOptimization extends SceneOptimization {
  38125. /**
  38126. * Gets a string describing the action executed by the current optimization
  38127. * @return description string
  38128. */
  38129. getDescription(): string;
  38130. /**
  38131. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38132. * @param scene defines the current scene where to apply this optimization
  38133. * @param optimizer defines the current optimizer
  38134. * @returns true if everything that can be done was applied
  38135. */
  38136. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38137. }
  38138. /**
  38139. * Defines an optimization used to turn render targets off
  38140. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38141. */
  38142. class RenderTargetsOptimization extends SceneOptimization {
  38143. /**
  38144. * Gets a string describing the action executed by the current optimization
  38145. * @return description string
  38146. */
  38147. getDescription(): string;
  38148. /**
  38149. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38150. * @param scene defines the current scene where to apply this optimization
  38151. * @param optimizer defines the current optimizer
  38152. * @returns true if everything that can be done was applied
  38153. */
  38154. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38155. }
  38156. /**
  38157. * Defines an optimization used to merge meshes with compatible materials
  38158. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38159. */
  38160. class MergeMeshesOptimization extends SceneOptimization {
  38161. private static _UpdateSelectionTree;
  38162. /**
  38163. * Gets or sets a boolean which defines if optimization octree has to be updated
  38164. */
  38165. /**
  38166. * Gets or sets a boolean which defines if optimization octree has to be updated
  38167. */
  38168. static UpdateSelectionTree: boolean;
  38169. /**
  38170. * Gets a string describing the action executed by the current optimization
  38171. * @return description string
  38172. */
  38173. getDescription(): string;
  38174. private _canBeMerged;
  38175. /**
  38176. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38177. * @param scene defines the current scene where to apply this optimization
  38178. * @param optimizer defines the current optimizer
  38179. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  38180. * @returns true if everything that can be done was applied
  38181. */
  38182. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  38183. }
  38184. /**
  38185. * Defines a list of options used by SceneOptimizer
  38186. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38187. */
  38188. class SceneOptimizerOptions {
  38189. /**
  38190. * Defines the target frame rate to reach (60 by default)
  38191. */
  38192. targetFrameRate: number;
  38193. /**
  38194. * Defines the interval between two checkes (2000ms by default)
  38195. */
  38196. trackerDuration: number;
  38197. /**
  38198. * Gets the list of optimizations to apply
  38199. */
  38200. optimizations: SceneOptimization[];
  38201. /**
  38202. * Creates a new list of options used by SceneOptimizer
  38203. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  38204. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  38205. */
  38206. constructor(
  38207. /**
  38208. * Defines the target frame rate to reach (60 by default)
  38209. */
  38210. targetFrameRate?: number,
  38211. /**
  38212. * Defines the interval between two checkes (2000ms by default)
  38213. */
  38214. trackerDuration?: number);
  38215. /**
  38216. * Add a new optimization
  38217. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  38218. * @returns the current SceneOptimizerOptions
  38219. */
  38220. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  38221. /**
  38222. * Add a new custom optimization
  38223. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  38224. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  38225. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  38226. * @returns the current SceneOptimizerOptions
  38227. */
  38228. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  38229. /**
  38230. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  38231. * @param targetFrameRate defines the target frame rate (60 by default)
  38232. * @returns a SceneOptimizerOptions object
  38233. */
  38234. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  38235. /**
  38236. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  38237. * @param targetFrameRate defines the target frame rate (60 by default)
  38238. * @returns a SceneOptimizerOptions object
  38239. */
  38240. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  38241. /**
  38242. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  38243. * @param targetFrameRate defines the target frame rate (60 by default)
  38244. * @returns a SceneOptimizerOptions object
  38245. */
  38246. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  38247. }
  38248. /**
  38249. * Class used to run optimizations in order to reach a target frame rate
  38250. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38251. */
  38252. class SceneOptimizer implements IDisposable {
  38253. private _isRunning;
  38254. private _options;
  38255. private _scene;
  38256. private _currentPriorityLevel;
  38257. private _targetFrameRate;
  38258. private _trackerDuration;
  38259. private _currentFrameRate;
  38260. private _sceneDisposeObserver;
  38261. private _improvementMode;
  38262. /**
  38263. * Defines an observable called when the optimizer reaches the target frame rate
  38264. */
  38265. onSuccessObservable: Observable<SceneOptimizer>;
  38266. /**
  38267. * Defines an observable called when the optimizer enables an optimization
  38268. */
  38269. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  38270. /**
  38271. * Defines an observable called when the optimizer is not able to reach the target frame rate
  38272. */
  38273. onFailureObservable: Observable<SceneOptimizer>;
  38274. /**
  38275. * Gets a boolean indicating if the optimizer is in improvement mode
  38276. */
  38277. readonly isInImprovementMode: boolean;
  38278. /**
  38279. * Gets the current priority level (0 at start)
  38280. */
  38281. readonly currentPriorityLevel: number;
  38282. /**
  38283. * Gets the current frame rate checked by the SceneOptimizer
  38284. */
  38285. readonly currentFrameRate: number;
  38286. /**
  38287. * Gets or sets the current target frame rate (60 by default)
  38288. */
  38289. /**
  38290. * Gets or sets the current target frame rate (60 by default)
  38291. */
  38292. targetFrameRate: number;
  38293. /**
  38294. * Gets or sets the current interval between two checks (every 2000ms by default)
  38295. */
  38296. /**
  38297. * Gets or sets the current interval between two checks (every 2000ms by default)
  38298. */
  38299. trackerDuration: number;
  38300. /**
  38301. * Gets the list of active optimizations
  38302. */
  38303. readonly optimizations: SceneOptimization[];
  38304. /**
  38305. * Creates a new SceneOptimizer
  38306. * @param scene defines the scene to work on
  38307. * @param options defines the options to use with the SceneOptimizer
  38308. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  38309. * @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)
  38310. */
  38311. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  38312. /**
  38313. * Stops the current optimizer
  38314. */
  38315. stop(): void;
  38316. /**
  38317. * Reset the optimizer to initial step (current priority level = 0)
  38318. */
  38319. reset(): void;
  38320. /**
  38321. * Start the optimizer. By default it will try to reach a specific framerate
  38322. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  38323. */
  38324. start(): void;
  38325. private _checkCurrentState;
  38326. /**
  38327. * Release all resources
  38328. */
  38329. dispose(): void;
  38330. /**
  38331. * Helper function to create a SceneOptimizer with one single line of code
  38332. * @param scene defines the scene to work on
  38333. * @param options defines the options to use with the SceneOptimizer
  38334. * @param onSuccess defines a callback to call on success
  38335. * @param onFailure defines a callback to call on failure
  38336. * @returns the new SceneOptimizer object
  38337. */
  38338. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  38339. }
  38340. }
  38341. declare module BABYLON {
  38342. /**
  38343. * Class used to serialize a scene into a string
  38344. */
  38345. class SceneSerializer {
  38346. /**
  38347. * Clear cache used by a previous serialization
  38348. */
  38349. static ClearCache(): void;
  38350. /**
  38351. * Serialize a scene into a JSON compatible object
  38352. * @param scene defines the scene to serialize
  38353. * @returns a JSON compatible object
  38354. */
  38355. static Serialize(scene: Scene): any;
  38356. /**
  38357. * Serialize a mesh into a JSON compatible object
  38358. * @param toSerialize defines the mesh to serialize
  38359. * @param withParents defines if parents must be serialized as well
  38360. * @param withChildren defines if children must be serialized as well
  38361. * @returns a JSON compatible object
  38362. */
  38363. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  38364. }
  38365. }
  38366. declare module BABYLON {
  38367. /**
  38368. * Defines an array and its length.
  38369. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  38370. */
  38371. interface ISmartArrayLike<T> {
  38372. /**
  38373. * The data of the array.
  38374. */
  38375. data: Array<T>;
  38376. /**
  38377. * The active length of the array.
  38378. */
  38379. length: number;
  38380. }
  38381. /**
  38382. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  38383. */
  38384. class SmartArray<T> implements ISmartArrayLike<T> {
  38385. /**
  38386. * The full set of data from the array.
  38387. */
  38388. data: Array<T>;
  38389. /**
  38390. * The active length of the array.
  38391. */
  38392. length: number;
  38393. protected _id: number;
  38394. /**
  38395. * Instantiates a Smart Array.
  38396. * @param capacity defines the default capacity of the array.
  38397. */
  38398. constructor(capacity: number);
  38399. /**
  38400. * Pushes a value at the end of the active data.
  38401. * @param value defines the object to push in the array.
  38402. */
  38403. push(value: T): void;
  38404. /**
  38405. * Iterates over the active data and apply the lambda to them.
  38406. * @param func defines the action to apply on each value.
  38407. */
  38408. forEach(func: (content: T) => void): void;
  38409. /**
  38410. * Sorts the full sets of data.
  38411. * @param compareFn defines the comparison function to apply.
  38412. */
  38413. sort(compareFn: (a: T, b: T) => number): void;
  38414. /**
  38415. * Resets the active data to an empty array.
  38416. */
  38417. reset(): void;
  38418. /**
  38419. * Releases all the data from the array as well as the array.
  38420. */
  38421. dispose(): void;
  38422. /**
  38423. * Concats the active data with a given array.
  38424. * @param array defines the data to concatenate with.
  38425. */
  38426. concat(array: any): void;
  38427. /**
  38428. * Returns the position of a value in the active data.
  38429. * @param value defines the value to find the index for
  38430. * @returns the index if found in the active data otherwise -1
  38431. */
  38432. indexOf(value: T): number;
  38433. /**
  38434. * Returns whether an element is part of the active data.
  38435. * @param value defines the value to look for
  38436. * @returns true if found in the active data otherwise false
  38437. */
  38438. contains(value: T): boolean;
  38439. private static _GlobalId;
  38440. }
  38441. /**
  38442. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  38443. * The data in this array can only be present once
  38444. */
  38445. class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  38446. private _duplicateId;
  38447. /**
  38448. * Pushes a value at the end of the active data.
  38449. * THIS DOES NOT PREVENT DUPPLICATE DATA
  38450. * @param value defines the object to push in the array.
  38451. */
  38452. push(value: T): void;
  38453. /**
  38454. * Pushes a value at the end of the active data.
  38455. * If the data is already present, it won t be added again
  38456. * @param value defines the object to push in the array.
  38457. * @returns true if added false if it was already present
  38458. */
  38459. pushNoDuplicate(value: T): boolean;
  38460. /**
  38461. * Resets the active data to an empty array.
  38462. */
  38463. reset(): void;
  38464. /**
  38465. * Concats the active data with a given array.
  38466. * This ensures no dupplicate will be present in the result.
  38467. * @param array defines the data to concatenate with.
  38468. */
  38469. concatWithNoDuplicate(array: any): void;
  38470. }
  38471. }
  38472. declare module BABYLON {
  38473. /**
  38474. * This class implement a typical dictionary using a string as key and the generic type T as value.
  38475. * The underlying implementation relies on an associative array to ensure the best performances.
  38476. * The value can be anything including 'null' but except 'undefined'
  38477. */
  38478. class StringDictionary<T> {
  38479. /**
  38480. * This will clear this dictionary and copy the content from the 'source' one.
  38481. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  38482. * @param source the dictionary to take the content from and copy to this dictionary
  38483. */
  38484. copyFrom(source: StringDictionary<T>): void;
  38485. /**
  38486. * Get a value based from its key
  38487. * @param key the given key to get the matching value from
  38488. * @return the value if found, otherwise undefined is returned
  38489. */
  38490. get(key: string): T | undefined;
  38491. /**
  38492. * Get a value from its key or add it if it doesn't exist.
  38493. * This method will ensure you that a given key/data will be present in the dictionary.
  38494. * @param key the given key to get the matching value from
  38495. * @param factory the factory that will create the value if the key is not present in the dictionary.
  38496. * The factory will only be invoked if there's no data for the given key.
  38497. * @return the value corresponding to the key.
  38498. */
  38499. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  38500. /**
  38501. * Get a value from its key if present in the dictionary otherwise add it
  38502. * @param key the key to get the value from
  38503. * @param val if there's no such key/value pair in the dictionary add it with this value
  38504. * @return the value corresponding to the key
  38505. */
  38506. getOrAdd(key: string, val: T): T;
  38507. /**
  38508. * Check if there's a given key in the dictionary
  38509. * @param key the key to check for
  38510. * @return true if the key is present, false otherwise
  38511. */
  38512. contains(key: string): boolean;
  38513. /**
  38514. * Add a new key and its corresponding value
  38515. * @param key the key to add
  38516. * @param value the value corresponding to the key
  38517. * @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
  38518. */
  38519. add(key: string, value: T): boolean;
  38520. /**
  38521. * Update a specific value associated to a key
  38522. * @param key defines the key to use
  38523. * @param value defines the value to store
  38524. * @returns true if the value was updated (or false if the key was not found)
  38525. */
  38526. set(key: string, value: T): boolean;
  38527. /**
  38528. * Get the element of the given key and remove it from the dictionary
  38529. * @param key defines the key to search
  38530. * @returns the value associated with the key or null if not found
  38531. */
  38532. getAndRemove(key: string): Nullable<T>;
  38533. /**
  38534. * Remove a key/value from the dictionary.
  38535. * @param key the key to remove
  38536. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  38537. */
  38538. remove(key: string): boolean;
  38539. /**
  38540. * Clear the whole content of the dictionary
  38541. */
  38542. clear(): void;
  38543. /**
  38544. * Gets the current count
  38545. */
  38546. readonly count: number;
  38547. /**
  38548. * Execute a callback on each key/val of the dictionary.
  38549. * Note that you can remove any element in this dictionary in the callback implementation
  38550. * @param callback the callback to execute on a given key/value pair
  38551. */
  38552. forEach(callback: (key: string, val: T) => void): void;
  38553. /**
  38554. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  38555. * If the callback returns null or undefined the method will iterate to the next key/value pair
  38556. * Note that you can remove any element in this dictionary in the callback implementation
  38557. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  38558. * @returns the first item
  38559. */
  38560. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  38561. private _count;
  38562. private _data;
  38563. }
  38564. }
  38565. declare module BABYLON {
  38566. /**
  38567. * Class used to store custom tags
  38568. */
  38569. class Tags {
  38570. /**
  38571. * Adds support for tags on the given object
  38572. * @param obj defines the object to use
  38573. */
  38574. static EnableFor(obj: any): void;
  38575. /**
  38576. * Removes tags support
  38577. * @param obj defines the object to use
  38578. */
  38579. static DisableFor(obj: any): void;
  38580. /**
  38581. * Gets a boolean indicating if the given object has tags
  38582. * @param obj defines the object to use
  38583. * @returns a boolean
  38584. */
  38585. static HasTags(obj: any): boolean;
  38586. /**
  38587. * Gets the tags available on a given object
  38588. * @param obj defines the object to use
  38589. * @param asString defines if the tags must be returned as a string instead of an array of strings
  38590. * @returns the tags
  38591. */
  38592. static GetTags(obj: any, asString?: boolean): any;
  38593. /**
  38594. * Adds tags to an object
  38595. * @param obj defines the object to use
  38596. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  38597. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  38598. */
  38599. static AddTagsTo(obj: any, tagsString: string): void;
  38600. /**
  38601. * @hidden
  38602. */
  38603. static _AddTagTo(obj: any, tag: string): void;
  38604. /**
  38605. * Removes specific tags from a specific object
  38606. * @param obj defines the object to use
  38607. * @param tagsString defines the tags to remove
  38608. */
  38609. static RemoveTagsFrom(obj: any, tagsString: string): void;
  38610. /**
  38611. * @hidden
  38612. */
  38613. static _RemoveTagFrom(obj: any, tag: string): void;
  38614. /**
  38615. * Defines if tags hosted on an object match a given query
  38616. * @param obj defines the object to use
  38617. * @param tagsQuery defines the tag query
  38618. * @returns a boolean
  38619. */
  38620. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  38621. }
  38622. }
  38623. declare module BABYLON {
  38624. /**
  38625. * Class used to host texture specific utilities
  38626. */
  38627. class TextureTools {
  38628. /**
  38629. * Uses the GPU to create a copy texture rescaled at a given size
  38630. * @param texture Texture to copy from
  38631. * @param width defines the desired width
  38632. * @param height defines the desired height
  38633. * @param useBilinearMode defines if bilinear mode has to be used
  38634. * @return the generated texture
  38635. */
  38636. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  38637. /**
  38638. * Gets an environment BRDF texture for a given scene
  38639. * @param scene defines the hosting scene
  38640. * @returns the environment BRDF texture
  38641. */
  38642. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  38643. private static _environmentBRDFBase64Texture;
  38644. }
  38645. }
  38646. declare module BABYLON {
  38647. /**
  38648. * Based on jsTGALoader - Javascript loader for TGA file
  38649. * By Vincent Thibault
  38650. * @see http://blog.robrowser.com/javascript-tga-loader.html
  38651. */
  38652. class TGATools {
  38653. private static _TYPE_INDEXED;
  38654. private static _TYPE_RGB;
  38655. private static _TYPE_GREY;
  38656. private static _TYPE_RLE_INDEXED;
  38657. private static _TYPE_RLE_RGB;
  38658. private static _TYPE_RLE_GREY;
  38659. private static _ORIGIN_MASK;
  38660. private static _ORIGIN_SHIFT;
  38661. private static _ORIGIN_BL;
  38662. private static _ORIGIN_BR;
  38663. private static _ORIGIN_UL;
  38664. private static _ORIGIN_UR;
  38665. /**
  38666. * Gets the header of a TGA file
  38667. * @param data defines the TGA data
  38668. * @returns the header
  38669. */
  38670. static GetTGAHeader(data: Uint8Array): any;
  38671. /**
  38672. * Uploads TGA content to a Babylon Texture
  38673. * @hidden
  38674. */
  38675. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  38676. /** @hidden */
  38677. 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;
  38678. /** @hidden */
  38679. 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;
  38680. /** @hidden */
  38681. 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;
  38682. /** @hidden */
  38683. 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;
  38684. /** @hidden */
  38685. 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;
  38686. /** @hidden */
  38687. 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;
  38688. }
  38689. }
  38690. declare module BABYLON {
  38691. /**
  38692. * Interface containing an array of animations
  38693. */
  38694. interface IAnimatable {
  38695. /**
  38696. * Array of animations
  38697. */
  38698. animations: Array<Animation>;
  38699. }
  38700. /** Interface used by value gradients (color, factor, ...) */
  38701. interface IValueGradient {
  38702. /**
  38703. * Gets or sets the gradient value (between 0 and 1)
  38704. */
  38705. gradient: number;
  38706. }
  38707. /** Class used to store color4 gradient */
  38708. class ColorGradient implements IValueGradient {
  38709. /**
  38710. * Gets or sets the gradient value (between 0 and 1)
  38711. */
  38712. gradient: number;
  38713. /**
  38714. * Gets or sets first associated color
  38715. */
  38716. color1: Color4;
  38717. /**
  38718. * Gets or sets second associated color
  38719. */
  38720. color2?: Color4;
  38721. /**
  38722. * Will get a color picked randomly between color1 and color2.
  38723. * If color2 is undefined then color1 will be used
  38724. * @param result defines the target Color4 to store the result in
  38725. */
  38726. getColorToRef(result: Color4): void;
  38727. }
  38728. /** Class used to store color 3 gradient */
  38729. class Color3Gradient implements IValueGradient {
  38730. /**
  38731. * Gets or sets the gradient value (between 0 and 1)
  38732. */
  38733. gradient: number;
  38734. /**
  38735. * Gets or sets the associated color
  38736. */
  38737. color: Color3;
  38738. }
  38739. /** Class used to store factor gradient */
  38740. class FactorGradient implements IValueGradient {
  38741. /**
  38742. * Gets or sets the gradient value (between 0 and 1)
  38743. */
  38744. gradient: number;
  38745. /**
  38746. * Gets or sets first associated factor
  38747. */
  38748. factor1: number;
  38749. /**
  38750. * Gets or sets second associated factor
  38751. */
  38752. factor2?: number;
  38753. /**
  38754. * Will get a number picked randomly between factor1 and factor2.
  38755. * If factor2 is undefined then factor1 will be used
  38756. * @returns the picked number
  38757. */
  38758. getFactor(): number;
  38759. }
  38760. /**
  38761. * @ignore
  38762. * Application error to support additional information when loading a file
  38763. */
  38764. class LoadFileError extends Error {
  38765. /** defines the optional XHR request */
  38766. request?: XMLHttpRequest | undefined;
  38767. private static _setPrototypeOf;
  38768. /**
  38769. * Creates a new LoadFileError
  38770. * @param message defines the message of the error
  38771. * @param request defines the optional XHR request
  38772. */
  38773. constructor(message: string,
  38774. /** defines the optional XHR request */
  38775. request?: XMLHttpRequest | undefined);
  38776. }
  38777. /**
  38778. * Class used to define a retry strategy when error happens while loading assets
  38779. */
  38780. class RetryStrategy {
  38781. /**
  38782. * Function used to defines an exponential back off strategy
  38783. * @param maxRetries defines the maximum number of retries (3 by default)
  38784. * @param baseInterval defines the interval between retries
  38785. * @returns the strategy function to use
  38786. */
  38787. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  38788. }
  38789. /**
  38790. * File request interface
  38791. */
  38792. interface IFileRequest {
  38793. /**
  38794. * Raised when the request is complete (success or error).
  38795. */
  38796. onCompleteObservable: Observable<IFileRequest>;
  38797. /**
  38798. * Aborts the request for a file.
  38799. */
  38800. abort: () => void;
  38801. }
  38802. /**
  38803. * Class containing a set of static utilities functions
  38804. */
  38805. class Tools {
  38806. /**
  38807. * Gets or sets the base URL to use to load assets
  38808. */
  38809. static BaseUrl: string;
  38810. /**
  38811. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  38812. */
  38813. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  38814. /**
  38815. * Default behaviour for cors in the application.
  38816. * It can be a string if the expected behavior is identical in the entire app.
  38817. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  38818. */
  38819. static CorsBehavior: string | ((url: string | string[]) => string);
  38820. /**
  38821. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  38822. * @ignorenaming
  38823. */
  38824. static UseFallbackTexture: boolean;
  38825. /**
  38826. * Use this object to register external classes like custom textures or material
  38827. * to allow the laoders to instantiate them
  38828. */
  38829. static RegisteredExternalClasses: {
  38830. [key: string]: Object;
  38831. };
  38832. /**
  38833. * Texture content used if a texture cannot loaded
  38834. * @ignorenaming
  38835. */
  38836. static fallbackTexture: string;
  38837. /**
  38838. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  38839. * @param u defines the coordinate on X axis
  38840. * @param v defines the coordinate on Y axis
  38841. * @param width defines the width of the source data
  38842. * @param height defines the height of the source data
  38843. * @param pixels defines the source byte array
  38844. * @param color defines the output color
  38845. */
  38846. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  38847. /**
  38848. * Interpolates between a and b via alpha
  38849. * @param a The lower value (returned when alpha = 0)
  38850. * @param b The upper value (returned when alpha = 1)
  38851. * @param alpha The interpolation-factor
  38852. * @return The mixed value
  38853. */
  38854. static Mix(a: number, b: number, alpha: number): number;
  38855. /**
  38856. * Tries to instantiate a new object from a given class name
  38857. * @param className defines the class name to instantiate
  38858. * @returns the new object or null if the system was not able to do the instantiation
  38859. */
  38860. static Instantiate(className: string): any;
  38861. /**
  38862. * Provides a slice function that will work even on IE
  38863. * @param data defines the array to slice
  38864. * @param start defines the start of the data (optional)
  38865. * @param end defines the end of the data (optional)
  38866. * @returns the new sliced array
  38867. */
  38868. static Slice<T>(data: T, start?: number, end?: number): T;
  38869. /**
  38870. * Polyfill for setImmediate
  38871. * @param action defines the action to execute after the current execution block
  38872. */
  38873. static SetImmediate(action: () => void): void;
  38874. /**
  38875. * Function indicating if a number is an exponent of 2
  38876. * @param value defines the value to test
  38877. * @returns true if the value is an exponent of 2
  38878. */
  38879. static IsExponentOfTwo(value: number): boolean;
  38880. private static _tmpFloatArray;
  38881. /**
  38882. * Returns the nearest 32-bit single precision float representation of a Number
  38883. * @param value A Number. If the parameter is of a different type, it will get converted
  38884. * to a number or to NaN if it cannot be converted
  38885. * @returns number
  38886. */
  38887. static FloatRound(value: number): number;
  38888. /**
  38889. * Find the next highest power of two.
  38890. * @param x Number to start search from.
  38891. * @return Next highest power of two.
  38892. */
  38893. static CeilingPOT(x: number): number;
  38894. /**
  38895. * Find the next lowest power of two.
  38896. * @param x Number to start search from.
  38897. * @return Next lowest power of two.
  38898. */
  38899. static FloorPOT(x: number): number;
  38900. /**
  38901. * Find the nearest power of two.
  38902. * @param x Number to start search from.
  38903. * @return Next nearest power of two.
  38904. */
  38905. static NearestPOT(x: number): number;
  38906. /**
  38907. * Get the closest exponent of two
  38908. * @param value defines the value to approximate
  38909. * @param max defines the maximum value to return
  38910. * @param mode defines how to define the closest value
  38911. * @returns closest exponent of two of the given value
  38912. */
  38913. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  38914. /**
  38915. * Extracts the filename from a path
  38916. * @param path defines the path to use
  38917. * @returns the filename
  38918. */
  38919. static GetFilename(path: string): string;
  38920. /**
  38921. * Extracts the "folder" part of a path (everything before the filename).
  38922. * @param uri The URI to extract the info from
  38923. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  38924. * @returns The "folder" part of the path
  38925. */
  38926. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  38927. /**
  38928. * Extracts text content from a DOM element hierarchy
  38929. * @param element defines the root element
  38930. * @returns a string
  38931. */
  38932. static GetDOMTextContent(element: HTMLElement): string;
  38933. /**
  38934. * Convert an angle in radians to degrees
  38935. * @param angle defines the angle to convert
  38936. * @returns the angle in degrees
  38937. */
  38938. static ToDegrees(angle: number): number;
  38939. /**
  38940. * Convert an angle in degrees to radians
  38941. * @param angle defines the angle to convert
  38942. * @returns the angle in radians
  38943. */
  38944. static ToRadians(angle: number): number;
  38945. /**
  38946. * Encode a buffer to a base64 string
  38947. * @param buffer defines the buffer to encode
  38948. * @returns the encoded string
  38949. */
  38950. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  38951. /**
  38952. * Extracts minimum and maximum values from a list of indexed positions
  38953. * @param positions defines the positions to use
  38954. * @param indices defines the indices to the positions
  38955. * @param indexStart defines the start index
  38956. * @param indexCount defines the end index
  38957. * @param bias defines bias value to add to the result
  38958. * @return minimum and maximum values
  38959. */
  38960. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  38961. minimum: Vector3;
  38962. maximum: Vector3;
  38963. };
  38964. /**
  38965. * Extracts minimum and maximum values from a list of positions
  38966. * @param positions defines the positions to use
  38967. * @param start defines the start index in the positions array
  38968. * @param count defines the number of positions to handle
  38969. * @param bias defines bias value to add to the result
  38970. * @param stride defines the stride size to use (distance between two positions in the positions array)
  38971. * @return minimum and maximum values
  38972. */
  38973. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  38974. minimum: Vector3;
  38975. maximum: Vector3;
  38976. };
  38977. /**
  38978. * Returns an array if obj is not an array
  38979. * @param obj defines the object to evaluate as an array
  38980. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  38981. * @returns either obj directly if obj is an array or a new array containing obj
  38982. */
  38983. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  38984. /**
  38985. * Returns an array of the given size filled with element built from the given constructor and the paramters
  38986. * @param size the number of element to construct and put in the array
  38987. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  38988. * @returns a new array filled with new objects
  38989. */
  38990. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  38991. /**
  38992. * Gets the pointer prefix to use
  38993. * @returns "pointer" if touch is enabled. Else returns "mouse"
  38994. */
  38995. static GetPointerPrefix(): string;
  38996. /**
  38997. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  38998. * @param func - the function to be called
  38999. * @param requester - the object that will request the next frame. Falls back to window.
  39000. * @returns frame number
  39001. */
  39002. static QueueNewFrame(func: () => void, requester?: any): number;
  39003. /**
  39004. * Ask the browser to promote the current element to fullscreen rendering mode
  39005. * @param element defines the DOM element to promote
  39006. */
  39007. static RequestFullscreen(element: HTMLElement): void;
  39008. /**
  39009. * Asks the browser to exit fullscreen mode
  39010. */
  39011. static ExitFullscreen(): void;
  39012. /**
  39013. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  39014. * @param url define the url we are trying
  39015. * @param element define the dom element where to configure the cors policy
  39016. */
  39017. static SetCorsBehavior(url: string | string[], element: {
  39018. crossOrigin: string | null;
  39019. }): void;
  39020. /**
  39021. * Removes unwanted characters from an url
  39022. * @param url defines the url to clean
  39023. * @returns the cleaned url
  39024. */
  39025. static CleanUrl(url: string): string;
  39026. /**
  39027. * Gets or sets a function used to pre-process url before using them to load assets
  39028. */
  39029. static PreprocessUrl: (url: string) => string;
  39030. /**
  39031. * Loads an image as an HTMLImageElement.
  39032. * @param input url string, ArrayBuffer, or Blob to load
  39033. * @param onLoad callback called when the image successfully loads
  39034. * @param onError callback called when the image fails to load
  39035. * @param database database for caching
  39036. * @returns the HTMLImageElement of the loaded image
  39037. */
  39038. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, database: Nullable<Database>): HTMLImageElement;
  39039. /**
  39040. * Loads a file
  39041. * @param url url string, ArrayBuffer, or Blob to load
  39042. * @param onSuccess callback called when the file successfully loads
  39043. * @param onProgress callback called while file is loading (if the server supports this mode)
  39044. * @param database database for caching
  39045. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  39046. * @param onError callback called when the file fails to load
  39047. * @returns a file request object
  39048. */
  39049. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, database?: Database, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  39050. /**
  39051. * Load a script (identified by an url). When the url returns, the
  39052. * content of this file is added into a new script element, attached to the DOM (body element)
  39053. * @param scriptUrl defines the url of the script to laod
  39054. * @param onSuccess defines the callback called when the script is loaded
  39055. * @param onError defines the callback to call if an error occurs
  39056. */
  39057. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  39058. /**
  39059. * Loads a file from a blob
  39060. * @param fileToLoad defines the blob to use
  39061. * @param callback defines the callback to call when data is loaded
  39062. * @param progressCallback defines the callback to call during loading process
  39063. * @returns a file request object
  39064. */
  39065. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  39066. /**
  39067. * Loads a file
  39068. * @param fileToLoad defines the file to load
  39069. * @param callback defines the callback to call when data is loaded
  39070. * @param progressCallBack defines the callback to call during loading process
  39071. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  39072. * @returns a file request object
  39073. */
  39074. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  39075. /**
  39076. * Creates a data url from a given string content
  39077. * @param content defines the content to convert
  39078. * @returns the new data url link
  39079. */
  39080. static FileAsURL(content: string): string;
  39081. /**
  39082. * Format the given number to a specific decimal format
  39083. * @param value defines the number to format
  39084. * @param decimals defines the number of decimals to use
  39085. * @returns the formatted string
  39086. */
  39087. static Format(value: number, decimals?: number): string;
  39088. /**
  39089. * Checks if a given vector is inside a specific range
  39090. * @param v defines the vector to test
  39091. * @param min defines the minimum range
  39092. * @param max defines the maximum range
  39093. */
  39094. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  39095. /**
  39096. * Tries to copy an object by duplicating every property
  39097. * @param source defines the source object
  39098. * @param destination defines the target object
  39099. * @param doNotCopyList defines a list of properties to avoid
  39100. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  39101. */
  39102. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  39103. /**
  39104. * Gets a boolean indicating if the given object has no own property
  39105. * @param obj defines the object to test
  39106. * @returns true if object has no own property
  39107. */
  39108. static IsEmpty(obj: any): boolean;
  39109. /**
  39110. * Function used to register events at window level
  39111. * @param events defines the events to register
  39112. */
  39113. static RegisterTopRootEvents(events: {
  39114. name: string;
  39115. handler: Nullable<(e: FocusEvent) => any>;
  39116. }[]): void;
  39117. /**
  39118. * Function used to unregister events from window level
  39119. * @param events defines the events to unregister
  39120. */
  39121. static UnregisterTopRootEvents(events: {
  39122. name: string;
  39123. handler: Nullable<(e: FocusEvent) => any>;
  39124. }[]): void;
  39125. /**
  39126. * Dumps the current bound framebuffer
  39127. * @param width defines the rendering width
  39128. * @param height defines the rendering height
  39129. * @param engine defines the hosting engine
  39130. * @param successCallback defines the callback triggered once the data are available
  39131. * @param mimeType defines the mime type of the result
  39132. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  39133. */
  39134. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  39135. /**
  39136. * Converts the canvas data to blob.
  39137. * This acts as a polyfill for browsers not supporting the to blob function.
  39138. * @param canvas Defines the canvas to extract the data from
  39139. * @param successCallback Defines the callback triggered once the data are available
  39140. * @param mimeType Defines the mime type of the result
  39141. */
  39142. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  39143. /**
  39144. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  39145. * @param successCallback defines the callback triggered once the data are available
  39146. * @param mimeType defines the mime type of the result
  39147. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  39148. */
  39149. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  39150. /**
  39151. * Downloads a blob in the browser
  39152. * @param blob defines the blob to download
  39153. * @param fileName defines the name of the downloaded file
  39154. */
  39155. static Download(blob: Blob, fileName: string): void;
  39156. /**
  39157. * Captures a screenshot of the current rendering
  39158. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  39159. * @param engine defines the rendering engine
  39160. * @param camera defines the source camera
  39161. * @param size This parameter can be set to a single number or to an object with the
  39162. * following (optional) properties: precision, width, height. If a single number is passed,
  39163. * it will be used for both width and height. If an object is passed, the screenshot size
  39164. * will be derived from the parameters. The precision property is a multiplier allowing
  39165. * rendering at a higher or lower resolution
  39166. * @param successCallback defines the callback receives a single parameter which contains the
  39167. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  39168. * src parameter of an <img> to display it
  39169. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  39170. * Check your browser for supported MIME types
  39171. */
  39172. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  39173. /**
  39174. * Generates an image screenshot from the specified camera.
  39175. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  39176. * @param engine The engine to use for rendering
  39177. * @param camera The camera to use for rendering
  39178. * @param size This parameter can be set to a single number or to an object with the
  39179. * following (optional) properties: precision, width, height. If a single number is passed,
  39180. * it will be used for both width and height. If an object is passed, the screenshot size
  39181. * will be derived from the parameters. The precision property is a multiplier allowing
  39182. * rendering at a higher or lower resolution
  39183. * @param successCallback The callback receives a single parameter which contains the
  39184. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  39185. * src parameter of an <img> to display it
  39186. * @param mimeType The MIME type of the screenshot image (default: image/png).
  39187. * Check your browser for supported MIME types
  39188. * @param samples Texture samples (default: 1)
  39189. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  39190. * @param fileName A name for for the downloaded file.
  39191. */
  39192. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  39193. /**
  39194. * Validates if xhr data is correct
  39195. * @param xhr defines the request to validate
  39196. * @param dataType defines the expected data type
  39197. * @returns true if data is correct
  39198. */
  39199. static ValidateXHRData(xhr: XMLHttpRequest, dataType?: number): boolean;
  39200. /**
  39201. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  39202. * Be aware Math.random() could cause collisions, but:
  39203. * "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"
  39204. * @returns a pseudo random id
  39205. */
  39206. static RandomId(): string;
  39207. /**
  39208. * Test if the given uri is a base64 string
  39209. * @param uri The uri to test
  39210. * @return True if the uri is a base64 string or false otherwise
  39211. */
  39212. static IsBase64(uri: string): boolean;
  39213. /**
  39214. * Decode the given base64 uri.
  39215. * @param uri The uri to decode
  39216. * @return The decoded base64 data.
  39217. */
  39218. static DecodeBase64(uri: string): ArrayBuffer;
  39219. /**
  39220. * No log
  39221. */
  39222. static readonly NoneLogLevel: number;
  39223. /**
  39224. * Only message logs
  39225. */
  39226. static readonly MessageLogLevel: number;
  39227. /**
  39228. * Only warning logs
  39229. */
  39230. static readonly WarningLogLevel: number;
  39231. /**
  39232. * Only error logs
  39233. */
  39234. static readonly ErrorLogLevel: number;
  39235. /**
  39236. * All logs
  39237. */
  39238. static readonly AllLogLevel: number;
  39239. private static _LogCache;
  39240. /**
  39241. * Gets a value indicating the number of loading errors
  39242. * @ignorenaming
  39243. */
  39244. static errorsCount: number;
  39245. /**
  39246. * Callback called when a new log is added
  39247. */
  39248. static OnNewCacheEntry: (entry: string) => void;
  39249. private static _AddLogEntry;
  39250. private static _FormatMessage;
  39251. private static _LogDisabled;
  39252. private static _LogEnabled;
  39253. private static _WarnDisabled;
  39254. private static _WarnEnabled;
  39255. private static _ErrorDisabled;
  39256. private static _ErrorEnabled;
  39257. /**
  39258. * Log a message to the console
  39259. */
  39260. static Log: (message: string) => void;
  39261. /**
  39262. * Write a warning message to the console
  39263. */
  39264. static Warn: (message: string) => void;
  39265. /**
  39266. * Write an error message to the console
  39267. */
  39268. static Error: (message: string) => void;
  39269. /**
  39270. * Gets current log cache (list of logs)
  39271. */
  39272. static readonly LogCache: string;
  39273. /**
  39274. * Clears the log cache
  39275. */
  39276. static ClearLogCache(): void;
  39277. /**
  39278. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  39279. */
  39280. static LogLevels: number;
  39281. /**
  39282. * Checks if the loaded document was accessed via `file:`-Protocol.
  39283. * @returns boolean
  39284. */
  39285. static IsFileURL(): boolean;
  39286. /**
  39287. * Checks if the window object exists
  39288. * @returns true if the window object exists
  39289. */
  39290. static IsWindowObjectExist(): boolean;
  39291. /**
  39292. * No performance log
  39293. */
  39294. static readonly PerformanceNoneLogLevel: number;
  39295. /**
  39296. * Use user marks to log performance
  39297. */
  39298. static readonly PerformanceUserMarkLogLevel: number;
  39299. /**
  39300. * Log performance to the console
  39301. */
  39302. static readonly PerformanceConsoleLogLevel: number;
  39303. private static _performance;
  39304. /**
  39305. * Sets the current performance log level
  39306. */
  39307. static PerformanceLogLevel: number;
  39308. private static _StartPerformanceCounterDisabled;
  39309. private static _EndPerformanceCounterDisabled;
  39310. private static _StartUserMark;
  39311. private static _EndUserMark;
  39312. private static _StartPerformanceConsole;
  39313. private static _EndPerformanceConsole;
  39314. /**
  39315. * Starts a performance counter
  39316. */
  39317. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  39318. /**
  39319. * Ends a specific performance coutner
  39320. */
  39321. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  39322. /**
  39323. * Gets either window.performance.now() if supported or Date.now() else
  39324. */
  39325. static readonly Now: number;
  39326. /**
  39327. * This method will return the name of the class used to create the instance of the given object.
  39328. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  39329. * @param object the object to get the class name from
  39330. * @param isType defines if the object is actually a type
  39331. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  39332. */
  39333. static GetClassName(object: any, isType?: boolean): string;
  39334. /**
  39335. * Gets the first element of an array satisfying a given predicate
  39336. * @param array defines the array to browse
  39337. * @param predicate defines the predicate to use
  39338. * @returns null if not found or the element
  39339. */
  39340. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  39341. /**
  39342. * This method will return the name of the full name of the class, including its owning module (if any).
  39343. * 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).
  39344. * @param object the object to get the class name from
  39345. * @param isType defines if the object is actually a type
  39346. * @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.
  39347. * @ignorenaming
  39348. */
  39349. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  39350. /**
  39351. * Returns a promise that resolves after the given amount of time.
  39352. * @param delay Number of milliseconds to delay
  39353. * @returns Promise that resolves after the given amount of time
  39354. */
  39355. static DelayAsync(delay: number): Promise<void>;
  39356. /**
  39357. * Gets the current gradient from an array of IValueGradient
  39358. * @param ratio defines the current ratio to get
  39359. * @param gradients defines the array of IValueGradient
  39360. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  39361. */
  39362. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  39363. }
  39364. /**
  39365. * This class is used to track a performance counter which is number based.
  39366. * The user has access to many properties which give statistics of different nature.
  39367. *
  39368. * The implementer can track two kinds of Performance Counter: time and count.
  39369. * 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.
  39370. * 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.
  39371. */
  39372. class PerfCounter {
  39373. /**
  39374. * Gets or sets a global boolean to turn on and off all the counters
  39375. */
  39376. static Enabled: boolean;
  39377. /**
  39378. * Returns the smallest value ever
  39379. */
  39380. readonly min: number;
  39381. /**
  39382. * Returns the biggest value ever
  39383. */
  39384. readonly max: number;
  39385. /**
  39386. * Returns the average value since the performance counter is running
  39387. */
  39388. readonly average: number;
  39389. /**
  39390. * Returns the average value of the last second the counter was monitored
  39391. */
  39392. readonly lastSecAverage: number;
  39393. /**
  39394. * Returns the current value
  39395. */
  39396. readonly current: number;
  39397. /**
  39398. * Gets the accumulated total
  39399. */
  39400. readonly total: number;
  39401. /**
  39402. * Gets the total value count
  39403. */
  39404. readonly count: number;
  39405. /**
  39406. * Creates a new counter
  39407. */
  39408. constructor();
  39409. /**
  39410. * Call this method to start monitoring a new frame.
  39411. * 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.
  39412. */
  39413. fetchNewFrame(): void;
  39414. /**
  39415. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  39416. * @param newCount the count value to add to the monitored count
  39417. * @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.
  39418. */
  39419. addCount(newCount: number, fetchResult: boolean): void;
  39420. /**
  39421. * Start monitoring this performance counter
  39422. */
  39423. beginMonitoring(): void;
  39424. /**
  39425. * Compute the time lapsed since the previous beginMonitoring() call.
  39426. * @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
  39427. */
  39428. endMonitoring(newFrame?: boolean): void;
  39429. private _fetchResult;
  39430. private _startMonitoringTime;
  39431. private _min;
  39432. private _max;
  39433. private _average;
  39434. private _current;
  39435. private _totalValueCount;
  39436. private _totalAccumulated;
  39437. private _lastSecAverage;
  39438. private _lastSecAccumulated;
  39439. private _lastSecTime;
  39440. private _lastSecValueCount;
  39441. }
  39442. /**
  39443. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  39444. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  39445. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  39446. * @param name The name of the class, case should be preserved
  39447. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  39448. */
  39449. function className(name: string, module?: string): (target: Object) => void;
  39450. /**
  39451. * An implementation of a loop for asynchronous functions.
  39452. */
  39453. class AsyncLoop {
  39454. /**
  39455. * Defines the number of iterations for the loop
  39456. */
  39457. iterations: number;
  39458. /**
  39459. * Defines the current index of the loop.
  39460. */
  39461. index: number;
  39462. private _done;
  39463. private _fn;
  39464. private _successCallback;
  39465. /**
  39466. * Constructor.
  39467. * @param iterations the number of iterations.
  39468. * @param func the function to run each iteration
  39469. * @param successCallback the callback that will be called upon succesful execution
  39470. * @param offset starting offset.
  39471. */
  39472. constructor(
  39473. /**
  39474. * Defines the number of iterations for the loop
  39475. */
  39476. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  39477. /**
  39478. * Execute the next iteration. Must be called after the last iteration was finished.
  39479. */
  39480. executeNext(): void;
  39481. /**
  39482. * Break the loop and run the success callback.
  39483. */
  39484. breakLoop(): void;
  39485. /**
  39486. * Create and run an async loop.
  39487. * @param iterations the number of iterations.
  39488. * @param fn the function to run each iteration
  39489. * @param successCallback the callback that will be called upon succesful execution
  39490. * @param offset starting offset.
  39491. * @returns the created async loop object
  39492. */
  39493. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  39494. /**
  39495. * A for-loop that will run a given number of iterations synchronous and the rest async.
  39496. * @param iterations total number of iterations
  39497. * @param syncedIterations number of synchronous iterations in each async iteration.
  39498. * @param fn the function to call each iteration.
  39499. * @param callback a success call back that will be called when iterating stops.
  39500. * @param breakFunction a break condition (optional)
  39501. * @param timeout timeout settings for the setTimeout function. default - 0.
  39502. * @returns the created async loop object
  39503. */
  39504. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  39505. }
  39506. }
  39507. interface HTMLCanvasElement {
  39508. /** Track wether a record is in progress */
  39509. isRecording: boolean;
  39510. /** Capture Stream method defined by some browsers */
  39511. captureStream(fps?: number): MediaStream;
  39512. }
  39513. interface MediaRecorder {
  39514. /** Starts recording */
  39515. start(timeSlice: number): void;
  39516. /** Stops recording */
  39517. stop(): void;
  39518. /** Event raised when an error arised. */
  39519. onerror: (event: ErrorEvent) => void;
  39520. /** Event raised when the recording stops. */
  39521. onstop: (event: Event) => void;
  39522. /** Event raised when a new chunk of data is available and should be tracked. */
  39523. ondataavailable: (event: Event) => void;
  39524. }
  39525. interface MediaRecorderOptions {
  39526. /** The mime type you want to use as the recording container for the new MediaRecorder */
  39527. mimeType?: string;
  39528. /** The chosen bitrate for the audio component of the media. */
  39529. audioBitsPerSecond?: number;
  39530. /** The chosen bitrate for the video component of the media. */
  39531. videoBitsPerSecond?: number;
  39532. /** 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. */
  39533. bitsPerSecond?: number;
  39534. }
  39535. interface MediaRecorderConstructor {
  39536. /**
  39537. * A reference to the prototype.
  39538. */
  39539. readonly prototype: MediaRecorder;
  39540. /**
  39541. * Creates a new MediaRecorder.
  39542. * @param stream Defines the stream to record.
  39543. * @param options Defines the options for the recorder available in the type MediaRecorderOptions.
  39544. */
  39545. new (stream: MediaStream, options?: MediaRecorderOptions): MediaRecorder;
  39546. }
  39547. /**
  39548. * MediaRecoreder object available in some browsers.
  39549. */
  39550. declare var MediaRecorder: MediaRecorderConstructor;
  39551. declare module BABYLON {
  39552. /**
  39553. * This represents the different options avilable for the video capture.
  39554. */
  39555. interface VideoRecorderOptions {
  39556. /** Defines the mime type of the video */
  39557. mimeType: string;
  39558. /** Defines the video the video should be recorded at */
  39559. fps: number;
  39560. /** Defines the chunk size for the recording data */
  39561. recordChunckSize: number;
  39562. }
  39563. /**
  39564. * This can helps recording videos from BabylonJS.
  39565. * This is based on the available WebRTC functionalities of the browser.
  39566. *
  39567. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  39568. */
  39569. class VideoRecorder {
  39570. private static readonly _defaultOptions;
  39571. /**
  39572. * Returns wehther or not the VideoRecorder is available in your browser.
  39573. * @param engine Defines the Babylon Engine to check the support for
  39574. * @returns true if supported otherwise false
  39575. */
  39576. static IsSupported(engine: Engine): boolean;
  39577. private readonly _options;
  39578. private _canvas;
  39579. private _mediaRecorder;
  39580. private _recordedChunks;
  39581. private _fileName;
  39582. private _resolve;
  39583. private _reject;
  39584. /**
  39585. * True wether a recording is already in progress.
  39586. */
  39587. readonly isRecording: boolean;
  39588. /**
  39589. * Create a new VideoCapture object which can help converting what you see in Babylon to
  39590. * a video file.
  39591. * @param engine Defines the BabylonJS Engine you wish to record
  39592. * @param options Defines options that can be used to customized the capture
  39593. */
  39594. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  39595. /**
  39596. * Stops the current recording before the default capture timeout passed in the startRecording
  39597. * functions.
  39598. */
  39599. stopRecording(): void;
  39600. /**
  39601. * Starts recording the canvas for a max duration specified in parameters.
  39602. * @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.
  39603. * @param maxDuration Defines the maximum recording time in seconds.
  39604. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  39605. * @return a promise callback at the end of the recording with the video data in Blob.
  39606. */
  39607. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  39608. /**
  39609. * Releases internal resources used during the recording.
  39610. */
  39611. dispose(): void;
  39612. private _handleDataAvailable;
  39613. private _handleError;
  39614. private _handleStop;
  39615. }
  39616. }
  39617. declare module BABYLON {
  39618. /**
  39619. * Defines the potential axis of a Joystick
  39620. */
  39621. enum JoystickAxis {
  39622. /** X axis */
  39623. X = 0,
  39624. /** Y axis */
  39625. Y = 1,
  39626. /** Z axis */
  39627. Z = 2
  39628. }
  39629. /**
  39630. * Class used to define virtual joystick (used in touch mode)
  39631. */
  39632. class VirtualJoystick {
  39633. /**
  39634. * Gets or sets a boolean indicating that left and right values must be inverted
  39635. */
  39636. reverseLeftRight: boolean;
  39637. /**
  39638. * Gets or sets a boolean indicating that up and down values must be inverted
  39639. */
  39640. reverseUpDown: boolean;
  39641. /**
  39642. * Gets the offset value for the position (ie. the change of the position value)
  39643. */
  39644. deltaPosition: Vector3;
  39645. /**
  39646. * Gets a boolean indicating if the virtual joystick was pressed
  39647. */
  39648. pressed: boolean;
  39649. private static _globalJoystickIndex;
  39650. private static vjCanvas;
  39651. private static vjCanvasContext;
  39652. private static vjCanvasWidth;
  39653. private static vjCanvasHeight;
  39654. private static halfWidth;
  39655. private _action;
  39656. private _axisTargetedByLeftAndRight;
  39657. private _axisTargetedByUpAndDown;
  39658. private _joystickSensibility;
  39659. private _inversedSensibility;
  39660. private _joystickPointerID;
  39661. private _joystickColor;
  39662. private _joystickPointerPos;
  39663. private _joystickPreviousPointerPos;
  39664. private _joystickPointerStartPos;
  39665. private _deltaJoystickVector;
  39666. private _leftJoystick;
  39667. private _touches;
  39668. private _onPointerDownHandlerRef;
  39669. private _onPointerMoveHandlerRef;
  39670. private _onPointerUpHandlerRef;
  39671. private _onResize;
  39672. /**
  39673. * Creates a new virtual joystick
  39674. * @param leftJoystick defines that the joystick is for left hand (false by default)
  39675. */
  39676. constructor(leftJoystick?: boolean);
  39677. /**
  39678. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  39679. * @param newJoystickSensibility defines the new sensibility
  39680. */
  39681. setJoystickSensibility(newJoystickSensibility: number): void;
  39682. private _onPointerDown;
  39683. private _onPointerMove;
  39684. private _onPointerUp;
  39685. /**
  39686. * Change the color of the virtual joystick
  39687. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  39688. */
  39689. setJoystickColor(newColor: string): void;
  39690. /**
  39691. * Defines a callback to call when the joystick is touched
  39692. * @param action defines the callback
  39693. */
  39694. setActionOnTouch(action: () => any): void;
  39695. /**
  39696. * Defines which axis you'd like to control for left & right
  39697. * @param axis defines the axis to use
  39698. */
  39699. setAxisForLeftRight(axis: JoystickAxis): void;
  39700. /**
  39701. * Defines which axis you'd like to control for up & down
  39702. * @param axis defines the axis to use
  39703. */
  39704. setAxisForUpDown(axis: JoystickAxis): void;
  39705. private _drawVirtualJoystick;
  39706. /**
  39707. * Release internal HTML canvas
  39708. */
  39709. releaseCanvas(): void;
  39710. }
  39711. }
  39712. declare module BABYLON {
  39713. /**
  39714. * Helper class to push actions to a pool of workers.
  39715. */
  39716. class WorkerPool implements IDisposable {
  39717. private _workerInfos;
  39718. private _pendingActions;
  39719. /**
  39720. * Constructor
  39721. * @param workers Array of workers to use for actions
  39722. */
  39723. constructor(workers: Array<Worker>);
  39724. /**
  39725. * Terminates all workers and clears any pending actions.
  39726. */
  39727. dispose(): void;
  39728. /**
  39729. * Pushes an action to the worker pool. If all the workers are active, the action will be
  39730. * pended until a worker has completed its action.
  39731. * @param action The action to perform. Call onComplete when the action is complete.
  39732. */
  39733. push(action: (worker: Worker, onComplete: () => void) => void): void;
  39734. private _execute;
  39735. }
  39736. }
  39737. declare module BABYLON {
  39738. /**
  39739. * The autoRotation behavior (BABYLON.AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  39740. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39741. */
  39742. class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  39743. /**
  39744. * Gets the name of the behavior.
  39745. */
  39746. readonly name: string;
  39747. private _zoomStopsAnimation;
  39748. private _idleRotationSpeed;
  39749. private _idleRotationWaitTime;
  39750. private _idleRotationSpinupTime;
  39751. /**
  39752. * Sets the flag that indicates if user zooming should stop animation.
  39753. */
  39754. /**
  39755. * Gets the flag that indicates if user zooming should stop animation.
  39756. */
  39757. zoomStopsAnimation: boolean;
  39758. /**
  39759. * Sets the default speed at which the camera rotates around the model.
  39760. */
  39761. /**
  39762. * Gets the default speed at which the camera rotates around the model.
  39763. */
  39764. idleRotationSpeed: number;
  39765. /**
  39766. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  39767. */
  39768. /**
  39769. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  39770. */
  39771. idleRotationWaitTime: number;
  39772. /**
  39773. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39774. */
  39775. /**
  39776. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39777. */
  39778. idleRotationSpinupTime: number;
  39779. /**
  39780. * Gets a value indicating if the camera is currently rotating because of this behavior
  39781. */
  39782. readonly rotationInProgress: boolean;
  39783. private _onPrePointerObservableObserver;
  39784. private _onAfterCheckInputsObserver;
  39785. private _attachedCamera;
  39786. private _isPointerDown;
  39787. private _lastFrameTime;
  39788. private _lastInteractionTime;
  39789. private _cameraRotationSpeed;
  39790. /**
  39791. * Initializes the behavior.
  39792. */
  39793. init(): void;
  39794. /**
  39795. * Attaches the behavior to its arc rotate camera.
  39796. * @param camera Defines the camera to attach the behavior to
  39797. */
  39798. attach(camera: ArcRotateCamera): void;
  39799. /**
  39800. * Detaches the behavior from its current arc rotate camera.
  39801. */
  39802. detach(): void;
  39803. /**
  39804. * Returns true if user is scrolling.
  39805. * @return true if user is scrolling.
  39806. */
  39807. private _userIsZooming;
  39808. private _lastFrameRadius;
  39809. private _shouldAnimationStopForInteraction;
  39810. /**
  39811. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39812. */
  39813. private _applyUserInteraction;
  39814. private _userIsMoving;
  39815. }
  39816. }
  39817. declare module BABYLON {
  39818. /**
  39819. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  39820. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39821. */
  39822. class BouncingBehavior implements Behavior<ArcRotateCamera> {
  39823. /**
  39824. * Gets the name of the behavior.
  39825. */
  39826. readonly name: string;
  39827. /**
  39828. * The easing function used by animations
  39829. */
  39830. static EasingFunction: BackEase;
  39831. /**
  39832. * The easing mode used by animations
  39833. */
  39834. static EasingMode: number;
  39835. /**
  39836. * The duration of the animation, in milliseconds
  39837. */
  39838. transitionDuration: number;
  39839. /**
  39840. * Length of the distance animated by the transition when lower radius is reached
  39841. */
  39842. lowerRadiusTransitionRange: number;
  39843. /**
  39844. * Length of the distance animated by the transition when upper radius is reached
  39845. */
  39846. upperRadiusTransitionRange: number;
  39847. private _autoTransitionRange;
  39848. /**
  39849. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  39850. */
  39851. /**
  39852. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  39853. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  39854. */
  39855. autoTransitionRange: boolean;
  39856. private _attachedCamera;
  39857. private _onAfterCheckInputsObserver;
  39858. private _onMeshTargetChangedObserver;
  39859. /**
  39860. * Initializes the behavior.
  39861. */
  39862. init(): void;
  39863. /**
  39864. * Attaches the behavior to its arc rotate camera.
  39865. * @param camera Defines the camera to attach the behavior to
  39866. */
  39867. attach(camera: ArcRotateCamera): void;
  39868. /**
  39869. * Detaches the behavior from its current arc rotate camera.
  39870. */
  39871. detach(): void;
  39872. private _radiusIsAnimating;
  39873. private _radiusBounceTransition;
  39874. private _animatables;
  39875. private _cachedWheelPrecision;
  39876. /**
  39877. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  39878. * @param radiusLimit The limit to check against.
  39879. * @return Bool to indicate if at limit.
  39880. */
  39881. private _isRadiusAtLimit;
  39882. /**
  39883. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  39884. * @param radiusDelta The delta by which to animate to. Can be negative.
  39885. */
  39886. private _applyBoundRadiusAnimation;
  39887. /**
  39888. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  39889. */
  39890. protected _clearAnimationLocks(): void;
  39891. /**
  39892. * Stops and removes all animations that have been applied to the camera
  39893. */
  39894. stopAllAnimations(): void;
  39895. }
  39896. }
  39897. declare module BABYLON {
  39898. /**
  39899. * 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.
  39900. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39901. */
  39902. class FramingBehavior implements Behavior<ArcRotateCamera> {
  39903. /**
  39904. * Gets the name of the behavior.
  39905. */
  39906. readonly name: string;
  39907. private _mode;
  39908. private _radiusScale;
  39909. private _positionScale;
  39910. private _defaultElevation;
  39911. private _elevationReturnTime;
  39912. private _elevationReturnWaitTime;
  39913. private _zoomStopsAnimation;
  39914. private _framingTime;
  39915. /**
  39916. * The easing function used by animations
  39917. */
  39918. static EasingFunction: ExponentialEase;
  39919. /**
  39920. * The easing mode used by animations
  39921. */
  39922. static EasingMode: number;
  39923. /**
  39924. * Sets the current mode used by the behavior
  39925. */
  39926. /**
  39927. * Gets current mode used by the behavior.
  39928. */
  39929. mode: number;
  39930. /**
  39931. * Sets the scale applied to the radius (1 by default)
  39932. */
  39933. /**
  39934. * Gets the scale applied to the radius
  39935. */
  39936. radiusScale: number;
  39937. /**
  39938. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  39939. */
  39940. /**
  39941. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  39942. */
  39943. positionScale: number;
  39944. /**
  39945. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  39946. * behaviour is triggered, in radians.
  39947. */
  39948. /**
  39949. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  39950. * behaviour is triggered, in radians.
  39951. */
  39952. defaultElevation: number;
  39953. /**
  39954. * Sets the time (in milliseconds) taken to return to the default beta position.
  39955. * Negative value indicates camera should not return to default.
  39956. */
  39957. /**
  39958. * Gets the time (in milliseconds) taken to return to the default beta position.
  39959. * Negative value indicates camera should not return to default.
  39960. */
  39961. elevationReturnTime: number;
  39962. /**
  39963. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  39964. */
  39965. /**
  39966. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  39967. */
  39968. elevationReturnWaitTime: number;
  39969. /**
  39970. * Sets the flag that indicates if user zooming should stop animation.
  39971. */
  39972. /**
  39973. * Gets the flag that indicates if user zooming should stop animation.
  39974. */
  39975. zoomStopsAnimation: boolean;
  39976. /**
  39977. * Sets the transition time when framing the mesh, in milliseconds
  39978. */
  39979. /**
  39980. * Gets the transition time when framing the mesh, in milliseconds
  39981. */
  39982. framingTime: number;
  39983. /**
  39984. * Define if the behavior should automatically change the configured
  39985. * camera limits and sensibilities.
  39986. */
  39987. autoCorrectCameraLimitsAndSensibility: boolean;
  39988. private _onPrePointerObservableObserver;
  39989. private _onAfterCheckInputsObserver;
  39990. private _onMeshTargetChangedObserver;
  39991. private _attachedCamera;
  39992. private _isPointerDown;
  39993. private _lastInteractionTime;
  39994. /**
  39995. * Initializes the behavior.
  39996. */
  39997. init(): void;
  39998. /**
  39999. * Attaches the behavior to its arc rotate camera.
  40000. * @param camera Defines the camera to attach the behavior to
  40001. */
  40002. attach(camera: ArcRotateCamera): void;
  40003. /**
  40004. * Detaches the behavior from its current arc rotate camera.
  40005. */
  40006. detach(): void;
  40007. private _animatables;
  40008. private _betaIsAnimating;
  40009. private _betaTransition;
  40010. private _radiusTransition;
  40011. private _vectorTransition;
  40012. /**
  40013. * Targets the given mesh and updates zoom level accordingly.
  40014. * @param mesh The mesh to target.
  40015. * @param radius Optional. If a cached radius position already exists, overrides default.
  40016. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  40017. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  40018. * @param onAnimationEnd Callback triggered at the end of the framing animation
  40019. */
  40020. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  40021. /**
  40022. * Targets the given mesh with its children and updates zoom level accordingly.
  40023. * @param mesh The mesh to target.
  40024. * @param radius Optional. If a cached radius position already exists, overrides default.
  40025. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  40026. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  40027. * @param onAnimationEnd Callback triggered at the end of the framing animation
  40028. */
  40029. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  40030. /**
  40031. * Targets the given meshes with their children and updates zoom level accordingly.
  40032. * @param meshes The mesh to target.
  40033. * @param radius Optional. If a cached radius position already exists, overrides default.
  40034. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  40035. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  40036. * @param onAnimationEnd Callback triggered at the end of the framing animation
  40037. */
  40038. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  40039. /**
  40040. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  40041. * @param minimumWorld Determines the smaller position of the bounding box extend
  40042. * @param maximumWorld Determines the bigger position of the bounding box extend
  40043. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  40044. * @param onAnimationEnd Callback triggered at the end of the framing animation
  40045. */
  40046. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  40047. /**
  40048. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  40049. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  40050. * frustum width.
  40051. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  40052. * to fully enclose the mesh in the viewing frustum.
  40053. */
  40054. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  40055. /**
  40056. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  40057. * is automatically returned to its default position (expected to be above ground plane).
  40058. */
  40059. private _maintainCameraAboveGround;
  40060. /**
  40061. * Returns the frustum slope based on the canvas ratio and camera FOV
  40062. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  40063. */
  40064. private _getFrustumSlope;
  40065. /**
  40066. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  40067. */
  40068. private _clearAnimationLocks;
  40069. /**
  40070. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  40071. */
  40072. private _applyUserInteraction;
  40073. /**
  40074. * Stops and removes all animations that have been applied to the camera
  40075. */
  40076. stopAllAnimations(): void;
  40077. /**
  40078. * Gets a value indicating if the user is moving the camera
  40079. */
  40080. readonly isUserIsMoving: boolean;
  40081. /**
  40082. * The camera can move all the way towards the mesh.
  40083. */
  40084. static IgnoreBoundsSizeMode: number;
  40085. /**
  40086. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  40087. */
  40088. static FitFrustumSidesMode: number;
  40089. }
  40090. }
  40091. declare module BABYLON {
  40092. /**
  40093. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  40094. */
  40095. class AttachToBoxBehavior implements BABYLON.Behavior<BABYLON.Mesh> {
  40096. private ui;
  40097. /**
  40098. * The name of the behavior
  40099. */
  40100. name: string;
  40101. /**
  40102. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  40103. */
  40104. distanceAwayFromFace: number;
  40105. /**
  40106. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  40107. */
  40108. distanceAwayFromBottomOfFace: number;
  40109. private _faceVectors;
  40110. private _target;
  40111. private _scene;
  40112. private _onRenderObserver;
  40113. private _tmpMatrix;
  40114. private _tmpVector;
  40115. /**
  40116. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  40117. * @param ui The transform node that should be attched to the mesh
  40118. */
  40119. constructor(ui: BABYLON.TransformNode);
  40120. /**
  40121. * Initializes the behavior
  40122. */
  40123. init(): void;
  40124. private _closestFace;
  40125. private _zeroVector;
  40126. private _lookAtTmpMatrix;
  40127. private _lookAtToRef;
  40128. /**
  40129. * Attaches the AttachToBoxBehavior to the passed in mesh
  40130. * @param target The mesh that the specified node will be attached to
  40131. */
  40132. attach(target: BABYLON.Mesh): void;
  40133. /**
  40134. * Detaches the behavior from the mesh
  40135. */
  40136. detach(): void;
  40137. }
  40138. }
  40139. declare module BABYLON {
  40140. /**
  40141. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  40142. */
  40143. class FadeInOutBehavior implements Behavior<Mesh> {
  40144. /**
  40145. * Time in milliseconds to delay before fading in (Default: 0)
  40146. */
  40147. delay: number;
  40148. /**
  40149. * Time in milliseconds for the mesh to fade in (Default: 300)
  40150. */
  40151. fadeInTime: number;
  40152. private _millisecondsPerFrame;
  40153. private _hovered;
  40154. private _hoverValue;
  40155. private _ownerNode;
  40156. /**
  40157. * Instatiates the FadeInOutBehavior
  40158. */
  40159. constructor();
  40160. /**
  40161. * The name of the behavior
  40162. */
  40163. readonly name: string;
  40164. /**
  40165. * Initializes the behavior
  40166. */
  40167. init(): void;
  40168. /**
  40169. * Attaches the fade behavior on the passed in mesh
  40170. * @param ownerNode The mesh that will be faded in/out once attached
  40171. */
  40172. attach(ownerNode: Mesh): void;
  40173. /**
  40174. * Detaches the behavior from the mesh
  40175. */
  40176. detach(): void;
  40177. /**
  40178. * Triggers the mesh to begin fading in or out
  40179. * @param value if the object should fade in or out (true to fade in)
  40180. */
  40181. fadeIn(value: boolean): void;
  40182. private _update;
  40183. private _setAllVisibility;
  40184. }
  40185. }
  40186. declare module BABYLON {
  40187. /**
  40188. * A behavior that when attached to a mesh will allow the mesh to be scaled
  40189. */
  40190. class MultiPointerScaleBehavior implements Behavior<Mesh> {
  40191. private _dragBehaviorA;
  40192. private _dragBehaviorB;
  40193. private _startDistance;
  40194. private _initialScale;
  40195. private _targetScale;
  40196. private _ownerNode;
  40197. private _sceneRenderObserver;
  40198. /**
  40199. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  40200. */
  40201. constructor();
  40202. /**
  40203. * The name of the behavior
  40204. */
  40205. readonly name: string;
  40206. /**
  40207. * Initializes the behavior
  40208. */
  40209. init(): void;
  40210. private _getCurrentDistance;
  40211. /**
  40212. * Attaches the scale behavior the passed in mesh
  40213. * @param ownerNode The mesh that will be scaled around once attached
  40214. */
  40215. attach(ownerNode: Mesh): void;
  40216. /**
  40217. * Detaches the behavior from the mesh
  40218. */
  40219. detach(): void;
  40220. }
  40221. }
  40222. declare module BABYLON {
  40223. /**
  40224. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  40225. */
  40226. class PointerDragBehavior implements Behavior<Mesh> {
  40227. private static _AnyMouseID;
  40228. private _attachedNode;
  40229. private _dragPlane;
  40230. private _scene;
  40231. private _pointerObserver;
  40232. private _beforeRenderObserver;
  40233. private static _planeScene;
  40234. /**
  40235. * 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)
  40236. */
  40237. maxDragAngle: number;
  40238. /**
  40239. * @hidden
  40240. */
  40241. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  40242. /**
  40243. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40244. */
  40245. currentDraggingPointerID: number;
  40246. /**
  40247. * The last position where the pointer hit the drag plane in world space
  40248. */
  40249. lastDragPosition: Vector3;
  40250. /**
  40251. * If the behavior is currently in a dragging state
  40252. */
  40253. dragging: boolean;
  40254. /**
  40255. * 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)
  40256. */
  40257. dragDeltaRatio: number;
  40258. /**
  40259. * If the drag plane orientation should be updated during the dragging (Default: true)
  40260. */
  40261. updateDragPlane: boolean;
  40262. private _debugMode;
  40263. private _moving;
  40264. /**
  40265. * Fires each time the attached mesh is dragged with the pointer
  40266. * * delta between last drag position and current drag position in world space
  40267. * * dragDistance along the drag axis
  40268. * * dragPlaneNormal normal of the current drag plane used during the drag
  40269. * * dragPlanePoint in world space where the drag intersects the drag plane
  40270. */
  40271. onDragObservable: Observable<{
  40272. delta: Vector3;
  40273. dragPlanePoint: Vector3;
  40274. dragPlaneNormal: Vector3;
  40275. dragDistance: number;
  40276. pointerId: number;
  40277. }>;
  40278. /**
  40279. * Fires each time a drag begins (eg. mouse down on mesh)
  40280. */
  40281. onDragStartObservable: Observable<{
  40282. dragPlanePoint: Vector3;
  40283. pointerId: number;
  40284. }>;
  40285. /**
  40286. * Fires each time a drag ends (eg. mouse release after drag)
  40287. */
  40288. onDragEndObservable: Observable<{
  40289. dragPlanePoint: Vector3;
  40290. pointerId: number;
  40291. }>;
  40292. /**
  40293. * If the attached mesh should be moved when dragged
  40294. */
  40295. moveAttached: boolean;
  40296. /**
  40297. * If the drag behavior will react to drag events (Default: true)
  40298. */
  40299. enabled: boolean;
  40300. /**
  40301. * If camera controls should be detached during the drag
  40302. */
  40303. detachCameraControls: boolean;
  40304. /**
  40305. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  40306. */
  40307. useObjectOrienationForDragging: boolean;
  40308. private _options;
  40309. /**
  40310. * Creates a pointer drag behavior that can be attached to a mesh
  40311. * @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)
  40312. */
  40313. constructor(options?: {
  40314. dragAxis?: Vector3;
  40315. dragPlaneNormal?: Vector3;
  40316. });
  40317. /**
  40318. * The name of the behavior
  40319. */
  40320. readonly name: string;
  40321. /**
  40322. * Initializes the behavior
  40323. */
  40324. init(): void;
  40325. private _tmpVector;
  40326. private _alternatePickedPoint;
  40327. private _worldDragAxis;
  40328. private _targetPosition;
  40329. private _attachedElement;
  40330. /**
  40331. * Attaches the drag behavior the passed in mesh
  40332. * @param ownerNode The mesh that will be dragged around once attached
  40333. */
  40334. attach(ownerNode: Mesh): void;
  40335. /**
  40336. * Force relase the drag action by code.
  40337. */
  40338. releaseDrag(): void;
  40339. private _startDragRay;
  40340. private _lastPointerRay;
  40341. /**
  40342. * Simulates the start of a pointer drag event on the behavior
  40343. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  40344. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  40345. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  40346. */
  40347. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  40348. private _startDrag;
  40349. private _dragDelta;
  40350. private _moveDrag;
  40351. private _pickWithRayOnDragPlane;
  40352. private _pointA;
  40353. private _pointB;
  40354. private _pointC;
  40355. private _lineA;
  40356. private _lineB;
  40357. private _localAxis;
  40358. private _lookAt;
  40359. private _updateDragPlanePosition;
  40360. /**
  40361. * Detaches the behavior from the mesh
  40362. */
  40363. detach(): void;
  40364. }
  40365. }
  40366. declare module BABYLON {
  40367. /**
  40368. * 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
  40369. */
  40370. class SixDofDragBehavior implements Behavior<Mesh> {
  40371. private static _virtualScene;
  40372. private _ownerNode;
  40373. private _sceneRenderObserver;
  40374. private _scene;
  40375. private _targetPosition;
  40376. private _virtualOriginMesh;
  40377. private _virtualDragMesh;
  40378. private _pointerObserver;
  40379. private _moving;
  40380. private _startingOrientation;
  40381. /**
  40382. * 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)
  40383. */
  40384. private zDragFactor;
  40385. /**
  40386. * If the behavior is currently in a dragging state
  40387. */
  40388. dragging: boolean;
  40389. /**
  40390. * 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)
  40391. */
  40392. dragDeltaRatio: number;
  40393. /**
  40394. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40395. */
  40396. currentDraggingPointerID: number;
  40397. /**
  40398. * If camera controls should be detached during the drag
  40399. */
  40400. detachCameraControls: boolean;
  40401. /**
  40402. * Fires each time a drag starts
  40403. */
  40404. onDragStartObservable: Observable<{}>;
  40405. /**
  40406. * Fires each time a drag ends (eg. mouse release after drag)
  40407. */
  40408. onDragEndObservable: Observable<{}>;
  40409. /**
  40410. * 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
  40411. */
  40412. constructor();
  40413. /**
  40414. * The name of the behavior
  40415. */
  40416. readonly name: string;
  40417. /**
  40418. * Initializes the behavior
  40419. */
  40420. init(): void;
  40421. /**
  40422. * Attaches the scale behavior the passed in mesh
  40423. * @param ownerNode The mesh that will be scaled around once attached
  40424. */
  40425. attach(ownerNode: Mesh): void;
  40426. /**
  40427. * Detaches the behavior from the mesh
  40428. */
  40429. detach(): void;
  40430. }
  40431. }
  40432. declare module BABYLON {
  40433. /**
  40434. * Manage the gamepad inputs to control an arc rotate camera.
  40435. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40436. */
  40437. class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  40438. /**
  40439. * Defines the camera the input is attached to.
  40440. */
  40441. camera: ArcRotateCamera;
  40442. /**
  40443. * Defines the gamepad the input is gathering event from.
  40444. */
  40445. gamepad: Nullable<Gamepad>;
  40446. /**
  40447. * Defines the gamepad rotation sensiblity.
  40448. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40449. */
  40450. gamepadRotationSensibility: number;
  40451. /**
  40452. * Defines the gamepad move sensiblity.
  40453. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40454. */
  40455. gamepadMoveSensibility: number;
  40456. private _onGamepadConnectedObserver;
  40457. private _onGamepadDisconnectedObserver;
  40458. /**
  40459. * Attach the input controls to a specific dom element to get the input from.
  40460. * @param element Defines the element the controls should be listened from
  40461. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40462. */
  40463. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40464. /**
  40465. * Detach the current controls from the specified dom element.
  40466. * @param element Defines the element to stop listening the inputs from
  40467. */
  40468. detachControl(element: Nullable<HTMLElement>): void;
  40469. /**
  40470. * Update the current camera state depending on the inputs that have been used this frame.
  40471. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40472. */
  40473. checkInputs(): void;
  40474. /**
  40475. * Gets the class name of the current intput.
  40476. * @returns the class name
  40477. */
  40478. getClassName(): string;
  40479. /**
  40480. * Get the friendly name associated with the input class.
  40481. * @returns the input friendly name
  40482. */
  40483. getSimpleName(): string;
  40484. }
  40485. }
  40486. declare module BABYLON {
  40487. /**
  40488. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  40489. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40490. */
  40491. class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  40492. /**
  40493. * Defines the camera the input is attached to.
  40494. */
  40495. camera: ArcRotateCamera;
  40496. /**
  40497. * Defines the list of key codes associated with the up action (increase alpha)
  40498. */
  40499. keysUp: number[];
  40500. /**
  40501. * Defines the list of key codes associated with the down action (decrease alpha)
  40502. */
  40503. keysDown: number[];
  40504. /**
  40505. * Defines the list of key codes associated with the left action (increase beta)
  40506. */
  40507. keysLeft: number[];
  40508. /**
  40509. * Defines the list of key codes associated with the right action (decrease beta)
  40510. */
  40511. keysRight: number[];
  40512. /**
  40513. * Defines the list of key codes associated with the reset action.
  40514. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  40515. */
  40516. keysReset: number[];
  40517. /**
  40518. * Defines the panning sensibility of the inputs.
  40519. * (How fast is the camera paning)
  40520. */
  40521. panningSensibility: number;
  40522. /**
  40523. * Defines the zooming sensibility of the inputs.
  40524. * (How fast is the camera zooming)
  40525. */
  40526. zoomingSensibility: number;
  40527. /**
  40528. * Defines wether maintaining the alt key down switch the movement mode from
  40529. * orientation to zoom.
  40530. */
  40531. useAltToZoom: boolean;
  40532. /**
  40533. * Rotation speed of the camera
  40534. */
  40535. angularSpeed: number;
  40536. private _keys;
  40537. private _ctrlPressed;
  40538. private _altPressed;
  40539. private _onCanvasBlurObserver;
  40540. private _onKeyboardObserver;
  40541. private _engine;
  40542. private _scene;
  40543. /**
  40544. * Attach the input controls to a specific dom element to get the input from.
  40545. * @param element Defines the element the controls should be listened from
  40546. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40547. */
  40548. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40549. /**
  40550. * Detach the current controls from the specified dom element.
  40551. * @param element Defines the element to stop listening the inputs from
  40552. */
  40553. detachControl(element: Nullable<HTMLElement>): void;
  40554. /**
  40555. * Update the current camera state depending on the inputs that have been used this frame.
  40556. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40557. */
  40558. checkInputs(): void;
  40559. /**
  40560. * Gets the class name of the current intput.
  40561. * @returns the class name
  40562. */
  40563. getClassName(): string;
  40564. /**
  40565. * Get the friendly name associated with the input class.
  40566. * @returns the input friendly name
  40567. */
  40568. getSimpleName(): string;
  40569. }
  40570. }
  40571. declare module BABYLON {
  40572. /**
  40573. * Manage the mouse wheel inputs to control an arc rotate camera.
  40574. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40575. */
  40576. class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  40577. /**
  40578. * Defines the camera the input is attached to.
  40579. */
  40580. camera: ArcRotateCamera;
  40581. /**
  40582. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  40583. */
  40584. wheelPrecision: number;
  40585. /**
  40586. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  40587. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  40588. */
  40589. wheelDeltaPercentage: number;
  40590. private _wheel;
  40591. private _observer;
  40592. /**
  40593. * Attach the input controls to a specific dom element to get the input from.
  40594. * @param element Defines the element the controls should be listened from
  40595. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40596. */
  40597. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40598. /**
  40599. * Detach the current controls from the specified dom element.
  40600. * @param element Defines the element to stop listening the inputs from
  40601. */
  40602. detachControl(element: Nullable<HTMLElement>): void;
  40603. /**
  40604. * Gets the class name of the current intput.
  40605. * @returns the class name
  40606. */
  40607. getClassName(): string;
  40608. /**
  40609. * Get the friendly name associated with the input class.
  40610. * @returns the input friendly name
  40611. */
  40612. getSimpleName(): string;
  40613. }
  40614. }
  40615. declare module BABYLON {
  40616. /**
  40617. * Manage the pointers inputs to control an arc rotate camera.
  40618. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40619. */
  40620. class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  40621. /**
  40622. * Defines the camera the input is attached to.
  40623. */
  40624. camera: ArcRotateCamera;
  40625. /**
  40626. * Defines the buttons associated with the input to handle camera move.
  40627. */
  40628. buttons: number[];
  40629. /**
  40630. * Defines the pointer angular sensibility along the X axis or how fast is the camera rotating.
  40631. */
  40632. angularSensibilityX: number;
  40633. /**
  40634. * Defines the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  40635. */
  40636. angularSensibilityY: number;
  40637. /**
  40638. * Defines the pointer pinch precision or how fast is the camera zooming.
  40639. */
  40640. pinchPrecision: number;
  40641. /**
  40642. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  40643. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  40644. */
  40645. pinchDeltaPercentage: number;
  40646. /**
  40647. * Defines the pointer panning sensibility or how fast is the camera moving.
  40648. */
  40649. panningSensibility: number;
  40650. /**
  40651. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  40652. */
  40653. multiTouchPanning: boolean;
  40654. /**
  40655. * Defines whether panning is enabled for both pan (2 fingers swipe) and zoom (pinch) through multitouch.
  40656. */
  40657. multiTouchPanAndZoom: boolean;
  40658. /**
  40659. * Revers pinch action direction.
  40660. */
  40661. pinchInwards: boolean;
  40662. private _isPanClick;
  40663. private _pointerInput;
  40664. private _observer;
  40665. private _onMouseMove;
  40666. private _onGestureStart;
  40667. private _onGesture;
  40668. private _MSGestureHandler;
  40669. private _onLostFocus;
  40670. private _onContextMenu;
  40671. /**
  40672. * Attach the input controls to a specific dom element to get the input from.
  40673. * @param element Defines the element the controls should be listened from
  40674. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40675. */
  40676. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40677. /**
  40678. * Detach the current controls from the specified dom element.
  40679. * @param element Defines the element to stop listening the inputs from
  40680. */
  40681. detachControl(element: Nullable<HTMLElement>): void;
  40682. /**
  40683. * Gets the class name of the current intput.
  40684. * @returns the class name
  40685. */
  40686. getClassName(): string;
  40687. /**
  40688. * Get the friendly name associated with the input class.
  40689. * @returns the input friendly name
  40690. */
  40691. getSimpleName(): string;
  40692. }
  40693. }
  40694. declare module BABYLON {
  40695. /**
  40696. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  40697. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40698. */
  40699. class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  40700. /**
  40701. * Defines the camera the input is attached to.
  40702. */
  40703. camera: ArcRotateCamera;
  40704. /**
  40705. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  40706. */
  40707. alphaCorrection: number;
  40708. /**
  40709. * Defines a correction factor applied on the beta value retrieved from the orientation events.
  40710. */
  40711. betaCorrection: number;
  40712. /**
  40713. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  40714. */
  40715. gammaCorrection: number;
  40716. private _alpha;
  40717. private _gamma;
  40718. private _dirty;
  40719. private _deviceOrientationHandler;
  40720. /**
  40721. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  40722. */
  40723. constructor();
  40724. /**
  40725. * Attach the input controls to a specific dom element to get the input from.
  40726. * @param element Defines the element the controls should be listened from
  40727. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40728. */
  40729. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40730. /** @hidden */
  40731. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  40732. /**
  40733. * Update the current camera state depending on the inputs that have been used this frame.
  40734. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40735. */
  40736. checkInputs(): void;
  40737. /**
  40738. * Detach the current controls from the specified dom element.
  40739. * @param element Defines the element to stop listening the inputs from
  40740. */
  40741. detachControl(element: Nullable<HTMLElement>): void;
  40742. /**
  40743. * Gets the class name of the current intput.
  40744. * @returns the class name
  40745. */
  40746. getClassName(): string;
  40747. /**
  40748. * Get the friendly name associated with the input class.
  40749. * @returns the input friendly name
  40750. */
  40751. getSimpleName(): string;
  40752. }
  40753. }
  40754. declare module BABYLON {
  40755. /**
  40756. * Listen to keyboard events to control the camera.
  40757. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40758. */
  40759. class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  40760. /**
  40761. * Defines the camera the input is attached to.
  40762. */
  40763. camera: FlyCamera;
  40764. /**
  40765. * The list of keyboard keys used to control the forward move of the camera.
  40766. */
  40767. keysForward: number[];
  40768. /**
  40769. * The list of keyboard keys used to control the backward move of the camera.
  40770. */
  40771. keysBackward: number[];
  40772. /**
  40773. * The list of keyboard keys used to control the forward move of the camera.
  40774. */
  40775. keysUp: number[];
  40776. /**
  40777. * The list of keyboard keys used to control the backward move of the camera.
  40778. */
  40779. keysDown: number[];
  40780. /**
  40781. * The list of keyboard keys used to control the right strafe move of the camera.
  40782. */
  40783. keysRight: number[];
  40784. /**
  40785. * The list of keyboard keys used to control the left strafe move of the camera.
  40786. */
  40787. keysLeft: number[];
  40788. private _keys;
  40789. private _onCanvasBlurObserver;
  40790. private _onKeyboardObserver;
  40791. private _engine;
  40792. private _scene;
  40793. /**
  40794. * Attach the input controls to a specific dom element to get the input from.
  40795. * @param element Defines the element the controls should be listened from
  40796. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40797. */
  40798. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40799. /**
  40800. * Detach the current controls from the specified dom element.
  40801. * @param element Defines the element to stop listening the inputs from
  40802. */
  40803. detachControl(element: Nullable<HTMLElement>): void;
  40804. /**
  40805. * Gets the class name of the current intput.
  40806. * @returns the class name
  40807. */
  40808. getClassName(): string;
  40809. /** @hidden */
  40810. _onLostFocus(e: FocusEvent): void;
  40811. /**
  40812. * Get the friendly name associated with the input class.
  40813. * @returns the input friendly name
  40814. */
  40815. getSimpleName(): string;
  40816. /**
  40817. * Update the current camera state depending on the inputs that have been used this frame.
  40818. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40819. */
  40820. checkInputs(): void;
  40821. }
  40822. }
  40823. declare module BABYLON {
  40824. /**
  40825. * Listen to mouse events to control the camera.
  40826. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40827. */
  40828. class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  40829. /**
  40830. * Defines the camera the input is attached to.
  40831. */
  40832. camera: FlyCamera;
  40833. /**
  40834. * Defines if touch is enabled. (Default is true.)
  40835. */
  40836. touchEnabled: boolean;
  40837. /**
  40838. * Defines the buttons associated with the input to handle camera rotation.
  40839. */
  40840. buttons: number[];
  40841. /**
  40842. * Assign buttons for Yaw control.
  40843. */
  40844. buttonsYaw: number[];
  40845. /**
  40846. * Assign buttons for Pitch control.
  40847. */
  40848. buttonsPitch: number[];
  40849. /**
  40850. * Assign buttons for Roll control.
  40851. */
  40852. buttonsRoll: number[];
  40853. /**
  40854. * Detect if any button is being pressed while mouse is moved.
  40855. * -1 = Mouse locked.
  40856. * 0 = Left button.
  40857. * 1 = Middle Button.
  40858. * 2 = Right Button.
  40859. */
  40860. activeButton: number;
  40861. /**
  40862. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  40863. * Higher values reduce its sensitivity.
  40864. */
  40865. angularSensibility: number;
  40866. private _mousemoveCallback;
  40867. private _observer;
  40868. private _rollObserver;
  40869. private previousPosition;
  40870. private noPreventDefault;
  40871. private element;
  40872. /**
  40873. * Listen to mouse events to control the camera.
  40874. * @param touchEnabled Define if touch is enabled. (Default is true.)
  40875. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40876. */
  40877. constructor(touchEnabled?: boolean);
  40878. /**
  40879. * Attach the mouse control to the HTML DOM element.
  40880. * @param element Defines the element that listens to the input events.
  40881. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  40882. */
  40883. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40884. /**
  40885. * Detach the current controls from the specified dom element.
  40886. * @param element Defines the element to stop listening the inputs from
  40887. */
  40888. detachControl(element: Nullable<HTMLElement>): void;
  40889. /**
  40890. * Gets the class name of the current input.
  40891. * @returns the class name.
  40892. */
  40893. getClassName(): string;
  40894. /**
  40895. * Get the friendly name associated with the input class.
  40896. * @returns the input's friendly name.
  40897. */
  40898. getSimpleName(): string;
  40899. private _pointerInput;
  40900. private _onMouseMove;
  40901. /**
  40902. * Rotate camera by mouse offset.
  40903. */
  40904. private rotateCamera;
  40905. }
  40906. }
  40907. declare module BABYLON {
  40908. /**
  40909. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  40910. * Screen rotation is taken into account.
  40911. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40912. */
  40913. class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  40914. private _camera;
  40915. private _screenOrientationAngle;
  40916. private _constantTranform;
  40917. private _screenQuaternion;
  40918. private _alpha;
  40919. private _beta;
  40920. private _gamma;
  40921. /**
  40922. * Instantiates a new input
  40923. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40924. */
  40925. constructor();
  40926. /**
  40927. * Define the camera controlled by the input.
  40928. */
  40929. camera: FreeCamera;
  40930. /**
  40931. * Attach the input controls to a specific dom element to get the input from.
  40932. * @param element Defines the element the controls should be listened from
  40933. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40934. */
  40935. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40936. private _orientationChanged;
  40937. private _deviceOrientation;
  40938. /**
  40939. * Detach the current controls from the specified dom element.
  40940. * @param element Defines the element to stop listening the inputs from
  40941. */
  40942. detachControl(element: Nullable<HTMLElement>): void;
  40943. /**
  40944. * Update the current camera state depending on the inputs that have been used this frame.
  40945. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40946. */
  40947. checkInputs(): void;
  40948. /**
  40949. * Gets the class name of the current intput.
  40950. * @returns the class name
  40951. */
  40952. getClassName(): string;
  40953. /**
  40954. * Get the friendly name associated with the input class.
  40955. * @returns the input friendly name
  40956. */
  40957. getSimpleName(): string;
  40958. }
  40959. }
  40960. declare module BABYLON {
  40961. /**
  40962. * Manage the gamepad inputs to control a free camera.
  40963. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40964. */
  40965. class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  40966. /**
  40967. * Define the camera the input is attached to.
  40968. */
  40969. camera: FreeCamera;
  40970. /**
  40971. * Define the Gamepad controlling the input
  40972. */
  40973. gamepad: Nullable<Gamepad>;
  40974. /**
  40975. * Defines the gamepad rotation sensiblity.
  40976. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40977. */
  40978. gamepadAngularSensibility: number;
  40979. /**
  40980. * Defines the gamepad move sensiblity.
  40981. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40982. */
  40983. gamepadMoveSensibility: number;
  40984. private _onGamepadConnectedObserver;
  40985. private _onGamepadDisconnectedObserver;
  40986. private _cameraTransform;
  40987. private _deltaTransform;
  40988. private _vector3;
  40989. private _vector2;
  40990. /**
  40991. * Attach the input controls to a specific dom element to get the input from.
  40992. * @param element Defines the element the controls should be listened from
  40993. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40994. */
  40995. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40996. /**
  40997. * Detach the current controls from the specified dom element.
  40998. * @param element Defines the element to stop listening the inputs from
  40999. */
  41000. detachControl(element: Nullable<HTMLElement>): void;
  41001. /**
  41002. * Update the current camera state depending on the inputs that have been used this frame.
  41003. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41004. */
  41005. checkInputs(): void;
  41006. /**
  41007. * Gets the class name of the current intput.
  41008. * @returns the class name
  41009. */
  41010. getClassName(): string;
  41011. /**
  41012. * Get the friendly name associated with the input class.
  41013. * @returns the input friendly name
  41014. */
  41015. getSimpleName(): string;
  41016. }
  41017. }
  41018. declare module BABYLON {
  41019. /**
  41020. * Manage the keyboard inputs to control the movement of a free camera.
  41021. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41022. */
  41023. class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  41024. /**
  41025. * Defines the camera the input is attached to.
  41026. */
  41027. camera: FreeCamera;
  41028. /**
  41029. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  41030. */
  41031. keysUp: number[];
  41032. /**
  41033. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  41034. */
  41035. keysDown: number[];
  41036. /**
  41037. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  41038. */
  41039. keysLeft: number[];
  41040. /**
  41041. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  41042. */
  41043. keysRight: number[];
  41044. private _keys;
  41045. private _onCanvasBlurObserver;
  41046. private _onKeyboardObserver;
  41047. private _engine;
  41048. private _scene;
  41049. /**
  41050. * Attach the input controls to a specific dom element to get the input from.
  41051. * @param element Defines the element the controls should be listened from
  41052. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41053. */
  41054. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41055. /**
  41056. * Detach the current controls from the specified dom element.
  41057. * @param element Defines the element to stop listening the inputs from
  41058. */
  41059. detachControl(element: Nullable<HTMLElement>): void;
  41060. /**
  41061. * Update the current camera state depending on the inputs that have been used this frame.
  41062. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41063. */
  41064. checkInputs(): void;
  41065. /**
  41066. * Gets the class name of the current intput.
  41067. * @returns the class name
  41068. */
  41069. getClassName(): string;
  41070. /** @hidden */
  41071. _onLostFocus(e: FocusEvent): void;
  41072. /**
  41073. * Get the friendly name associated with the input class.
  41074. * @returns the input friendly name
  41075. */
  41076. getSimpleName(): string;
  41077. }
  41078. }
  41079. declare module BABYLON {
  41080. /**
  41081. * Manage the mouse inputs to control the movement of a free camera.
  41082. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41083. */
  41084. class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  41085. /**
  41086. * Define if touch is enabled in the mouse input
  41087. */
  41088. touchEnabled: boolean;
  41089. /**
  41090. * Defines the camera the input is attached to.
  41091. */
  41092. camera: FreeCamera;
  41093. /**
  41094. * Defines the buttons associated with the input to handle camera move.
  41095. */
  41096. buttons: number[];
  41097. /**
  41098. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  41099. */
  41100. angularSensibility: number;
  41101. private _pointerInput;
  41102. private _onMouseMove;
  41103. private _observer;
  41104. private previousPosition;
  41105. /**
  41106. * Manage the mouse inputs to control the movement of a free camera.
  41107. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41108. * @param touchEnabled Defines if touch is enabled or not
  41109. */
  41110. constructor(
  41111. /**
  41112. * Define if touch is enabled in the mouse input
  41113. */
  41114. touchEnabled?: boolean);
  41115. /**
  41116. * Attach the input controls to a specific dom element to get the input from.
  41117. * @param element Defines the element the controls should be listened from
  41118. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41119. */
  41120. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41121. /**
  41122. * Detach the current controls from the specified dom element.
  41123. * @param element Defines the element to stop listening the inputs from
  41124. */
  41125. detachControl(element: Nullable<HTMLElement>): void;
  41126. /**
  41127. * Gets the class name of the current intput.
  41128. * @returns the class name
  41129. */
  41130. getClassName(): string;
  41131. /**
  41132. * Get the friendly name associated with the input class.
  41133. * @returns the input friendly name
  41134. */
  41135. getSimpleName(): string;
  41136. }
  41137. }
  41138. declare module BABYLON {
  41139. /**
  41140. * Manage the touch inputs to control the movement of a free camera.
  41141. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41142. */
  41143. class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  41144. /**
  41145. * Defines the camera the input is attached to.
  41146. */
  41147. camera: FreeCamera;
  41148. /**
  41149. * Defines the touch sensibility for rotation.
  41150. * The higher the faster.
  41151. */
  41152. touchAngularSensibility: number;
  41153. /**
  41154. * Defines the touch sensibility for move.
  41155. * The higher the faster.
  41156. */
  41157. touchMoveSensibility: number;
  41158. private _offsetX;
  41159. private _offsetY;
  41160. private _pointerPressed;
  41161. private _pointerInput;
  41162. private _observer;
  41163. private _onLostFocus;
  41164. /**
  41165. * Attach the input controls to a specific dom element to get the input from.
  41166. * @param element Defines the element the controls should be listened from
  41167. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41168. */
  41169. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41170. /**
  41171. * Detach the current controls from the specified dom element.
  41172. * @param element Defines the element to stop listening the inputs from
  41173. */
  41174. detachControl(element: Nullable<HTMLElement>): void;
  41175. /**
  41176. * Update the current camera state depending on the inputs that have been used this frame.
  41177. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41178. */
  41179. checkInputs(): void;
  41180. /**
  41181. * Gets the class name of the current intput.
  41182. * @returns the class name
  41183. */
  41184. getClassName(): string;
  41185. /**
  41186. * Get the friendly name associated with the input class.
  41187. * @returns the input friendly name
  41188. */
  41189. getSimpleName(): string;
  41190. }
  41191. }
  41192. declare module BABYLON {
  41193. /**
  41194. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  41195. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41196. */
  41197. class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  41198. /**
  41199. * Defines the camera the input is attached to.
  41200. */
  41201. camera: FreeCamera;
  41202. private _leftjoystick;
  41203. private _rightjoystick;
  41204. /**
  41205. * Gets the left stick of the virtual joystick.
  41206. * @returns The virtual Joystick
  41207. */
  41208. getLeftJoystick(): VirtualJoystick;
  41209. /**
  41210. * Gets the right stick of the virtual joystick.
  41211. * @returns The virtual Joystick
  41212. */
  41213. getRightJoystick(): VirtualJoystick;
  41214. /**
  41215. * Update the current camera state depending on the inputs that have been used this frame.
  41216. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41217. */
  41218. checkInputs(): void;
  41219. /**
  41220. * Attach the input controls to a specific dom element to get the input from.
  41221. * @param element Defines the element the controls should be listened from
  41222. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41223. */
  41224. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41225. /**
  41226. * Detach the current controls from the specified dom element.
  41227. * @param element Defines the element to stop listening the inputs from
  41228. */
  41229. detachControl(element: Nullable<HTMLElement>): void;
  41230. /**
  41231. * Gets the class name of the current intput.
  41232. * @returns the class name
  41233. */
  41234. getClassName(): string;
  41235. /**
  41236. * Get the friendly name associated with the input class.
  41237. * @returns the input friendly name
  41238. */
  41239. getSimpleName(): string;
  41240. }
  41241. }
  41242. declare module BABYLON {
  41243. /**
  41244. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  41245. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41246. */
  41247. class AnaglyphArcRotateCamera extends ArcRotateCamera {
  41248. /**
  41249. * Creates a new AnaglyphArcRotateCamera
  41250. * @param name defines camera name
  41251. * @param alpha defines alpha angle (in radians)
  41252. * @param beta defines beta angle (in radians)
  41253. * @param radius defines radius
  41254. * @param target defines camera target
  41255. * @param interaxialDistance defines distance between each color axis
  41256. * @param scene defines the hosting scene
  41257. */
  41258. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  41259. /**
  41260. * Gets camera class name
  41261. * @returns AnaglyphArcRotateCamera
  41262. */
  41263. getClassName(): string;
  41264. }
  41265. }
  41266. declare module BABYLON {
  41267. /**
  41268. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  41269. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41270. */
  41271. class AnaglyphFreeCamera extends FreeCamera {
  41272. /**
  41273. * Creates a new AnaglyphFreeCamera
  41274. * @param name defines camera name
  41275. * @param position defines initial position
  41276. * @param interaxialDistance defines distance between each color axis
  41277. * @param scene defines the hosting scene
  41278. */
  41279. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41280. /**
  41281. * Gets camera class name
  41282. * @returns AnaglyphFreeCamera
  41283. */
  41284. getClassName(): string;
  41285. }
  41286. }
  41287. declare module BABYLON {
  41288. /**
  41289. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  41290. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41291. */
  41292. class AnaglyphGamepadCamera extends GamepadCamera {
  41293. /**
  41294. * Creates a new AnaglyphGamepadCamera
  41295. * @param name defines camera name
  41296. * @param position defines initial position
  41297. * @param interaxialDistance defines distance between each color axis
  41298. * @param scene defines the hosting scene
  41299. */
  41300. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41301. /**
  41302. * Gets camera class name
  41303. * @returns AnaglyphGamepadCamera
  41304. */
  41305. getClassName(): string;
  41306. }
  41307. }
  41308. declare module BABYLON {
  41309. /**
  41310. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  41311. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41312. */
  41313. class AnaglyphUniversalCamera extends UniversalCamera {
  41314. /**
  41315. * Creates a new AnaglyphUniversalCamera
  41316. * @param name defines camera name
  41317. * @param position defines initial position
  41318. * @param interaxialDistance defines distance between each color axis
  41319. * @param scene defines the hosting scene
  41320. */
  41321. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41322. /**
  41323. * Gets camera class name
  41324. * @returns AnaglyphUniversalCamera
  41325. */
  41326. getClassName(): string;
  41327. }
  41328. }
  41329. declare module BABYLON {
  41330. /**
  41331. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  41332. * @see http://doc.babylonjs.com/features/cameras
  41333. */
  41334. class StereoscopicArcRotateCamera extends ArcRotateCamera {
  41335. /**
  41336. * Creates a new StereoscopicArcRotateCamera
  41337. * @param name defines camera name
  41338. * @param alpha defines alpha angle (in radians)
  41339. * @param beta defines beta angle (in radians)
  41340. * @param radius defines radius
  41341. * @param target defines camera target
  41342. * @param interaxialDistance defines distance between each color axis
  41343. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41344. * @param scene defines the hosting scene
  41345. */
  41346. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41347. /**
  41348. * Gets camera class name
  41349. * @returns StereoscopicArcRotateCamera
  41350. */
  41351. getClassName(): string;
  41352. }
  41353. }
  41354. declare module BABYLON {
  41355. /**
  41356. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  41357. * @see http://doc.babylonjs.com/features/cameras
  41358. */
  41359. class StereoscopicFreeCamera extends FreeCamera {
  41360. /**
  41361. * Creates a new StereoscopicFreeCamera
  41362. * @param name defines camera name
  41363. * @param position defines initial position
  41364. * @param interaxialDistance defines distance between each color axis
  41365. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41366. * @param scene defines the hosting scene
  41367. */
  41368. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41369. /**
  41370. * Gets camera class name
  41371. * @returns StereoscopicFreeCamera
  41372. */
  41373. getClassName(): string;
  41374. }
  41375. }
  41376. declare module BABYLON {
  41377. /**
  41378. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  41379. * @see http://doc.babylonjs.com/features/cameras
  41380. */
  41381. class StereoscopicGamepadCamera extends GamepadCamera {
  41382. /**
  41383. * Creates a new StereoscopicGamepadCamera
  41384. * @param name defines camera name
  41385. * @param position defines initial position
  41386. * @param interaxialDistance defines distance between each color axis
  41387. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41388. * @param scene defines the hosting scene
  41389. */
  41390. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41391. /**
  41392. * Gets camera class name
  41393. * @returns StereoscopicGamepadCamera
  41394. */
  41395. getClassName(): string;
  41396. }
  41397. }
  41398. declare module BABYLON {
  41399. /**
  41400. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  41401. * @see http://doc.babylonjs.com/features/cameras
  41402. */
  41403. class StereoscopicUniversalCamera extends UniversalCamera {
  41404. /**
  41405. * Creates a new StereoscopicUniversalCamera
  41406. * @param name defines camera name
  41407. * @param position defines initial position
  41408. * @param interaxialDistance defines distance between each color axis
  41409. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41410. * @param scene defines the hosting scene
  41411. */
  41412. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41413. /**
  41414. * Gets camera class name
  41415. * @returns StereoscopicUniversalCamera
  41416. */
  41417. getClassName(): string;
  41418. }
  41419. }
  41420. declare module BABYLON {
  41421. /**
  41422. * This represents all the required metrics to create a VR camera.
  41423. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  41424. */
  41425. class VRCameraMetrics {
  41426. /**
  41427. * Define the horizontal resolution off the screen.
  41428. */
  41429. hResolution: number;
  41430. /**
  41431. * Define the vertical resolution off the screen.
  41432. */
  41433. vResolution: number;
  41434. /**
  41435. * Define the horizontal screen size.
  41436. */
  41437. hScreenSize: number;
  41438. /**
  41439. * Define the vertical screen size.
  41440. */
  41441. vScreenSize: number;
  41442. /**
  41443. * Define the vertical screen center position.
  41444. */
  41445. vScreenCenter: number;
  41446. /**
  41447. * Define the distance of the eyes to the screen.
  41448. */
  41449. eyeToScreenDistance: number;
  41450. /**
  41451. * Define the distance between both lenses
  41452. */
  41453. lensSeparationDistance: number;
  41454. /**
  41455. * Define the distance between both viewer's eyes.
  41456. */
  41457. interpupillaryDistance: number;
  41458. /**
  41459. * Define the distortion factor of the VR postprocess.
  41460. * Please, touch with care.
  41461. */
  41462. distortionK: number[];
  41463. /**
  41464. * Define the chromatic aberration correction factors for the VR post process.
  41465. */
  41466. chromaAbCorrection: number[];
  41467. /**
  41468. * Define the scale factor of the post process.
  41469. * The smaller the better but the slower.
  41470. */
  41471. postProcessScaleFactor: number;
  41472. /**
  41473. * Define an offset for the lens center.
  41474. */
  41475. lensCenterOffset: number;
  41476. /**
  41477. * Define if the current vr camera should compensate the distortion of the lense or not.
  41478. */
  41479. compensateDistortion: boolean;
  41480. /**
  41481. * Gets the rendering aspect ratio based on the provided resolutions.
  41482. */
  41483. readonly aspectRatio: number;
  41484. /**
  41485. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  41486. */
  41487. readonly aspectRatioFov: number;
  41488. /**
  41489. * @hidden
  41490. */
  41491. readonly leftHMatrix: Matrix;
  41492. /**
  41493. * @hidden
  41494. */
  41495. readonly rightHMatrix: Matrix;
  41496. /**
  41497. * @hidden
  41498. */
  41499. readonly leftPreViewMatrix: Matrix;
  41500. /**
  41501. * @hidden
  41502. */
  41503. readonly rightPreViewMatrix: Matrix;
  41504. /**
  41505. * Get the default VRMetrics based on the most generic setup.
  41506. * @returns the default vr metrics
  41507. */
  41508. static GetDefault(): VRCameraMetrics;
  41509. }
  41510. }
  41511. declare module BABYLON {
  41512. /**
  41513. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  41514. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41515. */
  41516. class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  41517. /**
  41518. * Creates a new VRDeviceOrientationArcRotateCamera
  41519. * @param name defines camera name
  41520. * @param alpha defines the camera rotation along the logitudinal axis
  41521. * @param beta defines the camera rotation along the latitudinal axis
  41522. * @param radius defines the camera distance from its target
  41523. * @param target defines the camera target
  41524. * @param scene defines the scene the camera belongs to
  41525. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41526. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41527. */
  41528. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41529. /**
  41530. * Gets camera class name
  41531. * @returns VRDeviceOrientationArcRotateCamera
  41532. */
  41533. getClassName(): string;
  41534. }
  41535. }
  41536. declare module BABYLON {
  41537. /**
  41538. * Camera used to simulate VR rendering (based on FreeCamera)
  41539. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41540. */
  41541. class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  41542. /**
  41543. * Creates a new VRDeviceOrientationFreeCamera
  41544. * @param name defines camera name
  41545. * @param position defines the start position of the camera
  41546. * @param scene defines the scene the camera belongs to
  41547. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41548. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41549. */
  41550. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41551. /**
  41552. * Gets camera class name
  41553. * @returns VRDeviceOrientationFreeCamera
  41554. */
  41555. getClassName(): string;
  41556. }
  41557. }
  41558. declare module BABYLON {
  41559. /**
  41560. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  41561. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41562. */
  41563. class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  41564. /**
  41565. * Creates a new VRDeviceOrientationGamepadCamera
  41566. * @param name defines camera name
  41567. * @param position defines the start position of the camera
  41568. * @param scene defines the scene the camera belongs to
  41569. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41570. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41571. */
  41572. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41573. /**
  41574. * Gets camera class name
  41575. * @returns VRDeviceOrientationGamepadCamera
  41576. */
  41577. getClassName(): string;
  41578. }
  41579. }
  41580. declare module BABYLON {
  41581. /**
  41582. * Options to modify the vr teleportation behavior.
  41583. */
  41584. interface VRTeleportationOptions {
  41585. /**
  41586. * The name of the mesh which should be used as the teleportation floor. (default: null)
  41587. */
  41588. floorMeshName?: string;
  41589. /**
  41590. * A list of meshes to be used as the teleportation floor. (default: empty)
  41591. */
  41592. floorMeshes?: Mesh[];
  41593. }
  41594. /**
  41595. * Options to modify the vr experience helper's behavior.
  41596. */
  41597. interface VRExperienceHelperOptions extends WebVROptions {
  41598. /**
  41599. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  41600. */
  41601. createDeviceOrientationCamera?: boolean;
  41602. /**
  41603. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  41604. */
  41605. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  41606. /**
  41607. * Uses the main button on the controller to toggle the laser casted. (default: true)
  41608. */
  41609. laserToggle?: boolean;
  41610. /**
  41611. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  41612. */
  41613. floorMeshes?: Mesh[];
  41614. }
  41615. /**
  41616. * Helps to quickly add VR support to an existing scene.
  41617. * See http://doc.babylonjs.com/how_to/webvr_helper
  41618. */
  41619. class VRExperienceHelper {
  41620. /** Options to modify the vr experience helper's behavior. */
  41621. webVROptions: VRExperienceHelperOptions;
  41622. private _scene;
  41623. private _position;
  41624. private _btnVR;
  41625. private _btnVRDisplayed;
  41626. private _webVRsupported;
  41627. private _webVRready;
  41628. private _webVRrequesting;
  41629. private _webVRpresenting;
  41630. private _hasEnteredVR;
  41631. private _fullscreenVRpresenting;
  41632. private _canvas;
  41633. private _webVRCamera;
  41634. private _vrDeviceOrientationCamera;
  41635. private _deviceOrientationCamera;
  41636. private _existingCamera;
  41637. private _onKeyDown;
  41638. private _onVrDisplayPresentChange;
  41639. private _onVRDisplayChanged;
  41640. private _onVRRequestPresentStart;
  41641. private _onVRRequestPresentComplete;
  41642. /**
  41643. * Observable raised when entering VR.
  41644. */
  41645. onEnteringVRObservable: Observable<VRExperienceHelper>;
  41646. /**
  41647. * Observable raised when exiting VR.
  41648. */
  41649. onExitingVRObservable: Observable<VRExperienceHelper>;
  41650. /**
  41651. * Observable raised when controller mesh is loaded.
  41652. */
  41653. onControllerMeshLoadedObservable: Observable<WebVRController>;
  41654. /** Return this.onEnteringVRObservable
  41655. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  41656. */
  41657. readonly onEnteringVR: Observable<VRExperienceHelper>;
  41658. /** Return this.onExitingVRObservable
  41659. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  41660. */
  41661. readonly onExitingVR: Observable<VRExperienceHelper>;
  41662. /** Return this.onControllerMeshLoadedObservable
  41663. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  41664. */
  41665. readonly onControllerMeshLoaded: Observable<WebVRController>;
  41666. private _rayLength;
  41667. private _useCustomVRButton;
  41668. private _teleportationRequested;
  41669. private _teleportActive;
  41670. private _floorMeshName;
  41671. private _floorMeshesCollection;
  41672. private _rotationAllowed;
  41673. private _teleportBackwardsVector;
  41674. private _teleportationTarget;
  41675. private _isDefaultTeleportationTarget;
  41676. private _postProcessMove;
  41677. private _teleportationFillColor;
  41678. private _teleportationBorderColor;
  41679. private _rotationAngle;
  41680. private _haloCenter;
  41681. private _cameraGazer;
  41682. private _padSensibilityUp;
  41683. private _padSensibilityDown;
  41684. private _leftController;
  41685. private _rightController;
  41686. /**
  41687. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  41688. */
  41689. onNewMeshSelected: Observable<AbstractMesh>;
  41690. /**
  41691. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  41692. */
  41693. onNewMeshPicked: Observable<PickingInfo>;
  41694. private _circleEase;
  41695. /**
  41696. * Observable raised before camera teleportation
  41697. */
  41698. onBeforeCameraTeleport: Observable<Vector3>;
  41699. /**
  41700. * Observable raised after camera teleportation
  41701. */
  41702. onAfterCameraTeleport: Observable<Vector3>;
  41703. /**
  41704. * Observable raised when current selected mesh gets unselected
  41705. */
  41706. onSelectedMeshUnselected: Observable<AbstractMesh>;
  41707. private _raySelectionPredicate;
  41708. /**
  41709. * To be optionaly changed by user to define custom ray selection
  41710. */
  41711. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  41712. /**
  41713. * To be optionaly changed by user to define custom selection logic (after ray selection)
  41714. */
  41715. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  41716. /**
  41717. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  41718. */
  41719. teleportationEnabled: boolean;
  41720. private _defaultHeight;
  41721. private _teleportationInitialized;
  41722. private _interactionsEnabled;
  41723. private _interactionsRequested;
  41724. private _displayGaze;
  41725. private _displayLaserPointer;
  41726. /**
  41727. * The mesh used to display where the user is going to teleport.
  41728. */
  41729. /**
  41730. * Sets the mesh to be used to display where the user is going to teleport.
  41731. */
  41732. teleportationTarget: Mesh;
  41733. /**
  41734. * 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
  41735. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  41736. * See http://doc.babylonjs.com/resources/baking_transformations
  41737. */
  41738. gazeTrackerMesh: Mesh;
  41739. /**
  41740. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  41741. */
  41742. updateGazeTrackerScale: boolean;
  41743. /**
  41744. * The gaze tracking mesh corresponding to the left controller
  41745. */
  41746. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  41747. /**
  41748. * The gaze tracking mesh corresponding to the right controller
  41749. */
  41750. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  41751. /**
  41752. * If the ray of the gaze should be displayed.
  41753. */
  41754. /**
  41755. * Sets if the ray of the gaze should be displayed.
  41756. */
  41757. displayGaze: boolean;
  41758. /**
  41759. * If the ray of the LaserPointer should be displayed.
  41760. */
  41761. /**
  41762. * Sets if the ray of the LaserPointer should be displayed.
  41763. */
  41764. displayLaserPointer: boolean;
  41765. /**
  41766. * The deviceOrientationCamera used as the camera when not in VR.
  41767. */
  41768. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  41769. /**
  41770. * Based on the current WebVR support, returns the current VR camera used.
  41771. */
  41772. readonly currentVRCamera: Nullable<Camera>;
  41773. /**
  41774. * The webVRCamera which is used when in VR.
  41775. */
  41776. readonly webVRCamera: WebVRFreeCamera;
  41777. /**
  41778. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  41779. */
  41780. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  41781. private readonly _teleportationRequestInitiated;
  41782. /**
  41783. * Instantiates a VRExperienceHelper.
  41784. * Helps to quickly add VR support to an existing scene.
  41785. * @param scene The scene the VRExperienceHelper belongs to.
  41786. * @param webVROptions Options to modify the vr experience helper's behavior.
  41787. */
  41788. constructor(scene: Scene,
  41789. /** Options to modify the vr experience helper's behavior. */
  41790. webVROptions?: VRExperienceHelperOptions);
  41791. private _onDefaultMeshLoaded;
  41792. private _onResize;
  41793. private _onFullscreenChange;
  41794. /**
  41795. * Gets a value indicating if we are currently in VR mode.
  41796. */
  41797. readonly isInVRMode: boolean;
  41798. private onVrDisplayPresentChange;
  41799. private onVRDisplayChanged;
  41800. private moveButtonToBottomRight;
  41801. private displayVRButton;
  41802. private updateButtonVisibility;
  41803. /**
  41804. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  41805. * Otherwise, will use the fullscreen API.
  41806. */
  41807. enterVR(): void;
  41808. /**
  41809. * Attempt to exit VR, or fullscreen.
  41810. */
  41811. exitVR(): void;
  41812. /**
  41813. * The position of the vr experience helper.
  41814. */
  41815. /**
  41816. * Sets the position of the vr experience helper.
  41817. */
  41818. position: Vector3;
  41819. /**
  41820. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  41821. */
  41822. enableInteractions(): void;
  41823. private readonly _noControllerIsActive;
  41824. private beforeRender;
  41825. private _isTeleportationFloor;
  41826. /**
  41827. * Adds a floor mesh to be used for teleportation.
  41828. * @param floorMesh the mesh to be used for teleportation.
  41829. */
  41830. addFloorMesh(floorMesh: Mesh): void;
  41831. /**
  41832. * Removes a floor mesh from being used for teleportation.
  41833. * @param floorMesh the mesh to be removed.
  41834. */
  41835. removeFloorMesh(floorMesh: Mesh): void;
  41836. /**
  41837. * Enables interactions and teleportation using the VR controllers and gaze.
  41838. * @param vrTeleportationOptions options to modify teleportation behavior.
  41839. */
  41840. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  41841. private _onNewGamepadConnected;
  41842. private _tryEnableInteractionOnController;
  41843. private _onNewGamepadDisconnected;
  41844. private _enableInteractionOnController;
  41845. private _checkTeleportWithRay;
  41846. private _checkRotate;
  41847. private _checkTeleportBackwards;
  41848. private _enableTeleportationOnController;
  41849. private _createTeleportationCircles;
  41850. private _displayTeleportationTarget;
  41851. private _hideTeleportationTarget;
  41852. private _rotateCamera;
  41853. private _moveTeleportationSelectorTo;
  41854. private _workingVector;
  41855. private _workingQuaternion;
  41856. private _workingMatrix;
  41857. /**
  41858. * Teleports the users feet to the desired location
  41859. * @param location The location where the user's feet should be placed
  41860. */
  41861. teleportCamera(location: Vector3): void;
  41862. private _convertNormalToDirectionOfRay;
  41863. private _castRayAndSelectObject;
  41864. private _notifySelectedMeshUnselected;
  41865. /**
  41866. * Sets the color of the laser ray from the vr controllers.
  41867. * @param color new color for the ray.
  41868. */
  41869. changeLaserColor(color: Color3): void;
  41870. /**
  41871. * Sets the color of the ray from the vr headsets gaze.
  41872. * @param color new color for the ray.
  41873. */
  41874. changeGazeColor(color: Color3): void;
  41875. /**
  41876. * Exits VR and disposes of the vr experience helper
  41877. */
  41878. dispose(): void;
  41879. /**
  41880. * Gets the name of the VRExperienceHelper class
  41881. * @returns "VRExperienceHelper"
  41882. */
  41883. getClassName(): string;
  41884. }
  41885. }
  41886. declare module BABYLON {
  41887. /**
  41888. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  41889. * IMPORTANT!! The data is right-hand data.
  41890. * @export
  41891. * @interface DevicePose
  41892. */
  41893. interface DevicePose {
  41894. /**
  41895. * The position of the device, values in array are [x,y,z].
  41896. */
  41897. readonly position: Nullable<Float32Array>;
  41898. /**
  41899. * The linearVelocity of the device, values in array are [x,y,z].
  41900. */
  41901. readonly linearVelocity: Nullable<Float32Array>;
  41902. /**
  41903. * The linearAcceleration of the device, values in array are [x,y,z].
  41904. */
  41905. readonly linearAcceleration: Nullable<Float32Array>;
  41906. /**
  41907. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  41908. */
  41909. readonly orientation: Nullable<Float32Array>;
  41910. /**
  41911. * The angularVelocity of the device, values in array are [x,y,z].
  41912. */
  41913. readonly angularVelocity: Nullable<Float32Array>;
  41914. /**
  41915. * The angularAcceleration of the device, values in array are [x,y,z].
  41916. */
  41917. readonly angularAcceleration: Nullable<Float32Array>;
  41918. }
  41919. /**
  41920. * Interface representing a pose controlled object in Babylon.
  41921. * A pose controlled object has both regular pose values as well as pose values
  41922. * from an external device such as a VR head mounted display
  41923. */
  41924. interface PoseControlled {
  41925. /**
  41926. * The position of the object in babylon space.
  41927. */
  41928. position: Vector3;
  41929. /**
  41930. * The rotation quaternion of the object in babylon space.
  41931. */
  41932. rotationQuaternion: Quaternion;
  41933. /**
  41934. * The position of the device in babylon space.
  41935. */
  41936. devicePosition?: Vector3;
  41937. /**
  41938. * The rotation quaternion of the device in babylon space.
  41939. */
  41940. deviceRotationQuaternion: Quaternion;
  41941. /**
  41942. * The raw pose coming from the device.
  41943. */
  41944. rawPose: Nullable<DevicePose>;
  41945. /**
  41946. * The scale of the device to be used when translating from device space to babylon space.
  41947. */
  41948. deviceScaleFactor: number;
  41949. /**
  41950. * Updates the poseControlled values based on the input device pose.
  41951. * @param poseData the pose data to update the object with
  41952. */
  41953. updateFromDevice(poseData: DevicePose): void;
  41954. }
  41955. /**
  41956. * Set of options to customize the webVRCamera
  41957. */
  41958. interface WebVROptions {
  41959. /**
  41960. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  41961. */
  41962. trackPosition?: boolean;
  41963. /**
  41964. * Sets the scale of the vrDevice in babylon space. (default: 1)
  41965. */
  41966. positionScale?: number;
  41967. /**
  41968. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  41969. */
  41970. displayName?: string;
  41971. /**
  41972. * Should the native controller meshes be initialized. (default: true)
  41973. */
  41974. controllerMeshes?: boolean;
  41975. /**
  41976. * Creating a default HemiLight only on controllers. (default: true)
  41977. */
  41978. defaultLightingOnControllers?: boolean;
  41979. /**
  41980. * If you don't want to use the default VR button of the helper. (default: false)
  41981. */
  41982. useCustomVRButton?: boolean;
  41983. /**
  41984. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  41985. */
  41986. customVRButton?: HTMLButtonElement;
  41987. /**
  41988. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  41989. */
  41990. rayLength?: number;
  41991. /**
  41992. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  41993. */
  41994. defaultHeight?: number;
  41995. }
  41996. /**
  41997. * This represents a WebVR camera.
  41998. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  41999. * @example http://doc.babylonjs.com/how_to/webvr_camera
  42000. */
  42001. class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  42002. private webVROptions;
  42003. /**
  42004. * @hidden
  42005. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  42006. */
  42007. _vrDevice: any;
  42008. /**
  42009. * The rawPose of the vrDevice.
  42010. */
  42011. rawPose: Nullable<DevicePose>;
  42012. private _onVREnabled;
  42013. private _specsVersion;
  42014. private _attached;
  42015. private _frameData;
  42016. protected _descendants: Array<Node>;
  42017. private _deviceRoomPosition;
  42018. /** @hidden */
  42019. _deviceRoomRotationQuaternion: Quaternion;
  42020. private _standingMatrix;
  42021. /**
  42022. * Represents device position in babylon space.
  42023. */
  42024. devicePosition: Vector3;
  42025. /**
  42026. * Represents device rotation in babylon space.
  42027. */
  42028. deviceRotationQuaternion: Quaternion;
  42029. /**
  42030. * The scale of the device to be used when translating from device space to babylon space.
  42031. */
  42032. deviceScaleFactor: number;
  42033. private _deviceToWorld;
  42034. private _worldToDevice;
  42035. /**
  42036. * References to the webVR controllers for the vrDevice.
  42037. */
  42038. controllers: Array<WebVRController>;
  42039. /**
  42040. * Emits an event when a controller is attached.
  42041. */
  42042. onControllersAttachedObservable: Observable<WebVRController[]>;
  42043. /**
  42044. * Emits an event when a controller's mesh has been loaded;
  42045. */
  42046. onControllerMeshLoadedObservable: Observable<WebVRController>;
  42047. /**
  42048. * Emits an event when the HMD's pose has been updated.
  42049. */
  42050. onPoseUpdatedFromDeviceObservable: Observable<any>;
  42051. private _poseSet;
  42052. /**
  42053. * If the rig cameras be used as parent instead of this camera.
  42054. */
  42055. rigParenting: boolean;
  42056. private _lightOnControllers;
  42057. private _defaultHeight?;
  42058. /**
  42059. * Instantiates a WebVRFreeCamera.
  42060. * @param name The name of the WebVRFreeCamera
  42061. * @param position The starting anchor position for the camera
  42062. * @param scene The scene the camera belongs to
  42063. * @param webVROptions a set of customizable options for the webVRCamera
  42064. */
  42065. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  42066. /**
  42067. * Gets the device distance from the ground in meters.
  42068. * @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.
  42069. */
  42070. deviceDistanceToRoomGround(): number;
  42071. /**
  42072. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  42073. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  42074. */
  42075. useStandingMatrix(callback?: (bool: boolean) => void): void;
  42076. /**
  42077. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  42078. * @returns A promise with a boolean set to if the standing matrix is supported.
  42079. */
  42080. useStandingMatrixAsync(): Promise<boolean>;
  42081. /**
  42082. * Disposes the camera
  42083. */
  42084. dispose(): void;
  42085. /**
  42086. * Gets a vrController by name.
  42087. * @param name The name of the controller to retreive
  42088. * @returns the controller matching the name specified or null if not found
  42089. */
  42090. getControllerByName(name: string): Nullable<WebVRController>;
  42091. private _leftController;
  42092. /**
  42093. * The controller corrisponding to the users left hand.
  42094. */
  42095. readonly leftController: Nullable<WebVRController>;
  42096. private _rightController;
  42097. /**
  42098. * The controller corrisponding to the users right hand.
  42099. */
  42100. readonly rightController: Nullable<WebVRController>;
  42101. /**
  42102. * Casts a ray forward from the vrCamera's gaze.
  42103. * @param length Length of the ray (default: 100)
  42104. * @returns the ray corrisponding to the gaze
  42105. */
  42106. getForwardRay(length?: number): Ray;
  42107. /**
  42108. * @hidden
  42109. * Updates the camera based on device's frame data
  42110. */
  42111. _checkInputs(): void;
  42112. /**
  42113. * Updates the poseControlled values based on the input device pose.
  42114. * @param poseData Pose coming from the device
  42115. */
  42116. updateFromDevice(poseData: DevicePose): void;
  42117. private _htmlElementAttached;
  42118. private _detachIfAttached;
  42119. /**
  42120. * WebVR's attach control will start broadcasting frames to the device.
  42121. * Note that in certain browsers (chrome for example) this function must be called
  42122. * within a user-interaction callback. Example:
  42123. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  42124. *
  42125. * @param element html element to attach the vrDevice to
  42126. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  42127. */
  42128. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42129. /**
  42130. * Detaches the camera from the html element and disables VR
  42131. *
  42132. * @param element html element to detach from
  42133. */
  42134. detachControl(element: HTMLElement): void;
  42135. /**
  42136. * @returns the name of this class
  42137. */
  42138. getClassName(): string;
  42139. /**
  42140. * Calls resetPose on the vrDisplay
  42141. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  42142. */
  42143. resetToCurrentRotation(): void;
  42144. /**
  42145. * @hidden
  42146. * Updates the rig cameras (left and right eye)
  42147. */
  42148. _updateRigCameras(): void;
  42149. private _workingVector;
  42150. private _oneVector;
  42151. private _workingMatrix;
  42152. private updateCacheCalled;
  42153. private _correctPositionIfNotTrackPosition;
  42154. /**
  42155. * @hidden
  42156. * Updates the cached values of the camera
  42157. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  42158. */
  42159. _updateCache(ignoreParentClass?: boolean): void;
  42160. /**
  42161. * @hidden
  42162. * Get current device position in babylon world
  42163. */
  42164. _computeDevicePosition(): void;
  42165. /**
  42166. * Updates the current device position and rotation in the babylon world
  42167. */
  42168. update(): void;
  42169. /**
  42170. * @hidden
  42171. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  42172. * @returns an identity matrix
  42173. */
  42174. _getViewMatrix(): Matrix;
  42175. private _tmpMatrix;
  42176. /**
  42177. * This function is called by the two RIG cameras.
  42178. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  42179. */
  42180. protected _getWebVRViewMatrix(): Matrix;
  42181. protected _getWebVRProjectionMatrix(): Matrix;
  42182. private _onGamepadConnectedObserver;
  42183. private _onGamepadDisconnectedObserver;
  42184. private _updateCacheWhenTrackingDisabledObserver;
  42185. /**
  42186. * Initializes the controllers and their meshes
  42187. */
  42188. initControllers(): void;
  42189. }
  42190. }
  42191. declare module BABYLON {
  42192. /**
  42193. * Contains an array of blocks representing the octree
  42194. */
  42195. interface IOctreeContainer<T> {
  42196. /**
  42197. * Blocks within the octree
  42198. */
  42199. blocks: Array<OctreeBlock<T>>;
  42200. }
  42201. /**
  42202. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  42203. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42204. */
  42205. class Octree<T> {
  42206. /** 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.) */
  42207. maxDepth: number;
  42208. /**
  42209. * Blocks within the octree containing objects
  42210. */
  42211. blocks: Array<OctreeBlock<T>>;
  42212. /**
  42213. * Content stored in the octree
  42214. */
  42215. dynamicContent: T[];
  42216. private _maxBlockCapacity;
  42217. private _selectionContent;
  42218. private _creationFunc;
  42219. /**
  42220. * Creates a octree
  42221. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42222. * @param creationFunc function to be used to instatiate the octree
  42223. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  42224. * @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.)
  42225. */
  42226. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  42227. /** 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.) */
  42228. maxDepth?: number);
  42229. /**
  42230. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  42231. * @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);
  42232. * @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);
  42233. * @param entries meshes to be added to the octree blocks
  42234. */
  42235. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  42236. /**
  42237. * Adds a mesh to the octree
  42238. * @param entry Mesh to add to the octree
  42239. */
  42240. addMesh(entry: T): void;
  42241. /**
  42242. * Selects an array of meshes within the frustum
  42243. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  42244. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  42245. * @returns array of meshes within the frustum
  42246. */
  42247. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  42248. /**
  42249. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  42250. * @param sphereCenter defines the bounding sphere center
  42251. * @param sphereRadius defines the bounding sphere radius
  42252. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42253. * @returns an array of objects that intersect the sphere
  42254. */
  42255. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  42256. /**
  42257. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  42258. * @param ray defines the ray to test with
  42259. * @returns array of intersected objects
  42260. */
  42261. intersectsRay(ray: Ray): SmartArray<T>;
  42262. /**
  42263. * @hidden
  42264. */
  42265. 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;
  42266. /**
  42267. * Adds a mesh into the octree block if it intersects the block
  42268. */
  42269. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  42270. /**
  42271. * Adds a submesh into the octree block if it intersects the block
  42272. */
  42273. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  42274. }
  42275. }
  42276. declare module BABYLON {
  42277. /**
  42278. * Class used to store a cell in an octree
  42279. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42280. */
  42281. class OctreeBlock<T> {
  42282. /**
  42283. * Gets the content of the current block
  42284. */
  42285. entries: T[];
  42286. /**
  42287. * Gets the list of block children
  42288. */
  42289. blocks: Array<OctreeBlock<T>>;
  42290. private _depth;
  42291. private _maxDepth;
  42292. private _capacity;
  42293. private _minPoint;
  42294. private _maxPoint;
  42295. private _boundingVectors;
  42296. private _creationFunc;
  42297. /**
  42298. * Creates a new block
  42299. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  42300. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  42301. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42302. * @param depth defines the current depth of this block in the octree
  42303. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  42304. * @param creationFunc defines a callback to call when an element is added to the block
  42305. */
  42306. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  42307. /**
  42308. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42309. */
  42310. readonly capacity: number;
  42311. /**
  42312. * Gets the minimum vector (in world space) of the block's bounding box
  42313. */
  42314. readonly minPoint: Vector3;
  42315. /**
  42316. * Gets the maximum vector (in world space) of the block's bounding box
  42317. */
  42318. readonly maxPoint: Vector3;
  42319. /**
  42320. * Add a new element to this block
  42321. * @param entry defines the element to add
  42322. */
  42323. addEntry(entry: T): void;
  42324. /**
  42325. * Add an array of elements to this block
  42326. * @param entries defines the array of elements to add
  42327. */
  42328. addEntries(entries: T[]): void;
  42329. /**
  42330. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  42331. * @param frustumPlanes defines the frustum planes to test
  42332. * @param selection defines the array to store current content if selection is positive
  42333. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42334. */
  42335. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42336. /**
  42337. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  42338. * @param sphereCenter defines the bounding sphere center
  42339. * @param sphereRadius defines the bounding sphere radius
  42340. * @param selection defines the array to store current content if selection is positive
  42341. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42342. */
  42343. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42344. /**
  42345. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  42346. * @param ray defines the ray to test with
  42347. * @param selection defines the array to store current content if selection is positive
  42348. */
  42349. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  42350. /**
  42351. * Subdivide the content into child blocks (this block will then be empty)
  42352. */
  42353. createInnerBlocks(): void;
  42354. }
  42355. }
  42356. declare module BABYLON {
  42357. interface Scene {
  42358. /**
  42359. * @hidden
  42360. * Backing Filed
  42361. */
  42362. _selectionOctree: Octree<AbstractMesh>;
  42363. /**
  42364. * Gets the octree used to boost mesh selection (picking)
  42365. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42366. */
  42367. selectionOctree: Octree<AbstractMesh>;
  42368. /**
  42369. * Creates or updates the octree used to boost selection (picking)
  42370. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42371. * @param maxCapacity defines the maximum capacity per leaf
  42372. * @param maxDepth defines the maximum depth of the octree
  42373. * @returns an octree of AbstractMesh
  42374. */
  42375. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  42376. }
  42377. interface AbstractMesh {
  42378. /**
  42379. * @hidden
  42380. * Backing Field
  42381. */
  42382. _submeshesOctree: Octree<SubMesh>;
  42383. /**
  42384. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  42385. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  42386. * @param maxCapacity defines the maximum size of each block (64 by default)
  42387. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  42388. * @returns the new octree
  42389. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  42390. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42391. */
  42392. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  42393. }
  42394. /**
  42395. * Defines the octree scene component responsible to manage any octrees
  42396. * in a given scene.
  42397. */
  42398. class OctreeSceneComponent {
  42399. /**
  42400. * The component name helpfull to identify the component in the list of scene components.
  42401. */
  42402. readonly name: string;
  42403. /**
  42404. * The scene the component belongs to.
  42405. */
  42406. scene: Scene;
  42407. /**
  42408. * Indicates if the meshes have been checked to make sure they are isEnabled()
  42409. */
  42410. readonly checksIsEnabled: boolean;
  42411. /**
  42412. * Creates a new instance of the component for the given scene
  42413. * @param scene Defines the scene to register the component in
  42414. */
  42415. constructor(scene: Scene);
  42416. /**
  42417. * Registers the component in a given scene
  42418. */
  42419. register(): void;
  42420. /**
  42421. * Return the list of active meshes
  42422. * @returns the list of active meshes
  42423. */
  42424. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  42425. /**
  42426. * Return the list of active sub meshes
  42427. * @param mesh The mesh to get the candidates sub meshes from
  42428. * @returns the list of active sub meshes
  42429. */
  42430. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  42431. private _tempRay;
  42432. /**
  42433. * Return the list of sub meshes intersecting with a given local ray
  42434. * @param mesh defines the mesh to find the submesh for
  42435. * @param localRay defines the ray in local space
  42436. * @returns the list of intersecting sub meshes
  42437. */
  42438. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  42439. /**
  42440. * Return the list of sub meshes colliding with a collider
  42441. * @param mesh defines the mesh to find the submesh for
  42442. * @param collider defines the collider to evaluate the collision against
  42443. * @returns the list of colliding sub meshes
  42444. */
  42445. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  42446. /**
  42447. * Rebuilds the elements related to this component in case of
  42448. * context lost for instance.
  42449. */
  42450. rebuild(): void;
  42451. /**
  42452. * Disposes the component and the associated ressources.
  42453. */
  42454. dispose(): void;
  42455. }
  42456. }
  42457. declare module BABYLON {
  42458. /** @hidden */
  42459. class _OcclusionDataStorage {
  42460. /** @hidden */
  42461. occlusionInternalRetryCounter: number;
  42462. /** @hidden */
  42463. isOcclusionQueryInProgress: boolean;
  42464. /** @hidden */
  42465. isOccluded: boolean;
  42466. /** @hidden */
  42467. occlusionRetryCount: number;
  42468. /** @hidden */
  42469. occlusionType: number;
  42470. /** @hidden */
  42471. occlusionQueryAlgorithmType: number;
  42472. }
  42473. interface Engine {
  42474. /**
  42475. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  42476. * @return the new query
  42477. */
  42478. createQuery(): WebGLQuery;
  42479. /**
  42480. * Delete and release a webGL query
  42481. * @param query defines the query to delete
  42482. * @return the current engine
  42483. */
  42484. deleteQuery(query: WebGLQuery): Engine;
  42485. /**
  42486. * Check if a given query has resolved and got its value
  42487. * @param query defines the query to check
  42488. * @returns true if the query got its value
  42489. */
  42490. isQueryResultAvailable(query: WebGLQuery): boolean;
  42491. /**
  42492. * Gets the value of a given query
  42493. * @param query defines the query to check
  42494. * @returns the value of the query
  42495. */
  42496. getQueryResult(query: WebGLQuery): number;
  42497. /**
  42498. * Initiates an occlusion query
  42499. * @param algorithmType defines the algorithm to use
  42500. * @param query defines the query to use
  42501. * @returns the current engine
  42502. * @see http://doc.babylonjs.com/features/occlusionquery
  42503. */
  42504. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  42505. /**
  42506. * Ends an occlusion query
  42507. * @see http://doc.babylonjs.com/features/occlusionquery
  42508. * @param algorithmType defines the algorithm to use
  42509. * @returns the current engine
  42510. */
  42511. endOcclusionQuery(algorithmType: number): Engine;
  42512. /**
  42513. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  42514. * Please note that only one query can be issued at a time
  42515. * @returns a time token used to track the time span
  42516. */
  42517. startTimeQuery(): Nullable<_TimeToken>;
  42518. /**
  42519. * Ends a time query
  42520. * @param token defines the token used to measure the time span
  42521. * @returns the time spent (in ns)
  42522. */
  42523. endTimeQuery(token: _TimeToken): int;
  42524. /** @hidden */
  42525. _currentNonTimestampToken: Nullable<_TimeToken>;
  42526. /** @hidden */
  42527. _createTimeQuery(): WebGLQuery;
  42528. /** @hidden */
  42529. _deleteTimeQuery(query: WebGLQuery): void;
  42530. /** @hidden */
  42531. _getGlAlgorithmType(algorithmType: number): number;
  42532. /** @hidden */
  42533. _getTimeQueryResult(query: WebGLQuery): any;
  42534. /** @hidden */
  42535. _getTimeQueryAvailability(query: WebGLQuery): any;
  42536. }
  42537. interface AbstractMesh {
  42538. /**
  42539. * Backing filed
  42540. * @hidden
  42541. */
  42542. __occlusionDataStorage: _OcclusionDataStorage;
  42543. /**
  42544. * Access property
  42545. * @hidden
  42546. */
  42547. _occlusionDataStorage: _OcclusionDataStorage;
  42548. /**
  42549. * 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.
  42550. * The default value is -1 which means don't break the query and wait till the result
  42551. * @see http://doc.babylonjs.com/features/occlusionquery
  42552. */
  42553. occlusionRetryCount: number;
  42554. /**
  42555. * 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:
  42556. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  42557. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  42558. * * 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.
  42559. * @see http://doc.babylonjs.com/features/occlusionquery
  42560. */
  42561. occlusionType: number;
  42562. /**
  42563. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  42564. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  42565. * * 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.
  42566. * @see http://doc.babylonjs.com/features/occlusionquery
  42567. */
  42568. occlusionQueryAlgorithmType: number;
  42569. /**
  42570. * 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
  42571. * @see http://doc.babylonjs.com/features/occlusionquery
  42572. */
  42573. isOccluded: boolean;
  42574. /**
  42575. * Flag to check the progress status of the query
  42576. * @see http://doc.babylonjs.com/features/occlusionquery
  42577. */
  42578. isOcclusionQueryInProgress: boolean;
  42579. }
  42580. }
  42581. declare module BABYLON {
  42582. interface Engine {
  42583. /**
  42584. * Creates a webGL transform feedback object
  42585. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  42586. * @returns the webGL transform feedback object
  42587. */
  42588. createTransformFeedback(): WebGLTransformFeedback;
  42589. /**
  42590. * Delete a webGL transform feedback object
  42591. * @param value defines the webGL transform feedback object to delete
  42592. */
  42593. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  42594. /**
  42595. * Bind a webGL transform feedback object to the webgl context
  42596. * @param value defines the webGL transform feedback object to bind
  42597. */
  42598. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  42599. /**
  42600. * Begins a transform feedback operation
  42601. * @param usePoints defines if points or triangles must be used
  42602. */
  42603. beginTransformFeedback(usePoints: boolean): void;
  42604. /**
  42605. * Ends a transform feedback operation
  42606. */
  42607. endTransformFeedback(): void;
  42608. /**
  42609. * Specify the varyings to use with transform feedback
  42610. * @param program defines the associated webGL program
  42611. * @param value defines the list of strings representing the varying names
  42612. */
  42613. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  42614. /**
  42615. * Bind a webGL buffer for a transform feedback operation
  42616. * @param value defines the webGL buffer to bind
  42617. */
  42618. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  42619. }
  42620. }
  42621. declare module BABYLON {
  42622. /**
  42623. * Google Daydream controller
  42624. */
  42625. class DaydreamController extends WebVRController {
  42626. /**
  42627. * Base Url for the controller model.
  42628. */
  42629. static MODEL_BASE_URL: string;
  42630. /**
  42631. * File name for the controller model.
  42632. */
  42633. static MODEL_FILENAME: string;
  42634. /**
  42635. * Gamepad Id prefix used to identify Daydream Controller.
  42636. */
  42637. static readonly GAMEPAD_ID_PREFIX: string;
  42638. /**
  42639. * Creates a new DaydreamController from a gamepad
  42640. * @param vrGamepad the gamepad that the controller should be created from
  42641. */
  42642. constructor(vrGamepad: any);
  42643. /**
  42644. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42645. * @param scene scene in which to add meshes
  42646. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42647. */
  42648. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42649. /**
  42650. * Called once for each button that changed state since the last frame
  42651. * @param buttonIdx Which button index changed
  42652. * @param state New state of the button
  42653. * @param changes Which properties on the state changed since last frame
  42654. */
  42655. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42656. }
  42657. }
  42658. declare module BABYLON {
  42659. /**
  42660. * Gear VR Controller
  42661. */
  42662. class GearVRController extends WebVRController {
  42663. /**
  42664. * Base Url for the controller model.
  42665. */
  42666. static MODEL_BASE_URL: string;
  42667. /**
  42668. * File name for the controller model.
  42669. */
  42670. static MODEL_FILENAME: string;
  42671. /**
  42672. * Gamepad Id prefix used to identify this controller.
  42673. */
  42674. static readonly GAMEPAD_ID_PREFIX: string;
  42675. private readonly _buttonIndexToObservableNameMap;
  42676. /**
  42677. * Creates a new GearVRController from a gamepad
  42678. * @param vrGamepad the gamepad that the controller should be created from
  42679. */
  42680. constructor(vrGamepad: any);
  42681. /**
  42682. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42683. * @param scene scene in which to add meshes
  42684. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42685. */
  42686. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42687. /**
  42688. * Called once for each button that changed state since the last frame
  42689. * @param buttonIdx Which button index changed
  42690. * @param state New state of the button
  42691. * @param changes Which properties on the state changed since last frame
  42692. */
  42693. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42694. }
  42695. }
  42696. declare module BABYLON {
  42697. /**
  42698. * Generic Controller
  42699. */
  42700. class GenericController extends WebVRController {
  42701. /**
  42702. * Base Url for the controller model.
  42703. */
  42704. static readonly MODEL_BASE_URL: string;
  42705. /**
  42706. * File name for the controller model.
  42707. */
  42708. static readonly MODEL_FILENAME: string;
  42709. /**
  42710. * Creates a new GenericController from a gamepad
  42711. * @param vrGamepad the gamepad that the controller should be created from
  42712. */
  42713. constructor(vrGamepad: any);
  42714. /**
  42715. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42716. * @param scene scene in which to add meshes
  42717. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42718. */
  42719. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42720. /**
  42721. * Called once for each button that changed state since the last frame
  42722. * @param buttonIdx Which button index changed
  42723. * @param state New state of the button
  42724. * @param changes Which properties on the state changed since last frame
  42725. */
  42726. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42727. }
  42728. }
  42729. declare module BABYLON {
  42730. /**
  42731. * Oculus Touch Controller
  42732. */
  42733. class OculusTouchController extends WebVRController {
  42734. /**
  42735. * Base Url for the controller model.
  42736. */
  42737. static MODEL_BASE_URL: string;
  42738. /**
  42739. * File name for the left controller model.
  42740. */
  42741. static MODEL_LEFT_FILENAME: string;
  42742. /**
  42743. * File name for the right controller model.
  42744. */
  42745. static MODEL_RIGHT_FILENAME: string;
  42746. /**
  42747. * Fired when the secondary trigger on this controller is modified
  42748. */
  42749. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42750. /**
  42751. * Fired when the thumb rest on this controller is modified
  42752. */
  42753. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42754. /**
  42755. * Creates a new OculusTouchController from a gamepad
  42756. * @param vrGamepad the gamepad that the controller should be created from
  42757. */
  42758. constructor(vrGamepad: any);
  42759. /**
  42760. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42761. * @param scene scene in which to add meshes
  42762. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42763. */
  42764. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42765. /**
  42766. * Fired when the A button on this controller is modified
  42767. */
  42768. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42769. /**
  42770. * Fired when the B button on this controller is modified
  42771. */
  42772. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42773. /**
  42774. * Fired when the X button on this controller is modified
  42775. */
  42776. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42777. /**
  42778. * Fired when the Y button on this controller is modified
  42779. */
  42780. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42781. /**
  42782. * Called once for each button that changed state since the last frame
  42783. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  42784. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  42785. * 2) secondary trigger (same)
  42786. * 3) A (right) X (left), touch, pressed = value
  42787. * 4) B / Y
  42788. * 5) thumb rest
  42789. * @param buttonIdx Which button index changed
  42790. * @param state New state of the button
  42791. * @param changes Which properties on the state changed since last frame
  42792. */
  42793. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42794. }
  42795. }
  42796. declare module BABYLON {
  42797. /**
  42798. * Defines the types of pose enabled controllers that are supported
  42799. */
  42800. enum PoseEnabledControllerType {
  42801. /**
  42802. * HTC Vive
  42803. */
  42804. VIVE = 0,
  42805. /**
  42806. * Oculus Rift
  42807. */
  42808. OCULUS = 1,
  42809. /**
  42810. * Windows mixed reality
  42811. */
  42812. WINDOWS = 2,
  42813. /**
  42814. * Samsung gear VR
  42815. */
  42816. GEAR_VR = 3,
  42817. /**
  42818. * Google Daydream
  42819. */
  42820. DAYDREAM = 4,
  42821. /**
  42822. * Generic
  42823. */
  42824. GENERIC = 5
  42825. }
  42826. /**
  42827. * Defines the MutableGamepadButton interface for the state of a gamepad button
  42828. */
  42829. interface MutableGamepadButton {
  42830. /**
  42831. * Value of the button/trigger
  42832. */
  42833. value: number;
  42834. /**
  42835. * If the button/trigger is currently touched
  42836. */
  42837. touched: boolean;
  42838. /**
  42839. * If the button/trigger is currently pressed
  42840. */
  42841. pressed: boolean;
  42842. }
  42843. /**
  42844. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  42845. * @hidden
  42846. */
  42847. interface ExtendedGamepadButton extends GamepadButton {
  42848. /**
  42849. * If the button/trigger is currently pressed
  42850. */
  42851. readonly pressed: boolean;
  42852. /**
  42853. * If the button/trigger is currently touched
  42854. */
  42855. readonly touched: boolean;
  42856. /**
  42857. * Value of the button/trigger
  42858. */
  42859. readonly value: number;
  42860. }
  42861. /**
  42862. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  42863. */
  42864. class PoseEnabledControllerHelper {
  42865. /**
  42866. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  42867. * @param vrGamepad the gamepad to initialized
  42868. * @returns a vr controller of the type the gamepad identified as
  42869. */
  42870. static InitiateController(vrGamepad: any): OculusTouchController | WindowsMotionController | ViveController | GearVRController | DaydreamController | GenericController;
  42871. }
  42872. /**
  42873. * Defines the PoseEnabledController object that contains state of a vr capable controller
  42874. */
  42875. class PoseEnabledController extends Gamepad implements PoseControlled {
  42876. private _deviceRoomPosition;
  42877. private _deviceRoomRotationQuaternion;
  42878. /**
  42879. * The device position in babylon space
  42880. */
  42881. devicePosition: Vector3;
  42882. /**
  42883. * The device rotation in babylon space
  42884. */
  42885. deviceRotationQuaternion: Quaternion;
  42886. /**
  42887. * The scale factor of the device in babylon space
  42888. */
  42889. deviceScaleFactor: number;
  42890. /**
  42891. * (Likely devicePosition should be used instead) The device position in its room space
  42892. */
  42893. position: Vector3;
  42894. /**
  42895. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  42896. */
  42897. rotationQuaternion: Quaternion;
  42898. /**
  42899. * The type of controller (Eg. Windows mixed reality)
  42900. */
  42901. controllerType: PoseEnabledControllerType;
  42902. protected _calculatedPosition: Vector3;
  42903. private _calculatedRotation;
  42904. /**
  42905. * The raw pose from the device
  42906. */
  42907. rawPose: DevicePose;
  42908. private _trackPosition;
  42909. private _maxRotationDistFromHeadset;
  42910. private _draggedRoomRotation;
  42911. /**
  42912. * @hidden
  42913. */
  42914. _disableTrackPosition(fixedPosition: Vector3): void;
  42915. /**
  42916. * Internal, the mesh attached to the controller
  42917. * @hidden
  42918. */
  42919. _mesh: Nullable<AbstractMesh>;
  42920. private _poseControlledCamera;
  42921. private _leftHandSystemQuaternion;
  42922. /**
  42923. * Internal, matrix used to convert room space to babylon space
  42924. * @hidden
  42925. */
  42926. _deviceToWorld: Matrix;
  42927. /**
  42928. * Node to be used when casting a ray from the controller
  42929. * @hidden
  42930. */
  42931. _pointingPoseNode: Nullable<AbstractMesh>;
  42932. /**
  42933. * Name of the child mesh that can be used to cast a ray from the controller
  42934. */
  42935. static readonly POINTING_POSE: string;
  42936. /**
  42937. * Creates a new PoseEnabledController from a gamepad
  42938. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  42939. */
  42940. constructor(browserGamepad: any);
  42941. private _workingMatrix;
  42942. /**
  42943. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  42944. */
  42945. update(): void;
  42946. /**
  42947. * Updates only the pose device and mesh without doing any button event checking
  42948. */
  42949. protected _updatePoseAndMesh(): void;
  42950. /**
  42951. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  42952. * @param poseData raw pose fromthe device
  42953. */
  42954. updateFromDevice(poseData: DevicePose): void;
  42955. /**
  42956. * @hidden
  42957. */
  42958. _meshAttachedObservable: Observable<AbstractMesh>;
  42959. /**
  42960. * Attaches a mesh to the controller
  42961. * @param mesh the mesh to be attached
  42962. */
  42963. attachToMesh(mesh: AbstractMesh): void;
  42964. /**
  42965. * Attaches the controllers mesh to a camera
  42966. * @param camera the camera the mesh should be attached to
  42967. */
  42968. attachToPoseControlledCamera(camera: TargetCamera): void;
  42969. /**
  42970. * Disposes of the controller
  42971. */
  42972. dispose(): void;
  42973. /**
  42974. * The mesh that is attached to the controller
  42975. */
  42976. readonly mesh: Nullable<AbstractMesh>;
  42977. /**
  42978. * Gets the ray of the controller in the direction the controller is pointing
  42979. * @param length the length the resulting ray should be
  42980. * @returns a ray in the direction the controller is pointing
  42981. */
  42982. getForwardRay(length?: number): Ray;
  42983. }
  42984. }
  42985. declare module BABYLON {
  42986. /**
  42987. * Vive Controller
  42988. */
  42989. class ViveController extends WebVRController {
  42990. /**
  42991. * Base Url for the controller model.
  42992. */
  42993. static MODEL_BASE_URL: string;
  42994. /**
  42995. * File name for the controller model.
  42996. */
  42997. static MODEL_FILENAME: string;
  42998. /**
  42999. * Creates a new ViveController from a gamepad
  43000. * @param vrGamepad the gamepad that the controller should be created from
  43001. */
  43002. constructor(vrGamepad: any);
  43003. /**
  43004. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43005. * @param scene scene in which to add meshes
  43006. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43007. */
  43008. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43009. /**
  43010. * Fired when the left button on this controller is modified
  43011. */
  43012. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43013. /**
  43014. * Fired when the right button on this controller is modified
  43015. */
  43016. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43017. /**
  43018. * Fired when the menu button on this controller is modified
  43019. */
  43020. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43021. /**
  43022. * Called once for each button that changed state since the last frame
  43023. * Vive mapping:
  43024. * 0: touchpad
  43025. * 1: trigger
  43026. * 2: left AND right buttons
  43027. * 3: menu button
  43028. * @param buttonIdx Which button index changed
  43029. * @param state New state of the button
  43030. * @param changes Which properties on the state changed since last frame
  43031. */
  43032. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43033. }
  43034. }
  43035. declare module BABYLON {
  43036. /**
  43037. * Defines the WebVRController object that represents controllers tracked in 3D space
  43038. */
  43039. abstract class WebVRController extends PoseEnabledController {
  43040. /**
  43041. * Internal, the default controller model for the controller
  43042. */
  43043. protected _defaultModel: AbstractMesh;
  43044. /**
  43045. * Fired when the trigger state has changed
  43046. */
  43047. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43048. /**
  43049. * Fired when the main button state has changed
  43050. */
  43051. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43052. /**
  43053. * Fired when the secondary button state has changed
  43054. */
  43055. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43056. /**
  43057. * Fired when the pad state has changed
  43058. */
  43059. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  43060. /**
  43061. * Fired when controllers stick values have changed
  43062. */
  43063. onPadValuesChangedObservable: Observable<StickValues>;
  43064. /**
  43065. * Array of button availible on the controller
  43066. */
  43067. protected _buttons: Array<MutableGamepadButton>;
  43068. private _onButtonStateChange;
  43069. /**
  43070. * Fired when a controller button's state has changed
  43071. * @param callback the callback containing the button that was modified
  43072. */
  43073. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  43074. /**
  43075. * X and Y axis corrisponding to the controllers joystick
  43076. */
  43077. pad: StickValues;
  43078. /**
  43079. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  43080. */
  43081. hand: string;
  43082. /**
  43083. * The default controller model for the controller
  43084. */
  43085. readonly defaultModel: AbstractMesh;
  43086. /**
  43087. * Creates a new WebVRController from a gamepad
  43088. * @param vrGamepad the gamepad that the WebVRController should be created from
  43089. */
  43090. constructor(vrGamepad: any);
  43091. /**
  43092. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  43093. */
  43094. update(): void;
  43095. /**
  43096. * Function to be called when a button is modified
  43097. */
  43098. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43099. /**
  43100. * Loads a mesh and attaches it to the controller
  43101. * @param scene the scene the mesh should be added to
  43102. * @param meshLoaded callback for when the mesh has been loaded
  43103. */
  43104. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43105. private _setButtonValue;
  43106. private _changes;
  43107. private _checkChanges;
  43108. /**
  43109. * Disposes of th webVRCOntroller
  43110. */
  43111. dispose(): void;
  43112. }
  43113. }
  43114. declare module BABYLON {
  43115. /**
  43116. * Defines the WindowsMotionController object that the state of the windows motion controller
  43117. */
  43118. class WindowsMotionController extends WebVRController {
  43119. /**
  43120. * The base url used to load the left and right controller models
  43121. */
  43122. static MODEL_BASE_URL: string;
  43123. /**
  43124. * The name of the left controller model file
  43125. */
  43126. static MODEL_LEFT_FILENAME: string;
  43127. /**
  43128. * The name of the right controller model file
  43129. */
  43130. static MODEL_RIGHT_FILENAME: string;
  43131. /**
  43132. * The controller name prefix for this controller type
  43133. */
  43134. static readonly GAMEPAD_ID_PREFIX: string;
  43135. /**
  43136. * The controller id pattern for this controller type
  43137. */
  43138. private static readonly GAMEPAD_ID_PATTERN;
  43139. private _loadedMeshInfo;
  43140. private readonly _mapping;
  43141. /**
  43142. * Fired when the trackpad on this controller is clicked
  43143. */
  43144. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43145. /**
  43146. * Fired when the trackpad on this controller is modified
  43147. */
  43148. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43149. /**
  43150. * The current x and y values of this controller's trackpad
  43151. */
  43152. trackpad: StickValues;
  43153. /**
  43154. * Creates a new WindowsMotionController from a gamepad
  43155. * @param vrGamepad the gamepad that the controller should be created from
  43156. */
  43157. constructor(vrGamepad: any);
  43158. /**
  43159. * Fired when the trigger on this controller is modified
  43160. */
  43161. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43162. /**
  43163. * Fired when the menu button on this controller is modified
  43164. */
  43165. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43166. /**
  43167. * Fired when the grip button on this controller is modified
  43168. */
  43169. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43170. /**
  43171. * Fired when the thumbstick button on this controller is modified
  43172. */
  43173. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43174. /**
  43175. * Fired when the touchpad button on this controller is modified
  43176. */
  43177. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43178. /**
  43179. * Fired when the touchpad values on this controller are modified
  43180. */
  43181. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  43182. private _updateTrackpad;
  43183. /**
  43184. * Called once per frame by the engine.
  43185. */
  43186. update(): void;
  43187. /**
  43188. * Called once for each button that changed state since the last frame
  43189. * @param buttonIdx Which button index changed
  43190. * @param state New state of the button
  43191. * @param changes Which properties on the state changed since last frame
  43192. */
  43193. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43194. /**
  43195. * Moves the buttons on the controller mesh based on their current state
  43196. * @param buttonName the name of the button to move
  43197. * @param buttonValue the value of the button which determines the buttons new position
  43198. */
  43199. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  43200. /**
  43201. * Moves the axis on the controller mesh based on its current state
  43202. * @param axis the index of the axis
  43203. * @param axisValue the value of the axis which determines the meshes new position
  43204. * @hidden
  43205. */
  43206. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  43207. /**
  43208. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43209. * @param scene scene in which to add meshes
  43210. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43211. */
  43212. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  43213. /**
  43214. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  43215. * can be transformed by button presses and axes values, based on this._mapping.
  43216. *
  43217. * @param scene scene in which the meshes exist
  43218. * @param meshes list of meshes that make up the controller model to process
  43219. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  43220. */
  43221. private processModel;
  43222. private createMeshInfo;
  43223. /**
  43224. * Gets the ray of the controller in the direction the controller is pointing
  43225. * @param length the length the resulting ray should be
  43226. * @returns a ray in the direction the controller is pointing
  43227. */
  43228. getForwardRay(length?: number): Ray;
  43229. /**
  43230. * Disposes of the controller
  43231. */
  43232. dispose(): void;
  43233. }
  43234. }
  43235. declare module BABYLON {
  43236. /**
  43237. * Interface to implement to create a shadow generator compatible with BJS.
  43238. */
  43239. interface IShadowGenerator {
  43240. /**
  43241. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  43242. * @returns The render target texture if present otherwise, null
  43243. */
  43244. getShadowMap(): Nullable<RenderTargetTexture>;
  43245. /**
  43246. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  43247. * @returns The render target texture if the shadow map is present otherwise, null
  43248. */
  43249. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  43250. /**
  43251. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  43252. * @param subMesh The submesh we want to render in the shadow map
  43253. * @param useInstances Defines wether will draw in the map using instances
  43254. * @returns true if ready otherwise, false
  43255. */
  43256. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  43257. /**
  43258. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  43259. * @param defines Defines of the material we want to update
  43260. * @param lightIndex Index of the light in the enabled light list of the material
  43261. */
  43262. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  43263. /**
  43264. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  43265. * defined in the generator but impacting the effect).
  43266. * It implies the unifroms available on the materials are the standard BJS ones.
  43267. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  43268. * @param effect The effect we are binfing the information for
  43269. */
  43270. bindShadowLight(lightIndex: string, effect: Effect): void;
  43271. /**
  43272. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  43273. * (eq to shadow prjection matrix * light transform matrix)
  43274. * @returns The transform matrix used to create the shadow map
  43275. */
  43276. getTransformMatrix(): Matrix;
  43277. /**
  43278. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  43279. * Cube and 2D textures for instance.
  43280. */
  43281. recreateShadowMap(): void;
  43282. /**
  43283. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  43284. * @param onCompiled Callback triggered at the and of the effects compilation
  43285. * @param options Sets of optional options forcing the compilation with different modes
  43286. */
  43287. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  43288. useInstances: boolean;
  43289. }>): void;
  43290. /**
  43291. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  43292. * @param options Sets of optional options forcing the compilation with different modes
  43293. * @returns A promise that resolves when the compilation completes
  43294. */
  43295. forceCompilationAsync(options?: Partial<{
  43296. useInstances: boolean;
  43297. }>): Promise<void>;
  43298. /**
  43299. * Serializes the shadow generator setup to a json object.
  43300. * @returns The serialized JSON object
  43301. */
  43302. serialize(): any;
  43303. /**
  43304. * Disposes the Shadow map and related Textures and effects.
  43305. */
  43306. dispose(): void;
  43307. }
  43308. /**
  43309. * Default implementation IShadowGenerator.
  43310. * This is the main object responsible of generating shadows in the framework.
  43311. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  43312. */
  43313. class ShadowGenerator implements IShadowGenerator {
  43314. /**
  43315. * Shadow generator mode None: no filtering applied.
  43316. */
  43317. static readonly FILTER_NONE: number;
  43318. /**
  43319. * Shadow generator mode ESM: Exponential Shadow Mapping.
  43320. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  43321. */
  43322. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  43323. /**
  43324. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  43325. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  43326. */
  43327. static readonly FILTER_POISSONSAMPLING: number;
  43328. /**
  43329. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  43330. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  43331. */
  43332. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  43333. /**
  43334. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  43335. * edge artifacts on steep falloff.
  43336. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  43337. */
  43338. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  43339. /**
  43340. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  43341. * edge artifacts on steep falloff.
  43342. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  43343. */
  43344. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  43345. /**
  43346. * Shadow generator mode PCF: Percentage Closer Filtering
  43347. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  43348. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  43349. */
  43350. static readonly FILTER_PCF: number;
  43351. /**
  43352. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  43353. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  43354. * Contact Hardening
  43355. */
  43356. static readonly FILTER_PCSS: number;
  43357. /**
  43358. * Reserved for PCF and PCSS
  43359. * Highest Quality.
  43360. *
  43361. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  43362. *
  43363. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  43364. */
  43365. static readonly QUALITY_HIGH: number;
  43366. /**
  43367. * Reserved for PCF and PCSS
  43368. * Good tradeoff for quality/perf cross devices
  43369. *
  43370. * Execute PCF on a 3*3 kernel.
  43371. *
  43372. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  43373. */
  43374. static readonly QUALITY_MEDIUM: number;
  43375. /**
  43376. * Reserved for PCF and PCSS
  43377. * The lowest quality but the fastest.
  43378. *
  43379. * Execute PCF on a 1*1 kernel.
  43380. *
  43381. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  43382. */
  43383. static readonly QUALITY_LOW: number;
  43384. private _bias;
  43385. /**
  43386. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  43387. */
  43388. /**
  43389. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  43390. */
  43391. bias: number;
  43392. private _normalBias;
  43393. /**
  43394. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  43395. */
  43396. /**
  43397. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  43398. */
  43399. normalBias: number;
  43400. private _blurBoxOffset;
  43401. /**
  43402. * Gets the blur box offset: offset applied during the blur pass.
  43403. * Only usefull if useKernelBlur = false
  43404. */
  43405. /**
  43406. * Sets the blur box offset: offset applied during the blur pass.
  43407. * Only usefull if useKernelBlur = false
  43408. */
  43409. blurBoxOffset: number;
  43410. private _blurScale;
  43411. /**
  43412. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  43413. * 2 means half of the size.
  43414. */
  43415. /**
  43416. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  43417. * 2 means half of the size.
  43418. */
  43419. blurScale: number;
  43420. private _blurKernel;
  43421. /**
  43422. * Gets the blur kernel: kernel size of the blur pass.
  43423. * Only usefull if useKernelBlur = true
  43424. */
  43425. /**
  43426. * Sets the blur kernel: kernel size of the blur pass.
  43427. * Only usefull if useKernelBlur = true
  43428. */
  43429. blurKernel: number;
  43430. private _useKernelBlur;
  43431. /**
  43432. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  43433. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  43434. */
  43435. /**
  43436. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  43437. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  43438. */
  43439. useKernelBlur: boolean;
  43440. private _depthScale;
  43441. /**
  43442. * Gets the depth scale used in ESM mode.
  43443. */
  43444. /**
  43445. * Sets the depth scale used in ESM mode.
  43446. * This can override the scale stored on the light.
  43447. */
  43448. depthScale: number;
  43449. private _filter;
  43450. /**
  43451. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  43452. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  43453. */
  43454. /**
  43455. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  43456. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  43457. */
  43458. filter: number;
  43459. /**
  43460. * Gets if the current filter is set to Poisson Sampling.
  43461. */
  43462. /**
  43463. * Sets the current filter to Poisson Sampling.
  43464. */
  43465. usePoissonSampling: boolean;
  43466. /**
  43467. * Gets if the current filter is set to VSM.
  43468. * DEPRECATED. Should use useExponentialShadowMap instead.
  43469. */
  43470. /**
  43471. * Sets the current filter is to VSM.
  43472. * DEPRECATED. Should use useExponentialShadowMap instead.
  43473. */
  43474. useVarianceShadowMap: boolean;
  43475. /**
  43476. * Gets if the current filter is set to blurred VSM.
  43477. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  43478. */
  43479. /**
  43480. * Sets the current filter is to blurred VSM.
  43481. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  43482. */
  43483. useBlurVarianceShadowMap: boolean;
  43484. /**
  43485. * Gets if the current filter is set to ESM.
  43486. */
  43487. /**
  43488. * Sets the current filter is to ESM.
  43489. */
  43490. useExponentialShadowMap: boolean;
  43491. /**
  43492. * Gets if the current filter is set to filtered ESM.
  43493. */
  43494. /**
  43495. * Gets if the current filter is set to filtered ESM.
  43496. */
  43497. useBlurExponentialShadowMap: boolean;
  43498. /**
  43499. * Gets if the current filter is set to "close ESM" (using the inverse of the
  43500. * exponential to prevent steep falloff artifacts).
  43501. */
  43502. /**
  43503. * Sets the current filter to "close ESM" (using the inverse of the
  43504. * exponential to prevent steep falloff artifacts).
  43505. */
  43506. useCloseExponentialShadowMap: boolean;
  43507. /**
  43508. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  43509. * exponential to prevent steep falloff artifacts).
  43510. */
  43511. /**
  43512. * Sets the current filter to filtered "close ESM" (using the inverse of the
  43513. * exponential to prevent steep falloff artifacts).
  43514. */
  43515. useBlurCloseExponentialShadowMap: boolean;
  43516. /**
  43517. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  43518. */
  43519. /**
  43520. * Sets the current filter to "PCF" (percentage closer filtering).
  43521. */
  43522. usePercentageCloserFiltering: boolean;
  43523. private _filteringQuality;
  43524. /**
  43525. * Gets the PCF or PCSS Quality.
  43526. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  43527. */
  43528. /**
  43529. * Sets the PCF or PCSS Quality.
  43530. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  43531. */
  43532. filteringQuality: number;
  43533. /**
  43534. * Gets if the current filter is set to "PCSS" (contact hardening).
  43535. */
  43536. /**
  43537. * Sets the current filter to "PCSS" (contact hardening).
  43538. */
  43539. useContactHardeningShadow: boolean;
  43540. private _contactHardeningLightSizeUVRatio;
  43541. /**
  43542. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  43543. * Using a ratio helps keeping shape stability independently of the map size.
  43544. *
  43545. * It does not account for the light projection as it was having too much
  43546. * instability during the light setup or during light position changes.
  43547. *
  43548. * Only valid if useContactHardeningShadow is true.
  43549. */
  43550. /**
  43551. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  43552. * Using a ratio helps keeping shape stability independently of the map size.
  43553. *
  43554. * It does not account for the light projection as it was having too much
  43555. * instability during the light setup or during light position changes.
  43556. *
  43557. * Only valid if useContactHardeningShadow is true.
  43558. */
  43559. contactHardeningLightSizeUVRatio: number;
  43560. private _darkness;
  43561. /**
  43562. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  43563. * 0 means strongest and 1 would means no shadow.
  43564. * @returns the darkness.
  43565. */
  43566. getDarkness(): number;
  43567. /**
  43568. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  43569. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  43570. * @returns the shadow generator allowing fluent coding.
  43571. */
  43572. setDarkness(darkness: number): ShadowGenerator;
  43573. private _transparencyShadow;
  43574. /**
  43575. * Sets the ability to have transparent shadow (boolean).
  43576. * @param transparent True if transparent else False
  43577. * @returns the shadow generator allowing fluent coding
  43578. */
  43579. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  43580. private _shadowMap;
  43581. private _shadowMap2;
  43582. /**
  43583. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  43584. * @returns The render target texture if present otherwise, null
  43585. */
  43586. getShadowMap(): Nullable<RenderTargetTexture>;
  43587. /**
  43588. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  43589. * @returns The render target texture if the shadow map is present otherwise, null
  43590. */
  43591. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  43592. /**
  43593. * Helper function to add a mesh and its descendants to the list of shadow casters.
  43594. * @param mesh Mesh to add
  43595. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  43596. * @returns the Shadow Generator itself
  43597. */
  43598. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  43599. /**
  43600. * Helper function to remove a mesh and its descendants from the list of shadow casters
  43601. * @param mesh Mesh to remove
  43602. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  43603. * @returns the Shadow Generator itself
  43604. */
  43605. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  43606. /**
  43607. * Controls the extent to which the shadows fade out at the edge of the frustum
  43608. * Used only by directionals and spots
  43609. */
  43610. frustumEdgeFalloff: number;
  43611. private _light;
  43612. /**
  43613. * Returns the associated light object.
  43614. * @returns the light generating the shadow
  43615. */
  43616. getLight(): IShadowLight;
  43617. /**
  43618. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  43619. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  43620. * It might on the other hand introduce peter panning.
  43621. */
  43622. forceBackFacesOnly: boolean;
  43623. private _scene;
  43624. private _lightDirection;
  43625. private _effect;
  43626. private _viewMatrix;
  43627. private _projectionMatrix;
  43628. private _transformMatrix;
  43629. private _cachedPosition;
  43630. private _cachedDirection;
  43631. private _cachedDefines;
  43632. private _currentRenderID;
  43633. private _boxBlurPostprocess;
  43634. private _kernelBlurXPostprocess;
  43635. private _kernelBlurYPostprocess;
  43636. private _blurPostProcesses;
  43637. private _mapSize;
  43638. private _currentFaceIndex;
  43639. private _currentFaceIndexCache;
  43640. private _textureType;
  43641. private _defaultTextureMatrix;
  43642. /**
  43643. * Creates a ShadowGenerator object.
  43644. * A ShadowGenerator is the required tool to use the shadows.
  43645. * Each light casting shadows needs to use its own ShadowGenerator.
  43646. * Documentation : http://doc.babylonjs.com/tutorials/shadows
  43647. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  43648. * @param light The light object generating the shadows.
  43649. * @param useFullFloatFirst By default the generator will try to use half float textures but if you need precision (for self shadowing for instance), you can use this option to enforce full float texture.
  43650. */
  43651. constructor(mapSize: number, light: IShadowLight, useFullFloatFirst?: boolean);
  43652. private _initializeGenerator;
  43653. private _initializeShadowMap;
  43654. private _initializeBlurRTTAndPostProcesses;
  43655. private _renderForShadowMap;
  43656. private _renderSubMeshForShadowMap;
  43657. private _applyFilterValues;
  43658. /**
  43659. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  43660. * @param onCompiled Callback triggered at the and of the effects compilation
  43661. * @param options Sets of optional options forcing the compilation with different modes
  43662. */
  43663. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  43664. useInstances: boolean;
  43665. }>): void;
  43666. /**
  43667. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  43668. * @param options Sets of optional options forcing the compilation with different modes
  43669. * @returns A promise that resolves when the compilation completes
  43670. */
  43671. forceCompilationAsync(options?: Partial<{
  43672. useInstances: boolean;
  43673. }>): Promise<void>;
  43674. /**
  43675. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  43676. * @param subMesh The submesh we want to render in the shadow map
  43677. * @param useInstances Defines wether will draw in the map using instances
  43678. * @returns true if ready otherwise, false
  43679. */
  43680. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  43681. /**
  43682. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  43683. * @param defines Defines of the material we want to update
  43684. * @param lightIndex Index of the light in the enabled light list of the material
  43685. */
  43686. prepareDefines(defines: any, lightIndex: number): void;
  43687. /**
  43688. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  43689. * defined in the generator but impacting the effect).
  43690. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  43691. * @param effect The effect we are binfing the information for
  43692. */
  43693. bindShadowLight(lightIndex: string, effect: Effect): void;
  43694. /**
  43695. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  43696. * (eq to shadow prjection matrix * light transform matrix)
  43697. * @returns The transform matrix used to create the shadow map
  43698. */
  43699. getTransformMatrix(): Matrix;
  43700. /**
  43701. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  43702. * Cube and 2D textures for instance.
  43703. */
  43704. recreateShadowMap(): void;
  43705. private _disposeBlurPostProcesses;
  43706. private _disposeRTTandPostProcesses;
  43707. /**
  43708. * Disposes the ShadowGenerator.
  43709. * Returns nothing.
  43710. */
  43711. dispose(): void;
  43712. /**
  43713. * Serializes the shadow generator setup to a json object.
  43714. * @returns The serialized JSON object
  43715. */
  43716. serialize(): any;
  43717. /**
  43718. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  43719. * @param parsedShadowGenerator The JSON object to parse
  43720. * @param scene The scene to create the shadow map for
  43721. * @returns The parsed shadow generator
  43722. */
  43723. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  43724. }
  43725. }
  43726. declare module BABYLON {
  43727. /**
  43728. * Defines the shadow generator component responsible to manage any shadow generators
  43729. * in a given scene.
  43730. */
  43731. class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  43732. /**
  43733. * The component name helpfull to identify the component in the list of scene components.
  43734. */
  43735. readonly name: string;
  43736. /**
  43737. * The scene the component belongs to.
  43738. */
  43739. scene: Scene;
  43740. /**
  43741. * Creates a new instance of the component for the given scene
  43742. * @param scene Defines the scene to register the component in
  43743. */
  43744. constructor(scene: Scene);
  43745. /**
  43746. * Registers the component in a given scene
  43747. */
  43748. register(): void;
  43749. /**
  43750. * Rebuilds the elements related to this component in case of
  43751. * context lost for instance.
  43752. */
  43753. rebuild(): void;
  43754. /**
  43755. * Serializes the component data to the specified json object
  43756. * @param serializationObject The object to serialize to
  43757. */
  43758. serialize(serializationObject: any): void;
  43759. /**
  43760. * Adds all the element from the container to the scene
  43761. * @param container the container holding the elements
  43762. */
  43763. addFromContainer(container: AbstractScene): void;
  43764. /**
  43765. * Removes all the elements in the container from the scene
  43766. * @param container contains the elements to remove
  43767. */
  43768. removeFromContainer(container: AbstractScene): void;
  43769. /**
  43770. * Rebuilds the elements related to this component in case of
  43771. * context lost for instance.
  43772. */
  43773. dispose(): void;
  43774. private _gatherRenderTargets;
  43775. }
  43776. }
  43777. declare module BABYLON {
  43778. }
  43779. declare module BABYLON {
  43780. /**
  43781. * Background material used to create an efficient environement around your scene.
  43782. */
  43783. class BackgroundMaterial extends PushMaterial {
  43784. /**
  43785. * Standard reflectance value at parallel view angle.
  43786. */
  43787. static StandardReflectance0: number;
  43788. /**
  43789. * Standard reflectance value at grazing angle.
  43790. */
  43791. static StandardReflectance90: number;
  43792. protected _primaryColor: Color3;
  43793. /**
  43794. * Key light Color (multiply against the environement texture)
  43795. */
  43796. primaryColor: Color3;
  43797. protected __perceptualColor: Nullable<Color3>;
  43798. /**
  43799. * Experimental Internal Use Only.
  43800. *
  43801. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  43802. * This acts as a helper to set the primary color to a more "human friendly" value.
  43803. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  43804. * output color as close as possible from the chosen value.
  43805. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  43806. * part of lighting setup.)
  43807. */
  43808. _perceptualColor: Nullable<Color3>;
  43809. protected _primaryColorShadowLevel: float;
  43810. /**
  43811. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  43812. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  43813. */
  43814. primaryColorShadowLevel: float;
  43815. protected _primaryColorHighlightLevel: float;
  43816. /**
  43817. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  43818. * The primary color is used at the level chosen to define what the white area would look.
  43819. */
  43820. primaryColorHighlightLevel: float;
  43821. protected _reflectionTexture: Nullable<BaseTexture>;
  43822. /**
  43823. * Reflection Texture used in the material.
  43824. * Should be author in a specific way for the best result (refer to the documentation).
  43825. */
  43826. reflectionTexture: Nullable<BaseTexture>;
  43827. protected _reflectionBlur: float;
  43828. /**
  43829. * Reflection Texture level of blur.
  43830. *
  43831. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  43832. * texture twice.
  43833. */
  43834. reflectionBlur: float;
  43835. protected _diffuseTexture: Nullable<BaseTexture>;
  43836. /**
  43837. * Diffuse Texture used in the material.
  43838. * Should be author in a specific way for the best result (refer to the documentation).
  43839. */
  43840. diffuseTexture: Nullable<BaseTexture>;
  43841. protected _shadowLights: Nullable<IShadowLight[]>;
  43842. /**
  43843. * Specify the list of lights casting shadow on the material.
  43844. * All scene shadow lights will be included if null.
  43845. */
  43846. shadowLights: Nullable<IShadowLight[]>;
  43847. protected _shadowLevel: float;
  43848. /**
  43849. * Helps adjusting the shadow to a softer level if required.
  43850. * 0 means black shadows and 1 means no shadows.
  43851. */
  43852. shadowLevel: float;
  43853. protected _sceneCenter: Vector3;
  43854. /**
  43855. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  43856. * It is usually zero but might be interesting to modify according to your setup.
  43857. */
  43858. sceneCenter: Vector3;
  43859. protected _opacityFresnel: boolean;
  43860. /**
  43861. * This helps specifying that the material is falling off to the sky box at grazing angle.
  43862. * This helps ensuring a nice transition when the camera goes under the ground.
  43863. */
  43864. opacityFresnel: boolean;
  43865. protected _reflectionFresnel: boolean;
  43866. /**
  43867. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  43868. * This helps adding a mirror texture on the ground.
  43869. */
  43870. reflectionFresnel: boolean;
  43871. protected _reflectionFalloffDistance: number;
  43872. /**
  43873. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  43874. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  43875. */
  43876. reflectionFalloffDistance: number;
  43877. protected _reflectionAmount: number;
  43878. /**
  43879. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  43880. */
  43881. reflectionAmount: number;
  43882. protected _reflectionReflectance0: number;
  43883. /**
  43884. * This specifies the weight of the reflection at grazing angle.
  43885. */
  43886. reflectionReflectance0: number;
  43887. protected _reflectionReflectance90: number;
  43888. /**
  43889. * This specifies the weight of the reflection at a perpendicular point of view.
  43890. */
  43891. reflectionReflectance90: number;
  43892. /**
  43893. * Sets the reflection reflectance fresnel values according to the default standard
  43894. * empirically know to work well :-)
  43895. */
  43896. reflectionStandardFresnelWeight: number;
  43897. protected _useRGBColor: boolean;
  43898. /**
  43899. * Helps to directly use the maps channels instead of their level.
  43900. */
  43901. useRGBColor: boolean;
  43902. protected _enableNoise: boolean;
  43903. /**
  43904. * This helps reducing the banding effect that could occur on the background.
  43905. */
  43906. enableNoise: boolean;
  43907. /**
  43908. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  43909. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  43910. * Recommended to be keep at 1.0 except for special cases.
  43911. */
  43912. fovMultiplier: number;
  43913. private _fovMultiplier;
  43914. /**
  43915. * Enable the FOV adjustment feature controlled by fovMultiplier.
  43916. */
  43917. useEquirectangularFOV: boolean;
  43918. private _maxSimultaneousLights;
  43919. /**
  43920. * Number of Simultaneous lights allowed on the material.
  43921. */
  43922. maxSimultaneousLights: int;
  43923. /**
  43924. * Default configuration related to image processing available in the Background Material.
  43925. */
  43926. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43927. /**
  43928. * Keep track of the image processing observer to allow dispose and replace.
  43929. */
  43930. private _imageProcessingObserver;
  43931. /**
  43932. * Attaches a new image processing configuration to the PBR Material.
  43933. * @param configuration (if null the scene configuration will be use)
  43934. */
  43935. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  43936. /**
  43937. * Gets the image processing configuration used either in this material.
  43938. */
  43939. /**
  43940. * Sets the Default image processing configuration used either in the this material.
  43941. *
  43942. * If sets to null, the scene one is in use.
  43943. */
  43944. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  43945. /**
  43946. * Gets wether the color curves effect is enabled.
  43947. */
  43948. /**
  43949. * Sets wether the color curves effect is enabled.
  43950. */
  43951. cameraColorCurvesEnabled: boolean;
  43952. /**
  43953. * Gets wether the color grading effect is enabled.
  43954. */
  43955. /**
  43956. * Gets wether the color grading effect is enabled.
  43957. */
  43958. cameraColorGradingEnabled: boolean;
  43959. /**
  43960. * Gets wether tonemapping is enabled or not.
  43961. */
  43962. /**
  43963. * Sets wether tonemapping is enabled or not
  43964. */
  43965. cameraToneMappingEnabled: boolean;
  43966. /**
  43967. * The camera exposure used on this material.
  43968. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43969. * This corresponds to a photographic exposure.
  43970. */
  43971. /**
  43972. * The camera exposure used on this material.
  43973. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43974. * This corresponds to a photographic exposure.
  43975. */
  43976. cameraExposure: float;
  43977. /**
  43978. * Gets The camera contrast used on this material.
  43979. */
  43980. /**
  43981. * Sets The camera contrast used on this material.
  43982. */
  43983. cameraContrast: float;
  43984. /**
  43985. * Gets the Color Grading 2D Lookup Texture.
  43986. */
  43987. /**
  43988. * Sets the Color Grading 2D Lookup Texture.
  43989. */
  43990. cameraColorGradingTexture: Nullable<BaseTexture>;
  43991. /**
  43992. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43993. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43994. * 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;
  43995. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43996. */
  43997. /**
  43998. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43999. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44000. * 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;
  44001. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44002. */
  44003. cameraColorCurves: Nullable<ColorCurves>;
  44004. /**
  44005. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  44006. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  44007. */
  44008. switchToBGR: boolean;
  44009. private _renderTargets;
  44010. private _reflectionControls;
  44011. private _white;
  44012. private _primaryShadowColor;
  44013. private _primaryHighlightColor;
  44014. /**
  44015. * Instantiates a Background Material in the given scene
  44016. * @param name The friendly name of the material
  44017. * @param scene The scene to add the material to
  44018. */
  44019. constructor(name: string, scene: Scene);
  44020. /**
  44021. * Gets a boolean indicating that current material needs to register RTT
  44022. */
  44023. readonly hasRenderTargetTextures: boolean;
  44024. /**
  44025. * The entire material has been created in order to prevent overdraw.
  44026. * @returns false
  44027. */
  44028. needAlphaTesting(): boolean;
  44029. /**
  44030. * The entire material has been created in order to prevent overdraw.
  44031. * @returns true if blending is enable
  44032. */
  44033. needAlphaBlending(): boolean;
  44034. /**
  44035. * Checks wether the material is ready to be rendered for a given mesh.
  44036. * @param mesh The mesh to render
  44037. * @param subMesh The submesh to check against
  44038. * @param useInstances Specify wether or not the material is used with instances
  44039. * @returns true if all the dependencies are ready (Textures, Effects...)
  44040. */
  44041. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  44042. /**
  44043. * Compute the primary color according to the chosen perceptual color.
  44044. */
  44045. private _computePrimaryColorFromPerceptualColor;
  44046. /**
  44047. * Compute the highlights and shadow colors according to their chosen levels.
  44048. */
  44049. private _computePrimaryColors;
  44050. /**
  44051. * Build the uniform buffer used in the material.
  44052. */
  44053. buildUniformLayout(): void;
  44054. /**
  44055. * Unbind the material.
  44056. */
  44057. unbind(): void;
  44058. /**
  44059. * Bind only the world matrix to the material.
  44060. * @param world The world matrix to bind.
  44061. */
  44062. bindOnlyWorldMatrix(world: Matrix): void;
  44063. /**
  44064. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  44065. * @param world The world matrix to bind.
  44066. * @param subMesh The submesh to bind for.
  44067. */
  44068. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  44069. /**
  44070. * Dispose the material.
  44071. * @param forceDisposeEffect Force disposal of the associated effect.
  44072. * @param forceDisposeTextures Force disposal of the associated textures.
  44073. */
  44074. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  44075. /**
  44076. * Clones the material.
  44077. * @param name The cloned name.
  44078. * @returns The cloned material.
  44079. */
  44080. clone(name: string): BackgroundMaterial;
  44081. /**
  44082. * Serializes the current material to its JSON representation.
  44083. * @returns The JSON representation.
  44084. */
  44085. serialize(): any;
  44086. /**
  44087. * Gets the class name of the material
  44088. * @returns "BackgroundMaterial"
  44089. */
  44090. getClassName(): string;
  44091. /**
  44092. * Parse a JSON input to create back a background material.
  44093. * @param source The JSON data to parse
  44094. * @param scene The scene to create the parsed material in
  44095. * @param rootUrl The root url of the assets the material depends upon
  44096. * @returns the instantiated BackgroundMaterial.
  44097. */
  44098. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  44099. }
  44100. }
  44101. declare module BABYLON {
  44102. /**
  44103. * The Physically based material base class of BJS.
  44104. *
  44105. * This offers the main features of a standard PBR material.
  44106. * For more information, please refer to the documentation :
  44107. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  44108. */
  44109. abstract class PBRBaseMaterial extends PushMaterial {
  44110. /**
  44111. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  44112. */
  44113. static readonly LIGHTFALLOFF_PHYSICAL: number;
  44114. /**
  44115. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  44116. * to enhance interoperability with other engines.
  44117. */
  44118. static readonly LIGHTFALLOFF_GLTF: number;
  44119. /**
  44120. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  44121. * to enhance interoperability with other materials.
  44122. */
  44123. static readonly LIGHTFALLOFF_STANDARD: number;
  44124. /**
  44125. * Intensity of the direct lights e.g. the four lights available in your scene.
  44126. * This impacts both the direct diffuse and specular highlights.
  44127. */
  44128. protected _directIntensity: number;
  44129. /**
  44130. * Intensity of the emissive part of the material.
  44131. * This helps controlling the emissive effect without modifying the emissive color.
  44132. */
  44133. protected _emissiveIntensity: number;
  44134. /**
  44135. * Intensity of the environment e.g. how much the environment will light the object
  44136. * either through harmonics for rough material or through the refelction for shiny ones.
  44137. */
  44138. protected _environmentIntensity: number;
  44139. /**
  44140. * This is a special control allowing the reduction of the specular highlights coming from the
  44141. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  44142. */
  44143. protected _specularIntensity: number;
  44144. /**
  44145. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  44146. */
  44147. private _lightingInfos;
  44148. /**
  44149. * Debug Control allowing disabling the bump map on this material.
  44150. */
  44151. protected _disableBumpMap: boolean;
  44152. /**
  44153. * AKA Diffuse Texture in standard nomenclature.
  44154. */
  44155. protected _albedoTexture: BaseTexture;
  44156. /**
  44157. * AKA Occlusion Texture in other nomenclature.
  44158. */
  44159. protected _ambientTexture: BaseTexture;
  44160. /**
  44161. * AKA Occlusion Texture Intensity in other nomenclature.
  44162. */
  44163. protected _ambientTextureStrength: number;
  44164. /**
  44165. * Defines how much the AO map is occluding the analytical lights (point spot...).
  44166. * 1 means it completely occludes it
  44167. * 0 mean it has no impact
  44168. */
  44169. protected _ambientTextureImpactOnAnalyticalLights: number;
  44170. /**
  44171. * Stores the alpha values in a texture.
  44172. */
  44173. protected _opacityTexture: BaseTexture;
  44174. /**
  44175. * Stores the reflection values in a texture.
  44176. */
  44177. protected _reflectionTexture: BaseTexture;
  44178. /**
  44179. * Stores the refraction values in a texture.
  44180. */
  44181. protected _refractionTexture: BaseTexture;
  44182. /**
  44183. * Stores the emissive values in a texture.
  44184. */
  44185. protected _emissiveTexture: BaseTexture;
  44186. /**
  44187. * AKA Specular texture in other nomenclature.
  44188. */
  44189. protected _reflectivityTexture: BaseTexture;
  44190. /**
  44191. * Used to switch from specular/glossiness to metallic/roughness workflow.
  44192. */
  44193. protected _metallicTexture: BaseTexture;
  44194. /**
  44195. * Specifies the metallic scalar of the metallic/roughness workflow.
  44196. * Can also be used to scale the metalness values of the metallic texture.
  44197. */
  44198. protected _metallic: Nullable<number>;
  44199. /**
  44200. * Specifies the roughness scalar of the metallic/roughness workflow.
  44201. * Can also be used to scale the roughness values of the metallic texture.
  44202. */
  44203. protected _roughness: Nullable<number>;
  44204. /**
  44205. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  44206. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  44207. */
  44208. protected _microSurfaceTexture: BaseTexture;
  44209. /**
  44210. * Stores surface normal data used to displace a mesh in a texture.
  44211. */
  44212. protected _bumpTexture: BaseTexture;
  44213. /**
  44214. * Stores the pre-calculated light information of a mesh in a texture.
  44215. */
  44216. protected _lightmapTexture: BaseTexture;
  44217. /**
  44218. * The color of a material in ambient lighting.
  44219. */
  44220. protected _ambientColor: Color3;
  44221. /**
  44222. * AKA Diffuse Color in other nomenclature.
  44223. */
  44224. protected _albedoColor: Color3;
  44225. /**
  44226. * AKA Specular Color in other nomenclature.
  44227. */
  44228. protected _reflectivityColor: Color3;
  44229. /**
  44230. * The color applied when light is reflected from a material.
  44231. */
  44232. protected _reflectionColor: Color3;
  44233. /**
  44234. * The color applied when light is emitted from a material.
  44235. */
  44236. protected _emissiveColor: Color3;
  44237. /**
  44238. * AKA Glossiness in other nomenclature.
  44239. */
  44240. protected _microSurface: number;
  44241. /**
  44242. * source material index of refraction (IOR)' / 'destination material IOR.
  44243. */
  44244. protected _indexOfRefraction: number;
  44245. /**
  44246. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  44247. */
  44248. protected _invertRefractionY: boolean;
  44249. /**
  44250. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  44251. * Materials half opaque for instance using refraction could benefit from this control.
  44252. */
  44253. protected _linkRefractionWithTransparency: boolean;
  44254. /**
  44255. * Specifies that the material will use the light map as a show map.
  44256. */
  44257. protected _useLightmapAsShadowmap: boolean;
  44258. /**
  44259. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  44260. * makes the reflect vector face the model (under horizon).
  44261. */
  44262. protected _useHorizonOcclusion: boolean;
  44263. /**
  44264. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  44265. * too much the area relying on ambient texture to define their ambient occlusion.
  44266. */
  44267. protected _useRadianceOcclusion: boolean;
  44268. /**
  44269. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  44270. */
  44271. protected _useAlphaFromAlbedoTexture: boolean;
  44272. /**
  44273. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  44274. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  44275. */
  44276. protected _useSpecularOverAlpha: boolean;
  44277. /**
  44278. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  44279. */
  44280. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  44281. /**
  44282. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  44283. */
  44284. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  44285. /**
  44286. * Specifies if the metallic texture contains the roughness information in its green channel.
  44287. */
  44288. protected _useRoughnessFromMetallicTextureGreen: boolean;
  44289. /**
  44290. * Specifies if the metallic texture contains the metallness information in its blue channel.
  44291. */
  44292. protected _useMetallnessFromMetallicTextureBlue: boolean;
  44293. /**
  44294. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  44295. */
  44296. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  44297. /**
  44298. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  44299. */
  44300. protected _useAmbientInGrayScale: boolean;
  44301. /**
  44302. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  44303. * The material will try to infer what glossiness each pixel should be.
  44304. */
  44305. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  44306. /**
  44307. * Defines the falloff type used in this material.
  44308. * It by default is Physical.
  44309. */
  44310. protected _lightFalloff: number;
  44311. /**
  44312. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  44313. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  44314. */
  44315. protected _useRadianceOverAlpha: boolean;
  44316. /**
  44317. * Allows using an object space normal map (instead of tangent space).
  44318. */
  44319. protected _useObjectSpaceNormalMap: boolean;
  44320. /**
  44321. * Allows using the bump map in parallax mode.
  44322. */
  44323. protected _useParallax: boolean;
  44324. /**
  44325. * Allows using the bump map in parallax occlusion mode.
  44326. */
  44327. protected _useParallaxOcclusion: boolean;
  44328. /**
  44329. * Controls the scale bias of the parallax mode.
  44330. */
  44331. protected _parallaxScaleBias: number;
  44332. /**
  44333. * If sets to true, disables all the lights affecting the material.
  44334. */
  44335. protected _disableLighting: boolean;
  44336. /**
  44337. * Number of Simultaneous lights allowed on the material.
  44338. */
  44339. protected _maxSimultaneousLights: number;
  44340. /**
  44341. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  44342. */
  44343. protected _invertNormalMapX: boolean;
  44344. /**
  44345. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  44346. */
  44347. protected _invertNormalMapY: boolean;
  44348. /**
  44349. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  44350. */
  44351. protected _twoSidedLighting: boolean;
  44352. /**
  44353. * Defines the alpha limits in alpha test mode.
  44354. */
  44355. protected _alphaCutOff: number;
  44356. /**
  44357. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  44358. */
  44359. protected _forceAlphaTest: boolean;
  44360. /**
  44361. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44362. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  44363. */
  44364. protected _useAlphaFresnel: boolean;
  44365. /**
  44366. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44367. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  44368. */
  44369. protected _useLinearAlphaFresnel: boolean;
  44370. /**
  44371. * The transparency mode of the material.
  44372. */
  44373. protected _transparencyMode: Nullable<number>;
  44374. /**
  44375. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  44376. * from cos thetav and roughness:
  44377. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  44378. */
  44379. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  44380. /**
  44381. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  44382. */
  44383. protected _forceIrradianceInFragment: boolean;
  44384. /**
  44385. * Force normal to face away from face.
  44386. */
  44387. protected _forceNormalForward: boolean;
  44388. /**
  44389. * Enables specular anti aliasing in the PBR shader.
  44390. * It will both interacts on the Geometry for analytical and IBL lighting.
  44391. * It also prefilter the roughness map based on the bump values.
  44392. */
  44393. protected _enableSpecularAntiAliasing: boolean;
  44394. /**
  44395. * Default configuration related to image processing available in the PBR Material.
  44396. */
  44397. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44398. /**
  44399. * Keep track of the image processing observer to allow dispose and replace.
  44400. */
  44401. private _imageProcessingObserver;
  44402. /**
  44403. * Attaches a new image processing configuration to the PBR Material.
  44404. * @param configuration
  44405. */
  44406. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  44407. /**
  44408. * Stores the available render targets.
  44409. */
  44410. private _renderTargets;
  44411. /**
  44412. * Sets the global ambient color for the material used in lighting calculations.
  44413. */
  44414. private _globalAmbientColor;
  44415. /**
  44416. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  44417. */
  44418. private _useLogarithmicDepth;
  44419. /**
  44420. * If set to true, no lighting calculations will be applied.
  44421. */
  44422. private _unlit;
  44423. /**
  44424. * Instantiates a new PBRMaterial instance.
  44425. *
  44426. * @param name The material name
  44427. * @param scene The scene the material will be use in.
  44428. */
  44429. constructor(name: string, scene: Scene);
  44430. /**
  44431. * Gets a boolean indicating that current material needs to register RTT
  44432. */
  44433. readonly hasRenderTargetTextures: boolean;
  44434. /**
  44435. * Gets the name of the material class.
  44436. */
  44437. getClassName(): string;
  44438. /**
  44439. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  44440. */
  44441. /**
  44442. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  44443. */
  44444. useLogarithmicDepth: boolean;
  44445. /**
  44446. * Gets the current transparency mode.
  44447. */
  44448. /**
  44449. * Sets the transparency mode of the material.
  44450. *
  44451. * | Value | Type | Description |
  44452. * | ----- | ----------------------------------- | ----------- |
  44453. * | 0 | OPAQUE | |
  44454. * | 1 | ALPHATEST | |
  44455. * | 2 | ALPHABLEND | |
  44456. * | 3 | ALPHATESTANDBLEND | |
  44457. *
  44458. */
  44459. transparencyMode: Nullable<number>;
  44460. /**
  44461. * Returns true if alpha blending should be disabled.
  44462. */
  44463. private readonly _disableAlphaBlending;
  44464. /**
  44465. * Specifies whether or not this material should be rendered in alpha blend mode.
  44466. */
  44467. needAlphaBlending(): boolean;
  44468. /**
  44469. * Specifies if the mesh will require alpha blending.
  44470. * @param mesh - BJS mesh.
  44471. */
  44472. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  44473. /**
  44474. * Specifies whether or not this material should be rendered in alpha test mode.
  44475. */
  44476. needAlphaTesting(): boolean;
  44477. /**
  44478. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  44479. */
  44480. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  44481. /**
  44482. * Gets the texture used for the alpha test.
  44483. */
  44484. getAlphaTestTexture(): BaseTexture;
  44485. /**
  44486. * Stores the reflectivity values based on metallic roughness workflow.
  44487. */
  44488. private static _scaledReflectivity;
  44489. /**
  44490. * Specifies that the submesh is ready to be used.
  44491. * @param mesh - BJS mesh.
  44492. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  44493. * @param useInstances - Specifies that instances should be used.
  44494. * @returns - boolean indicating that the submesh is ready or not.
  44495. */
  44496. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  44497. /**
  44498. * Specifies if the material uses metallic roughness workflow.
  44499. * @returns boolean specifiying if the material uses metallic roughness workflow.
  44500. */
  44501. isMetallicWorkflow(): boolean;
  44502. private _prepareEffect;
  44503. private _prepareDefines;
  44504. /**
  44505. * Force shader compilation
  44506. */
  44507. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  44508. clipPlane: boolean;
  44509. }>): void;
  44510. /**
  44511. * Initializes the uniform buffer layout for the shader.
  44512. */
  44513. buildUniformLayout(): void;
  44514. /**
  44515. * Unbinds the textures.
  44516. */
  44517. unbind(): void;
  44518. /**
  44519. * Binds the submesh data.
  44520. * @param world - The world matrix.
  44521. * @param mesh - The BJS mesh.
  44522. * @param subMesh - A submesh of the BJS mesh.
  44523. */
  44524. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  44525. /**
  44526. * Returns the animatable textures.
  44527. * @returns - Array of animatable textures.
  44528. */
  44529. getAnimatables(): IAnimatable[];
  44530. /**
  44531. * Returns the texture used for reflections.
  44532. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  44533. */
  44534. private _getReflectionTexture;
  44535. /**
  44536. * Returns the texture used for refraction or null if none is used.
  44537. * @returns - Refection texture if present. If no refraction texture and refraction
  44538. * is linked with transparency, returns environment texture. Otherwise, returns null.
  44539. */
  44540. private _getRefractionTexture;
  44541. /**
  44542. * Disposes the resources of the material.
  44543. * @param forceDisposeEffect - Forces the disposal of effects.
  44544. * @param forceDisposeTextures - Forces the disposal of all textures.
  44545. */
  44546. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  44547. }
  44548. }
  44549. declare module BABYLON {
  44550. /**
  44551. * The Physically based simple base material of BJS.
  44552. *
  44553. * This enables better naming and convention enforcements on top of the pbrMaterial.
  44554. * It is used as the base class for both the specGloss and metalRough conventions.
  44555. */
  44556. abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  44557. /**
  44558. * Number of Simultaneous lights allowed on the material.
  44559. */
  44560. maxSimultaneousLights: number;
  44561. /**
  44562. * If sets to true, disables all the lights affecting the material.
  44563. */
  44564. disableLighting: boolean;
  44565. /**
  44566. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  44567. */
  44568. environmentTexture: BaseTexture;
  44569. /**
  44570. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  44571. */
  44572. invertNormalMapX: boolean;
  44573. /**
  44574. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  44575. */
  44576. invertNormalMapY: boolean;
  44577. /**
  44578. * Normal map used in the model.
  44579. */
  44580. normalTexture: BaseTexture;
  44581. /**
  44582. * Emissivie color used to self-illuminate the model.
  44583. */
  44584. emissiveColor: Color3;
  44585. /**
  44586. * Emissivie texture used to self-illuminate the model.
  44587. */
  44588. emissiveTexture: BaseTexture;
  44589. /**
  44590. * Occlusion Channel Strenght.
  44591. */
  44592. occlusionStrength: number;
  44593. /**
  44594. * Occlusion Texture of the material (adding extra occlusion effects).
  44595. */
  44596. occlusionTexture: BaseTexture;
  44597. /**
  44598. * Defines the alpha limits in alpha test mode.
  44599. */
  44600. alphaCutOff: number;
  44601. /**
  44602. * Gets the current double sided mode.
  44603. */
  44604. /**
  44605. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  44606. */
  44607. doubleSided: boolean;
  44608. /**
  44609. * Stores the pre-calculated light information of a mesh in a texture.
  44610. */
  44611. lightmapTexture: BaseTexture;
  44612. /**
  44613. * If true, the light map contains occlusion information instead of lighting info.
  44614. */
  44615. useLightmapAsShadowmap: boolean;
  44616. /**
  44617. * Return the active textures of the material.
  44618. */
  44619. getActiveTextures(): BaseTexture[];
  44620. hasTexture(texture: BaseTexture): boolean;
  44621. /**
  44622. * Instantiates a new PBRMaterial instance.
  44623. *
  44624. * @param name The material name
  44625. * @param scene The scene the material will be use in.
  44626. */
  44627. constructor(name: string, scene: Scene);
  44628. getClassName(): string;
  44629. }
  44630. }
  44631. declare module BABYLON {
  44632. /**
  44633. * The Physically based material of BJS.
  44634. *
  44635. * This offers the main features of a standard PBR material.
  44636. * For more information, please refer to the documentation :
  44637. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  44638. */
  44639. class PBRMaterial extends PBRBaseMaterial {
  44640. /**
  44641. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  44642. */
  44643. static readonly PBRMATERIAL_OPAQUE: number;
  44644. /**
  44645. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  44646. */
  44647. static readonly PBRMATERIAL_ALPHATEST: number;
  44648. /**
  44649. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44650. */
  44651. static readonly PBRMATERIAL_ALPHABLEND: number;
  44652. /**
  44653. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44654. * They are also discarded below the alpha cutoff threshold to improve performances.
  44655. */
  44656. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  44657. /**
  44658. * Defines the default value of how much AO map is occluding the analytical lights
  44659. * (point spot...).
  44660. */
  44661. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  44662. /**
  44663. * Intensity of the direct lights e.g. the four lights available in your scene.
  44664. * This impacts both the direct diffuse and specular highlights.
  44665. */
  44666. directIntensity: number;
  44667. /**
  44668. * Intensity of the emissive part of the material.
  44669. * This helps controlling the emissive effect without modifying the emissive color.
  44670. */
  44671. emissiveIntensity: number;
  44672. /**
  44673. * Intensity of the environment e.g. how much the environment will light the object
  44674. * either through harmonics for rough material or through the refelction for shiny ones.
  44675. */
  44676. environmentIntensity: number;
  44677. /**
  44678. * This is a special control allowing the reduction of the specular highlights coming from the
  44679. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  44680. */
  44681. specularIntensity: number;
  44682. /**
  44683. * Debug Control allowing disabling the bump map on this material.
  44684. */
  44685. disableBumpMap: boolean;
  44686. /**
  44687. * AKA Diffuse Texture in standard nomenclature.
  44688. */
  44689. albedoTexture: BaseTexture;
  44690. /**
  44691. * AKA Occlusion Texture in other nomenclature.
  44692. */
  44693. ambientTexture: BaseTexture;
  44694. /**
  44695. * AKA Occlusion Texture Intensity in other nomenclature.
  44696. */
  44697. ambientTextureStrength: number;
  44698. /**
  44699. * Defines how much the AO map is occluding the analytical lights (point spot...).
  44700. * 1 means it completely occludes it
  44701. * 0 mean it has no impact
  44702. */
  44703. ambientTextureImpactOnAnalyticalLights: number;
  44704. /**
  44705. * Stores the alpha values in a texture.
  44706. */
  44707. opacityTexture: BaseTexture;
  44708. /**
  44709. * Stores the reflection values in a texture.
  44710. */
  44711. reflectionTexture: Nullable<BaseTexture>;
  44712. /**
  44713. * Stores the emissive values in a texture.
  44714. */
  44715. emissiveTexture: BaseTexture;
  44716. /**
  44717. * AKA Specular texture in other nomenclature.
  44718. */
  44719. reflectivityTexture: BaseTexture;
  44720. /**
  44721. * Used to switch from specular/glossiness to metallic/roughness workflow.
  44722. */
  44723. metallicTexture: BaseTexture;
  44724. /**
  44725. * Specifies the metallic scalar of the metallic/roughness workflow.
  44726. * Can also be used to scale the metalness values of the metallic texture.
  44727. */
  44728. metallic: Nullable<number>;
  44729. /**
  44730. * Specifies the roughness scalar of the metallic/roughness workflow.
  44731. * Can also be used to scale the roughness values of the metallic texture.
  44732. */
  44733. roughness: Nullable<number>;
  44734. /**
  44735. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  44736. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  44737. */
  44738. microSurfaceTexture: BaseTexture;
  44739. /**
  44740. * Stores surface normal data used to displace a mesh in a texture.
  44741. */
  44742. bumpTexture: BaseTexture;
  44743. /**
  44744. * Stores the pre-calculated light information of a mesh in a texture.
  44745. */
  44746. lightmapTexture: BaseTexture;
  44747. /**
  44748. * Stores the refracted light information in a texture.
  44749. */
  44750. refractionTexture: BaseTexture;
  44751. /**
  44752. * The color of a material in ambient lighting.
  44753. */
  44754. ambientColor: Color3;
  44755. /**
  44756. * AKA Diffuse Color in other nomenclature.
  44757. */
  44758. albedoColor: Color3;
  44759. /**
  44760. * AKA Specular Color in other nomenclature.
  44761. */
  44762. reflectivityColor: Color3;
  44763. /**
  44764. * The color reflected from the material.
  44765. */
  44766. reflectionColor: Color3;
  44767. /**
  44768. * The color emitted from the material.
  44769. */
  44770. emissiveColor: Color3;
  44771. /**
  44772. * AKA Glossiness in other nomenclature.
  44773. */
  44774. microSurface: number;
  44775. /**
  44776. * source material index of refraction (IOR)' / 'destination material IOR.
  44777. */
  44778. indexOfRefraction: number;
  44779. /**
  44780. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  44781. */
  44782. invertRefractionY: boolean;
  44783. /**
  44784. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  44785. * Materials half opaque for instance using refraction could benefit from this control.
  44786. */
  44787. linkRefractionWithTransparency: boolean;
  44788. /**
  44789. * If true, the light map contains occlusion information instead of lighting info.
  44790. */
  44791. useLightmapAsShadowmap: boolean;
  44792. /**
  44793. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  44794. */
  44795. useAlphaFromAlbedoTexture: boolean;
  44796. /**
  44797. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  44798. */
  44799. forceAlphaTest: boolean;
  44800. /**
  44801. * Defines the alpha limits in alpha test mode.
  44802. */
  44803. alphaCutOff: number;
  44804. /**
  44805. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  44806. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  44807. */
  44808. useSpecularOverAlpha: boolean;
  44809. /**
  44810. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  44811. */
  44812. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  44813. /**
  44814. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  44815. */
  44816. useRoughnessFromMetallicTextureAlpha: boolean;
  44817. /**
  44818. * Specifies if the metallic texture contains the roughness information in its green channel.
  44819. */
  44820. useRoughnessFromMetallicTextureGreen: boolean;
  44821. /**
  44822. * Specifies if the metallic texture contains the metallness information in its blue channel.
  44823. */
  44824. useMetallnessFromMetallicTextureBlue: boolean;
  44825. /**
  44826. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  44827. */
  44828. useAmbientOcclusionFromMetallicTextureRed: boolean;
  44829. /**
  44830. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  44831. */
  44832. useAmbientInGrayScale: boolean;
  44833. /**
  44834. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  44835. * The material will try to infer what glossiness each pixel should be.
  44836. */
  44837. useAutoMicroSurfaceFromReflectivityMap: boolean;
  44838. /**
  44839. * BJS is using an harcoded light falloff based on a manually sets up range.
  44840. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  44841. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  44842. */
  44843. /**
  44844. * BJS is using an harcoded light falloff based on a manually sets up range.
  44845. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  44846. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  44847. */
  44848. usePhysicalLightFalloff: boolean;
  44849. /**
  44850. * In order to support the falloff compatibility with gltf, a special mode has been added
  44851. * to reproduce the gltf light falloff.
  44852. */
  44853. /**
  44854. * In order to support the falloff compatibility with gltf, a special mode has been added
  44855. * to reproduce the gltf light falloff.
  44856. */
  44857. useGLTFLightFalloff: boolean;
  44858. /**
  44859. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  44860. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  44861. */
  44862. useRadianceOverAlpha: boolean;
  44863. /**
  44864. * Allows using an object space normal map (instead of tangent space).
  44865. */
  44866. useObjectSpaceNormalMap: boolean;
  44867. /**
  44868. * Allows using the bump map in parallax mode.
  44869. */
  44870. useParallax: boolean;
  44871. /**
  44872. * Allows using the bump map in parallax occlusion mode.
  44873. */
  44874. useParallaxOcclusion: boolean;
  44875. /**
  44876. * Controls the scale bias of the parallax mode.
  44877. */
  44878. parallaxScaleBias: number;
  44879. /**
  44880. * If sets to true, disables all the lights affecting the material.
  44881. */
  44882. disableLighting: boolean;
  44883. /**
  44884. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  44885. */
  44886. forceIrradianceInFragment: boolean;
  44887. /**
  44888. * Number of Simultaneous lights allowed on the material.
  44889. */
  44890. maxSimultaneousLights: number;
  44891. /**
  44892. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  44893. */
  44894. invertNormalMapX: boolean;
  44895. /**
  44896. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  44897. */
  44898. invertNormalMapY: boolean;
  44899. /**
  44900. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  44901. */
  44902. twoSidedLighting: boolean;
  44903. /**
  44904. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44905. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  44906. */
  44907. useAlphaFresnel: boolean;
  44908. /**
  44909. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44910. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  44911. */
  44912. useLinearAlphaFresnel: boolean;
  44913. /**
  44914. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44915. * And/Or occlude the blended part.
  44916. */
  44917. environmentBRDFTexture: Nullable<BaseTexture>;
  44918. /**
  44919. * Force normal to face away from face.
  44920. */
  44921. forceNormalForward: boolean;
  44922. /**
  44923. * Enables specular anti aliasing in the PBR shader.
  44924. * It will both interacts on the Geometry for analytical and IBL lighting.
  44925. * It also prefilter the roughness map based on the bump values.
  44926. */
  44927. enableSpecularAntiAliasing: boolean;
  44928. /**
  44929. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  44930. * makes the reflect vector face the model (under horizon).
  44931. */
  44932. useHorizonOcclusion: boolean;
  44933. /**
  44934. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  44935. * too much the area relying on ambient texture to define their ambient occlusion.
  44936. */
  44937. useRadianceOcclusion: boolean;
  44938. /**
  44939. * If set to true, no lighting calculations will be applied.
  44940. */
  44941. unlit: boolean;
  44942. /**
  44943. * Gets the image processing configuration used either in this material.
  44944. */
  44945. /**
  44946. * Sets the Default image processing configuration used either in the this material.
  44947. *
  44948. * If sets to null, the scene one is in use.
  44949. */
  44950. imageProcessingConfiguration: ImageProcessingConfiguration;
  44951. /**
  44952. * Gets wether the color curves effect is enabled.
  44953. */
  44954. /**
  44955. * Sets wether the color curves effect is enabled.
  44956. */
  44957. cameraColorCurvesEnabled: boolean;
  44958. /**
  44959. * Gets wether the color grading effect is enabled.
  44960. */
  44961. /**
  44962. * Gets wether the color grading effect is enabled.
  44963. */
  44964. cameraColorGradingEnabled: boolean;
  44965. /**
  44966. * Gets wether tonemapping is enabled or not.
  44967. */
  44968. /**
  44969. * Sets wether tonemapping is enabled or not
  44970. */
  44971. cameraToneMappingEnabled: boolean;
  44972. /**
  44973. * The camera exposure used on this material.
  44974. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44975. * This corresponds to a photographic exposure.
  44976. */
  44977. /**
  44978. * The camera exposure used on this material.
  44979. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44980. * This corresponds to a photographic exposure.
  44981. */
  44982. cameraExposure: number;
  44983. /**
  44984. * Gets The camera contrast used on this material.
  44985. */
  44986. /**
  44987. * Sets The camera contrast used on this material.
  44988. */
  44989. cameraContrast: number;
  44990. /**
  44991. * Gets the Color Grading 2D Lookup Texture.
  44992. */
  44993. /**
  44994. * Sets the Color Grading 2D Lookup Texture.
  44995. */
  44996. cameraColorGradingTexture: Nullable<BaseTexture>;
  44997. /**
  44998. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44999. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45000. * 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;
  45001. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45002. */
  45003. /**
  45004. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45005. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45006. * 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;
  45007. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45008. */
  45009. cameraColorCurves: Nullable<ColorCurves>;
  45010. /**
  45011. * Instantiates a new PBRMaterial instance.
  45012. *
  45013. * @param name The material name
  45014. * @param scene The scene the material will be use in.
  45015. */
  45016. constructor(name: string, scene: Scene);
  45017. /**
  45018. * Returns the name of this material class.
  45019. */
  45020. getClassName(): string;
  45021. /**
  45022. * Returns an array of the actively used textures.
  45023. * @returns - Array of BaseTextures
  45024. */
  45025. getActiveTextures(): BaseTexture[];
  45026. /**
  45027. * Checks to see if a texture is used in the material.
  45028. * @param texture - Base texture to use.
  45029. * @returns - Boolean specifying if a texture is used in the material.
  45030. */
  45031. hasTexture(texture: BaseTexture): boolean;
  45032. /**
  45033. * Makes a duplicate of the current material.
  45034. * @param name - name to use for the new material.
  45035. */
  45036. clone(name: string): PBRMaterial;
  45037. /**
  45038. * Serializes this PBR Material.
  45039. * @returns - An object with the serialized material.
  45040. */
  45041. serialize(): any;
  45042. /**
  45043. * Parses a PBR Material from a serialized object.
  45044. * @param source - Serialized object.
  45045. * @param scene - BJS scene instance.
  45046. * @param rootUrl - url for the scene object
  45047. * @returns - PBRMaterial
  45048. */
  45049. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  45050. }
  45051. }
  45052. declare module BABYLON {
  45053. /**
  45054. * The PBR material of BJS following the metal roughness convention.
  45055. *
  45056. * This fits to the PBR convention in the GLTF definition:
  45057. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  45058. */
  45059. class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  45060. /**
  45061. * The base color has two different interpretations depending on the value of metalness.
  45062. * When the material is a metal, the base color is the specific measured reflectance value
  45063. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  45064. * of the material.
  45065. */
  45066. baseColor: Color3;
  45067. /**
  45068. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  45069. * well as opacity information in the alpha channel.
  45070. */
  45071. baseTexture: BaseTexture;
  45072. /**
  45073. * Specifies the metallic scalar value of the material.
  45074. * Can also be used to scale the metalness values of the metallic texture.
  45075. */
  45076. metallic: number;
  45077. /**
  45078. * Specifies the roughness scalar value of the material.
  45079. * Can also be used to scale the roughness values of the metallic texture.
  45080. */
  45081. roughness: number;
  45082. /**
  45083. * Texture containing both the metallic value in the B channel and the
  45084. * roughness value in the G channel to keep better precision.
  45085. */
  45086. metallicRoughnessTexture: BaseTexture;
  45087. /**
  45088. * Instantiates a new PBRMetalRoughnessMaterial instance.
  45089. *
  45090. * @param name The material name
  45091. * @param scene The scene the material will be use in.
  45092. */
  45093. constructor(name: string, scene: Scene);
  45094. /**
  45095. * Return the currrent class name of the material.
  45096. */
  45097. getClassName(): string;
  45098. /**
  45099. * Return the active textures of the material.
  45100. */
  45101. getActiveTextures(): BaseTexture[];
  45102. /**
  45103. * Checks to see if a texture is used in the material.
  45104. * @param texture - Base texture to use.
  45105. * @returns - Boolean specifying if a texture is used in the material.
  45106. */
  45107. hasTexture(texture: BaseTexture): boolean;
  45108. /**
  45109. * Makes a duplicate of the current material.
  45110. * @param name - name to use for the new material.
  45111. */
  45112. clone(name: string): PBRMetallicRoughnessMaterial;
  45113. /**
  45114. * Serialize the material to a parsable JSON object.
  45115. */
  45116. serialize(): any;
  45117. /**
  45118. * Parses a JSON object correponding to the serialize function.
  45119. */
  45120. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  45121. }
  45122. }
  45123. declare module BABYLON {
  45124. /**
  45125. * The PBR material of BJS following the specular glossiness convention.
  45126. *
  45127. * This fits to the PBR convention in the GLTF definition:
  45128. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  45129. */
  45130. class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  45131. /**
  45132. * Specifies the diffuse color of the material.
  45133. */
  45134. diffuseColor: Color3;
  45135. /**
  45136. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  45137. * channel.
  45138. */
  45139. diffuseTexture: BaseTexture;
  45140. /**
  45141. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  45142. */
  45143. specularColor: Color3;
  45144. /**
  45145. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  45146. */
  45147. glossiness: number;
  45148. /**
  45149. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  45150. */
  45151. specularGlossinessTexture: BaseTexture;
  45152. /**
  45153. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  45154. *
  45155. * @param name The material name
  45156. * @param scene The scene the material will be use in.
  45157. */
  45158. constructor(name: string, scene: Scene);
  45159. /**
  45160. * Return the currrent class name of the material.
  45161. */
  45162. getClassName(): string;
  45163. /**
  45164. * Return the active textures of the material.
  45165. */
  45166. getActiveTextures(): BaseTexture[];
  45167. /**
  45168. * Checks to see if a texture is used in the material.
  45169. * @param texture - Base texture to use.
  45170. * @returns - Boolean specifying if a texture is used in the material.
  45171. */
  45172. hasTexture(texture: BaseTexture): boolean;
  45173. /**
  45174. * Makes a duplicate of the current material.
  45175. * @param name - name to use for the new material.
  45176. */
  45177. clone(name: string): PBRSpecularGlossinessMaterial;
  45178. /**
  45179. * Serialize the material to a parsable JSON object.
  45180. */
  45181. serialize(): any;
  45182. /**
  45183. * Parses a JSON object correponding to the serialize function.
  45184. */
  45185. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  45186. }
  45187. }
  45188. declare module BABYLON {
  45189. /**
  45190. * Base class of all the textures in babylon.
  45191. * It groups all the common properties the materials, post process, lights... might need
  45192. * in order to make a correct use of the texture.
  45193. */
  45194. class BaseTexture {
  45195. /**
  45196. * Default anisotropic filtering level for the application.
  45197. * It is set to 4 as a good tradeoff between perf and quality.
  45198. */
  45199. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  45200. /**
  45201. * Define the name of the texture.
  45202. */
  45203. name: string;
  45204. private _hasAlpha;
  45205. /**
  45206. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  45207. */
  45208. hasAlpha: boolean;
  45209. /**
  45210. * Defines if the alpha value should be determined via the rgb values.
  45211. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  45212. */
  45213. getAlphaFromRGB: boolean;
  45214. /**
  45215. * Intensity or strength of the texture.
  45216. * It is commonly used by materials to fine tune the intensity of the texture
  45217. */
  45218. level: number;
  45219. /**
  45220. * Define the UV chanel to use starting from 0 and defaulting to 0.
  45221. * This is part of the texture as textures usually maps to one uv set.
  45222. */
  45223. coordinatesIndex: number;
  45224. private _coordinatesMode;
  45225. /**
  45226. * How a texture is mapped.
  45227. *
  45228. * | Value | Type | Description |
  45229. * | ----- | ----------------------------------- | ----------- |
  45230. * | 0 | EXPLICIT_MODE | |
  45231. * | 1 | SPHERICAL_MODE | |
  45232. * | 2 | PLANAR_MODE | |
  45233. * | 3 | CUBIC_MODE | |
  45234. * | 4 | PROJECTION_MODE | |
  45235. * | 5 | SKYBOX_MODE | |
  45236. * | 6 | INVCUBIC_MODE | |
  45237. * | 7 | EQUIRECTANGULAR_MODE | |
  45238. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  45239. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  45240. */
  45241. coordinatesMode: number;
  45242. /**
  45243. * | Value | Type | Description |
  45244. * | ----- | ------------------ | ----------- |
  45245. * | 0 | CLAMP_ADDRESSMODE | |
  45246. * | 1 | WRAP_ADDRESSMODE | |
  45247. * | 2 | MIRROR_ADDRESSMODE | |
  45248. */
  45249. wrapU: number;
  45250. /**
  45251. * | Value | Type | Description |
  45252. * | ----- | ------------------ | ----------- |
  45253. * | 0 | CLAMP_ADDRESSMODE | |
  45254. * | 1 | WRAP_ADDRESSMODE | |
  45255. * | 2 | MIRROR_ADDRESSMODE | |
  45256. */
  45257. wrapV: number;
  45258. /**
  45259. * | Value | Type | Description |
  45260. * | ----- | ------------------ | ----------- |
  45261. * | 0 | CLAMP_ADDRESSMODE | |
  45262. * | 1 | WRAP_ADDRESSMODE | |
  45263. * | 2 | MIRROR_ADDRESSMODE | |
  45264. */
  45265. wrapR: number;
  45266. /**
  45267. * With compliant hardware and browser (supporting anisotropic filtering)
  45268. * this defines the level of anisotropic filtering in the texture.
  45269. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  45270. */
  45271. anisotropicFilteringLevel: number;
  45272. /**
  45273. * Define if the texture is a cube texture or if false a 2d texture.
  45274. */
  45275. isCube: boolean;
  45276. /**
  45277. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  45278. */
  45279. is3D: boolean;
  45280. /**
  45281. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  45282. * HDR texture are usually stored in linear space.
  45283. * This only impacts the PBR and Background materials
  45284. */
  45285. gammaSpace: boolean;
  45286. /**
  45287. * Gets whether or not the texture contains RGBD data.
  45288. */
  45289. readonly isRGBD: boolean;
  45290. /**
  45291. * Is Z inverted in the texture (useful in a cube texture).
  45292. */
  45293. invertZ: boolean;
  45294. /**
  45295. * @hidden
  45296. */
  45297. lodLevelInAlpha: boolean;
  45298. /**
  45299. * With prefiltered texture, defined the offset used during the prefiltering steps.
  45300. */
  45301. lodGenerationOffset: number;
  45302. /**
  45303. * With prefiltered texture, defined the scale used during the prefiltering steps.
  45304. */
  45305. lodGenerationScale: number;
  45306. /**
  45307. * Define if the texture is a render target.
  45308. */
  45309. isRenderTarget: boolean;
  45310. /**
  45311. * Define the unique id of the texture in the scene.
  45312. */
  45313. readonly uid: string;
  45314. /**
  45315. * Return a string representation of the texture.
  45316. * @returns the texture as a string
  45317. */
  45318. toString(): string;
  45319. /**
  45320. * Get the class name of the texture.
  45321. * @returns "BaseTexture"
  45322. */
  45323. getClassName(): string;
  45324. /**
  45325. * Define the list of animation attached to the texture.
  45326. */
  45327. animations: Animation[];
  45328. /**
  45329. * An event triggered when the texture is disposed.
  45330. */
  45331. onDisposeObservable: Observable<BaseTexture>;
  45332. private _onDisposeObserver;
  45333. /**
  45334. * Callback triggered when the texture has been disposed.
  45335. * Kept for back compatibility, you can use the onDisposeObservable instead.
  45336. */
  45337. onDispose: () => void;
  45338. /**
  45339. * Define the current state of the loading sequence when in delayed load mode.
  45340. */
  45341. delayLoadState: number;
  45342. private _scene;
  45343. /** @hidden */
  45344. _texture: Nullable<InternalTexture>;
  45345. private _uid;
  45346. /**
  45347. * Define if the texture is preventinga material to render or not.
  45348. * If not and the texture is not ready, the engine will use a default black texture instead.
  45349. */
  45350. readonly isBlocking: boolean;
  45351. /**
  45352. * Instantiates a new BaseTexture.
  45353. * Base class of all the textures in babylon.
  45354. * It groups all the common properties the materials, post process, lights... might need
  45355. * in order to make a correct use of the texture.
  45356. * @param scene Define the scene the texture blongs to
  45357. */
  45358. constructor(scene: Nullable<Scene>);
  45359. /**
  45360. * Get the scene the texture belongs to.
  45361. * @returns the scene or null if undefined
  45362. */
  45363. getScene(): Nullable<Scene>;
  45364. /**
  45365. * Get the texture transform matrix used to offset tile the texture for istance.
  45366. * @returns the transformation matrix
  45367. */
  45368. getTextureMatrix(): Matrix;
  45369. /**
  45370. * Get the texture reflection matrix used to rotate/transform the reflection.
  45371. * @returns the reflection matrix
  45372. */
  45373. getReflectionTextureMatrix(): Matrix;
  45374. /**
  45375. * Get the underlying lower level texture from Babylon.
  45376. * @returns the insternal texture
  45377. */
  45378. getInternalTexture(): Nullable<InternalTexture>;
  45379. /**
  45380. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  45381. * @returns true if ready or not blocking
  45382. */
  45383. isReadyOrNotBlocking(): boolean;
  45384. /**
  45385. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  45386. * @returns true if fully ready
  45387. */
  45388. isReady(): boolean;
  45389. private _cachedSize;
  45390. /**
  45391. * Get the size of the texture.
  45392. * @returns the texture size.
  45393. */
  45394. getSize(): ISize;
  45395. /**
  45396. * Get the base size of the texture.
  45397. * It can be different from the size if the texture has been resized for POT for instance
  45398. * @returns the base size
  45399. */
  45400. getBaseSize(): ISize;
  45401. /**
  45402. * Scales the texture if is `canRescale()`
  45403. * @param ratio the resize factor we want to use to rescale
  45404. */
  45405. scale(ratio: number): void;
  45406. /**
  45407. * Get if the texture can rescale.
  45408. */
  45409. readonly canRescale: boolean;
  45410. /** @hidden */
  45411. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  45412. /** @hidden */
  45413. _rebuild(): void;
  45414. /**
  45415. * Triggers the load sequence in delayed load mode.
  45416. */
  45417. delayLoad(): void;
  45418. /**
  45419. * Clones the texture.
  45420. * @returns the cloned texture
  45421. */
  45422. clone(): Nullable<BaseTexture>;
  45423. /**
  45424. * Get the texture underlying type (INT, FLOAT...)
  45425. */
  45426. readonly textureType: number;
  45427. /**
  45428. * Get the texture underlying format (RGB, RGBA...)
  45429. */
  45430. readonly textureFormat: number;
  45431. /**
  45432. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  45433. * This will returns an RGBA array buffer containing either in values (0-255) or
  45434. * float values (0-1) depending of the underlying buffer type.
  45435. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  45436. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  45437. * @param buffer defines a user defined buffer to fill with data (can be null)
  45438. * @returns The Array buffer containing the pixels data.
  45439. */
  45440. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  45441. /**
  45442. * Release and destroy the underlying lower level texture aka internalTexture.
  45443. */
  45444. releaseInternalTexture(): void;
  45445. /**
  45446. * Get the polynomial representation of the texture data.
  45447. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  45448. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  45449. */
  45450. sphericalPolynomial: Nullable<SphericalPolynomial>;
  45451. /** @hidden */
  45452. readonly _lodTextureHigh: Nullable<BaseTexture>;
  45453. /** @hidden */
  45454. readonly _lodTextureMid: Nullable<BaseTexture>;
  45455. /** @hidden */
  45456. readonly _lodTextureLow: Nullable<BaseTexture>;
  45457. /**
  45458. * Dispose the texture and release its associated resources.
  45459. */
  45460. dispose(): void;
  45461. /**
  45462. * Serialize the texture into a JSON representation that can be parsed later on.
  45463. * @returns the JSON representation of the texture
  45464. */
  45465. serialize(): any;
  45466. /**
  45467. * Helper function to be called back once a list of texture contains only ready textures.
  45468. * @param textures Define the list of textures to wait for
  45469. * @param callback Define the callback triggered once the entire list will be ready
  45470. */
  45471. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  45472. }
  45473. }
  45474. declare module BABYLON {
  45475. /**
  45476. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  45477. * It can help converting any input color in a desired output one. This can then be used to create effects
  45478. * from sepia, black and white to sixties or futuristic rendering...
  45479. *
  45480. * The only supported format is currently 3dl.
  45481. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  45482. */
  45483. class ColorGradingTexture extends BaseTexture {
  45484. /**
  45485. * The current texture matrix. (will always be identity in color grading texture)
  45486. */
  45487. private _textureMatrix;
  45488. /**
  45489. * The texture URL.
  45490. */
  45491. url: string;
  45492. /**
  45493. * Empty line regex stored for GC.
  45494. */
  45495. private static _noneEmptyLineRegex;
  45496. private _engine;
  45497. /**
  45498. * Instantiates a ColorGradingTexture from the following parameters.
  45499. *
  45500. * @param url The location of the color gradind data (currently only supporting 3dl)
  45501. * @param scene The scene the texture will be used in
  45502. */
  45503. constructor(url: string, scene: Scene);
  45504. /**
  45505. * Returns the texture matrix used in most of the material.
  45506. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  45507. */
  45508. getTextureMatrix(): Matrix;
  45509. /**
  45510. * Occurs when the file being loaded is a .3dl LUT file.
  45511. */
  45512. private load3dlTexture;
  45513. /**
  45514. * Starts the loading process of the texture.
  45515. */
  45516. private loadTexture;
  45517. /**
  45518. * Clones the color gradind texture.
  45519. */
  45520. clone(): ColorGradingTexture;
  45521. /**
  45522. * Called during delayed load for textures.
  45523. */
  45524. delayLoad(): void;
  45525. /**
  45526. * Parses a color grading texture serialized by Babylon.
  45527. * @param parsedTexture The texture information being parsedTexture
  45528. * @param scene The scene to load the texture in
  45529. * @param rootUrl The root url of the data assets to load
  45530. * @return A color gradind texture
  45531. */
  45532. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<ColorGradingTexture>;
  45533. /**
  45534. * Serializes the LUT texture to json format.
  45535. */
  45536. serialize(): any;
  45537. }
  45538. }
  45539. declare module BABYLON {
  45540. /**
  45541. * Class for creating a cube texture
  45542. */
  45543. class CubeTexture extends BaseTexture {
  45544. /**
  45545. * The url of the texture
  45546. */
  45547. url: string;
  45548. /**
  45549. * Gets or sets the center of the bounding box associated with the cube texture.
  45550. * It must define where the camera used to render the texture was set
  45551. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  45552. */
  45553. boundingBoxPosition: Vector3;
  45554. private _boundingBoxSize;
  45555. /**
  45556. * Gets or sets the size of the bounding box associated with the cube texture
  45557. * When defined, the cubemap will switch to local mode
  45558. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  45559. * @example https://www.babylonjs-playground.com/#RNASML
  45560. */
  45561. /**
  45562. * Returns the bounding box size
  45563. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  45564. */
  45565. boundingBoxSize: Vector3;
  45566. protected _rotationY: number;
  45567. /**
  45568. * Sets texture matrix rotation angle around Y axis in radians.
  45569. */
  45570. /**
  45571. * Gets texture matrix rotation angle around Y axis radians.
  45572. */
  45573. rotationY: number;
  45574. private _noMipmap;
  45575. private _files;
  45576. private _extensions;
  45577. private _textureMatrix;
  45578. private _format;
  45579. private _createPolynomials;
  45580. /** @hidden */
  45581. readonly _prefiltered: boolean;
  45582. /**
  45583. * Creates a cube texture from an array of image urls
  45584. * @param files defines an array of image urls
  45585. * @param scene defines the hosting scene
  45586. * @param noMipmap specifies if mip maps are not used
  45587. * @returns a cube texture
  45588. */
  45589. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  45590. /**
  45591. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  45592. * @param url defines the url of the prefiltered texture
  45593. * @param scene defines the scene the texture is attached to
  45594. * @param forcedExtension defines the extension of the file if different from the url
  45595. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  45596. * @return the prefiltered texture
  45597. */
  45598. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  45599. /**
  45600. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  45601. * as prefiltered data.
  45602. * @param rootUrl defines the url of the texture or the root name of the six images
  45603. * @param scene defines the scene the texture is attached to
  45604. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  45605. * @param noMipmap defines if mipmaps should be created or not
  45606. * @param files defines the six files to load for the different faces
  45607. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  45608. * @param onError defines a callback triggered in case of error during load
  45609. * @param format defines the internal format to use for the texture once loaded
  45610. * @param prefiltered defines whether or not the texture is created from prefiltered data
  45611. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  45612. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  45613. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  45614. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  45615. * @return the cube texture
  45616. */
  45617. 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);
  45618. /**
  45619. * Delays loading of the cube texture
  45620. */
  45621. delayLoad(): void;
  45622. /**
  45623. * Returns the reflection texture matrix
  45624. * @returns the reflection texture matrix
  45625. */
  45626. getReflectionTextureMatrix(): Matrix;
  45627. /**
  45628. * Sets the reflection texture matrix
  45629. * @param value Reflection texture matrix
  45630. */
  45631. setReflectionTextureMatrix(value: Matrix): void;
  45632. /**
  45633. * Parses text to create a cube texture
  45634. * @param parsedTexture define the serialized text to read from
  45635. * @param scene defines the hosting scene
  45636. * @param rootUrl defines the root url of the cube texture
  45637. * @returns a cube texture
  45638. */
  45639. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  45640. /**
  45641. * Makes a clone, or deep copy, of the cube texture
  45642. * @returns a new cube texture
  45643. */
  45644. clone(): CubeTexture;
  45645. }
  45646. }
  45647. declare module BABYLON {
  45648. /**
  45649. * A class extending Texture allowing drawing on a texture
  45650. * @see http://doc.babylonjs.com/how_to/dynamictexture
  45651. */
  45652. class DynamicTexture extends Texture {
  45653. private _generateMipMaps;
  45654. private _canvas;
  45655. private _context;
  45656. private _engine;
  45657. /**
  45658. * Creates a DynamicTexture
  45659. * @param name defines the name of the texture
  45660. * @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
  45661. * @param scene defines the scene where you want the texture
  45662. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  45663. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  45664. * @param format defines the texture format to use (default is BABYLON.Engine.TEXTUREFORMAT_RGBA)
  45665. */
  45666. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  45667. /**
  45668. * Gets the current state of canRescale
  45669. */
  45670. readonly canRescale: boolean;
  45671. private _recreate;
  45672. /**
  45673. * Scales the texture
  45674. * @param ratio the scale factor to apply to both width and height
  45675. */
  45676. scale(ratio: number): void;
  45677. /**
  45678. * Resizes the texture
  45679. * @param width the new width
  45680. * @param height the new height
  45681. */
  45682. scaleTo(width: number, height: number): void;
  45683. /**
  45684. * Gets the context of the canvas used by the texture
  45685. * @returns the canvas context of the dynamic texture
  45686. */
  45687. getContext(): CanvasRenderingContext2D;
  45688. /**
  45689. * Clears the texture
  45690. */
  45691. clear(): void;
  45692. /**
  45693. * Updates the texture
  45694. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  45695. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  45696. */
  45697. update(invertY?: boolean, premulAlpha?: boolean): void;
  45698. /**
  45699. * Draws text onto the texture
  45700. * @param text defines the text to be drawn
  45701. * @param x defines the placement of the text from the left
  45702. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  45703. * @param font defines the font to be used with font-style, font-size, font-name
  45704. * @param color defines the color used for the text
  45705. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  45706. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  45707. * @param update defines whether texture is immediately update (default is true)
  45708. */
  45709. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  45710. /**
  45711. * Clones the texture
  45712. * @returns the clone of the texture.
  45713. */
  45714. clone(): DynamicTexture;
  45715. /**
  45716. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  45717. * @returns a serialized dynamic texture object
  45718. */
  45719. serialize(): any;
  45720. /** @hidden */
  45721. _rebuild(): void;
  45722. }
  45723. }
  45724. declare module BABYLON {
  45725. /**
  45726. * This represents a texture coming from an HDR input.
  45727. *
  45728. * The only supported format is currently panorama picture stored in RGBE format.
  45729. * Example of such files can be found on HDRLib: http://hdrlib.com/
  45730. */
  45731. class HDRCubeTexture extends BaseTexture {
  45732. private static _facesMapping;
  45733. private _generateHarmonics;
  45734. private _noMipmap;
  45735. private _textureMatrix;
  45736. private _size;
  45737. private _onLoad;
  45738. private _onError;
  45739. /**
  45740. * The texture URL.
  45741. */
  45742. url: string;
  45743. /**
  45744. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  45745. */
  45746. coordinatesMode: number;
  45747. protected _isBlocking: boolean;
  45748. /**
  45749. * Sets wether or not the texture is blocking during loading.
  45750. */
  45751. /**
  45752. * Gets wether or not the texture is blocking during loading.
  45753. */
  45754. isBlocking: boolean;
  45755. protected _rotationY: number;
  45756. /**
  45757. * Sets texture matrix rotation angle around Y axis in radians.
  45758. */
  45759. /**
  45760. * Gets texture matrix rotation angle around Y axis radians.
  45761. */
  45762. rotationY: number;
  45763. /**
  45764. * Gets or sets the center of the bounding box associated with the cube texture
  45765. * It must define where the camera used to render the texture was set
  45766. */
  45767. boundingBoxPosition: Vector3;
  45768. private _boundingBoxSize;
  45769. /**
  45770. * Gets or sets the size of the bounding box associated with the cube texture
  45771. * When defined, the cubemap will switch to local mode
  45772. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  45773. * @example https://www.babylonjs-playground.com/#RNASML
  45774. */
  45775. boundingBoxSize: Vector3;
  45776. /**
  45777. * Instantiates an HDRTexture from the following parameters.
  45778. *
  45779. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  45780. * @param scene The scene the texture will be used in
  45781. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  45782. * @param noMipmap Forces to not generate the mipmap if true
  45783. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  45784. * @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)
  45785. * @param reserved Reserved flag for internal use.
  45786. */
  45787. 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>);
  45788. /**
  45789. * Occurs when the file is raw .hdr file.
  45790. */
  45791. private loadTexture;
  45792. clone(): HDRCubeTexture;
  45793. delayLoad(): void;
  45794. /**
  45795. * Get the texture reflection matrix used to rotate/transform the reflection.
  45796. * @returns the reflection matrix
  45797. */
  45798. getReflectionTextureMatrix(): Matrix;
  45799. /**
  45800. * Set the texture reflection matrix used to rotate/transform the reflection.
  45801. * @param value Define the reflection matrix to set
  45802. */
  45803. setReflectionTextureMatrix(value: Matrix): void;
  45804. /**
  45805. * Parses a JSON representation of an HDR Texture in order to create the texture
  45806. * @param parsedTexture Define the JSON representation
  45807. * @param scene Define the scene the texture should be created in
  45808. * @param rootUrl Define the root url in case we need to load relative dependencies
  45809. * @returns the newly created texture after parsing
  45810. */
  45811. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  45812. serialize(): any;
  45813. }
  45814. }
  45815. declare module BABYLON {
  45816. /**
  45817. * Class used to store data associated with WebGL texture data for the engine
  45818. * This class should not be used directly
  45819. */
  45820. class InternalTexture implements IInternalTextureTracker {
  45821. /**
  45822. * The source of the texture data is unknown
  45823. */
  45824. static DATASOURCE_UNKNOWN: number;
  45825. /**
  45826. * Texture data comes from an URL
  45827. */
  45828. static DATASOURCE_URL: number;
  45829. /**
  45830. * Texture data is only used for temporary storage
  45831. */
  45832. static DATASOURCE_TEMP: number;
  45833. /**
  45834. * Texture data comes from raw data (ArrayBuffer)
  45835. */
  45836. static DATASOURCE_RAW: number;
  45837. /**
  45838. * Texture content is dynamic (video or dynamic texture)
  45839. */
  45840. static DATASOURCE_DYNAMIC: number;
  45841. /**
  45842. * Texture content is generated by rendering to it
  45843. */
  45844. static DATASOURCE_RENDERTARGET: number;
  45845. /**
  45846. * Texture content is part of a multi render target process
  45847. */
  45848. static DATASOURCE_MULTIRENDERTARGET: number;
  45849. /**
  45850. * Texture data comes from a cube data file
  45851. */
  45852. static DATASOURCE_CUBE: number;
  45853. /**
  45854. * Texture data comes from a raw cube data
  45855. */
  45856. static DATASOURCE_CUBERAW: number;
  45857. /**
  45858. * Texture data come from a prefiltered cube data file
  45859. */
  45860. static DATASOURCE_CUBEPREFILTERED: number;
  45861. /**
  45862. * Texture content is raw 3D data
  45863. */
  45864. static DATASOURCE_RAW3D: number;
  45865. /**
  45866. * Texture content is a depth texture
  45867. */
  45868. static DATASOURCE_DEPTHTEXTURE: number;
  45869. /**
  45870. * Texture data comes from a raw cube data encoded with RGBD
  45871. */
  45872. static DATASOURCE_CUBERAW_RGBD: number;
  45873. /**
  45874. * Defines if the texture is ready
  45875. */
  45876. isReady: boolean;
  45877. /**
  45878. * Defines if the texture is a cube texture
  45879. */
  45880. isCube: boolean;
  45881. /**
  45882. * Defines if the texture contains 3D data
  45883. */
  45884. is3D: boolean;
  45885. /**
  45886. * Gets the URL used to load this texture
  45887. */
  45888. url: string;
  45889. /**
  45890. * Gets the sampling mode of the texture
  45891. */
  45892. samplingMode: number;
  45893. /**
  45894. * Gets a boolean indicating if the texture needs mipmaps generation
  45895. */
  45896. generateMipMaps: boolean;
  45897. /**
  45898. * Gets the number of samples used by the texture (WebGL2+ only)
  45899. */
  45900. samples: number;
  45901. /**
  45902. * Gets the type of the texture (int, float...)
  45903. */
  45904. type: number;
  45905. /**
  45906. * Gets the format of the texture (RGB, RGBA...)
  45907. */
  45908. format: number;
  45909. /**
  45910. * Observable called when the texture is loaded
  45911. */
  45912. onLoadedObservable: Observable<InternalTexture>;
  45913. /**
  45914. * Gets the width of the texture
  45915. */
  45916. width: number;
  45917. /**
  45918. * Gets the height of the texture
  45919. */
  45920. height: number;
  45921. /**
  45922. * Gets the depth of the texture
  45923. */
  45924. depth: number;
  45925. /**
  45926. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  45927. */
  45928. baseWidth: number;
  45929. /**
  45930. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  45931. */
  45932. baseHeight: number;
  45933. /**
  45934. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  45935. */
  45936. baseDepth: number;
  45937. /**
  45938. * Gets a boolean indicating if the texture is inverted on Y axis
  45939. */
  45940. invertY: boolean;
  45941. /**
  45942. * Gets or set the previous tracker in the list
  45943. */
  45944. previous: Nullable<IInternalTextureTracker>;
  45945. /**
  45946. * Gets or set the next tracker in the list
  45947. */
  45948. next: Nullable<IInternalTextureTracker>;
  45949. /** @hidden */
  45950. _initialSlot: number;
  45951. /** @hidden */
  45952. _designatedSlot: number;
  45953. /** @hidden */
  45954. _dataSource: number;
  45955. /** @hidden */
  45956. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  45957. /** @hidden */
  45958. _bufferView: Nullable<ArrayBufferView>;
  45959. /** @hidden */
  45960. _bufferViewArray: Nullable<ArrayBufferView[]>;
  45961. /** @hidden */
  45962. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  45963. /** @hidden */
  45964. _size: number;
  45965. /** @hidden */
  45966. _extension: string;
  45967. /** @hidden */
  45968. _files: Nullable<string[]>;
  45969. /** @hidden */
  45970. _workingCanvas: HTMLCanvasElement;
  45971. /** @hidden */
  45972. _workingContext: CanvasRenderingContext2D;
  45973. /** @hidden */
  45974. _framebuffer: Nullable<WebGLFramebuffer>;
  45975. /** @hidden */
  45976. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  45977. /** @hidden */
  45978. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  45979. /** @hidden */
  45980. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  45981. /** @hidden */
  45982. _attachments: Nullable<number[]>;
  45983. /** @hidden */
  45984. _cachedCoordinatesMode: Nullable<number>;
  45985. /** @hidden */
  45986. _cachedWrapU: Nullable<number>;
  45987. /** @hidden */
  45988. _cachedWrapV: Nullable<number>;
  45989. /** @hidden */
  45990. _cachedWrapR: Nullable<number>;
  45991. /** @hidden */
  45992. _cachedAnisotropicFilteringLevel: Nullable<number>;
  45993. /** @hidden */
  45994. _isDisabled: boolean;
  45995. /** @hidden */
  45996. _compression: Nullable<string>;
  45997. /** @hidden */
  45998. _generateStencilBuffer: boolean;
  45999. /** @hidden */
  46000. _generateDepthBuffer: boolean;
  46001. /** @hidden */
  46002. _comparisonFunction: number;
  46003. /** @hidden */
  46004. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  46005. /** @hidden */
  46006. _lodGenerationScale: number;
  46007. /** @hidden */
  46008. _lodGenerationOffset: number;
  46009. /** @hidden */
  46010. _lodTextureHigh: BaseTexture;
  46011. /** @hidden */
  46012. _lodTextureMid: BaseTexture;
  46013. /** @hidden */
  46014. _lodTextureLow: BaseTexture;
  46015. /** @hidden */
  46016. _isRGBD: boolean;
  46017. /** @hidden */
  46018. _webGLTexture: Nullable<WebGLTexture>;
  46019. /** @hidden */
  46020. _references: number;
  46021. private _engine;
  46022. /**
  46023. * Gets the Engine the texture belongs to.
  46024. * @returns The babylon engine
  46025. */
  46026. getEngine(): Engine;
  46027. /**
  46028. * Gets the data source type of the texture (can be one of the BABYLON.InternalTexture.DATASOURCE_XXXX)
  46029. */
  46030. readonly dataSource: number;
  46031. /**
  46032. * Creates a new InternalTexture
  46033. * @param engine defines the engine to use
  46034. * @param dataSource defines the type of data that will be used
  46035. */
  46036. constructor(engine: Engine, dataSource: number);
  46037. /**
  46038. * Increments the number of references (ie. the number of Texture that point to it)
  46039. */
  46040. incrementReferences(): void;
  46041. /**
  46042. * Change the size of the texture (not the size of the content)
  46043. * @param width defines the new width
  46044. * @param height defines the new height
  46045. * @param depth defines the new depth (1 by default)
  46046. */
  46047. updateSize(width: int, height: int, depth?: int): void;
  46048. /** @hidden */
  46049. _rebuild(): void;
  46050. /** @hidden */
  46051. _swapAndDie(target: InternalTexture): void;
  46052. /**
  46053. * Dispose the current allocated resources
  46054. */
  46055. dispose(): void;
  46056. }
  46057. }
  46058. declare module BABYLON {
  46059. /**
  46060. * This represents the required contract to create a new type of texture loader.
  46061. */
  46062. interface IInternalTextureLoader {
  46063. /**
  46064. * Defines wether the loader supports cascade loading the different faces.
  46065. */
  46066. supportCascades: boolean;
  46067. /**
  46068. * This returns if the loader support the current file information.
  46069. * @param extension defines the file extension of the file being loaded
  46070. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46071. * @param fallback defines the fallback internal texture if any
  46072. * @param isBase64 defines whether the texture is encoded as a base64
  46073. * @param isBuffer defines whether the texture data are stored as a buffer
  46074. * @returns true if the loader can load the specified file
  46075. */
  46076. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46077. /**
  46078. * Transform the url before loading if required.
  46079. * @param rootUrl the url of the texture
  46080. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46081. * @returns the transformed texture
  46082. */
  46083. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46084. /**
  46085. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46086. * @param rootUrl the url of the texture
  46087. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46088. * @returns the fallback texture
  46089. */
  46090. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46091. /**
  46092. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46093. * @param data contains the texture data
  46094. * @param texture defines the BabylonJS internal texture
  46095. * @param createPolynomials will be true if polynomials have been requested
  46096. * @param onLoad defines the callback to trigger once the texture is ready
  46097. * @param onError defines the callback to trigger in case of error
  46098. */
  46099. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46100. /**
  46101. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46102. * @param data contains the texture data
  46103. * @param texture defines the BabylonJS internal texture
  46104. * @param callback defines the method to call once ready to upload
  46105. */
  46106. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46107. }
  46108. }
  46109. declare module BABYLON {
  46110. /**
  46111. * Internal interface used to track InternalTexture already bound to the GL context
  46112. */
  46113. interface IInternalTextureTracker {
  46114. /**
  46115. * Gets or set the previous tracker in the list
  46116. */
  46117. previous: Nullable<IInternalTextureTracker>;
  46118. /**
  46119. * Gets or set the next tracker in the list
  46120. */
  46121. next: Nullable<IInternalTextureTracker>;
  46122. }
  46123. /**
  46124. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  46125. */
  46126. class DummyInternalTextureTracker {
  46127. /**
  46128. * Gets or set the previous tracker in the list
  46129. */
  46130. previous: Nullable<IInternalTextureTracker>;
  46131. /**
  46132. * Gets or set the next tracker in the list
  46133. */
  46134. next: Nullable<IInternalTextureTracker>;
  46135. }
  46136. }
  46137. declare module BABYLON {
  46138. /**
  46139. * Mirror texture can be used to simulate the view from a mirror in a scene.
  46140. * It will dynamically be rendered every frame to adapt to the camera point of view.
  46141. * You can then easily use it as a reflectionTexture on a flat surface.
  46142. * In case the surface is not a plane, please consider relying on reflection probes.
  46143. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  46144. */
  46145. class MirrorTexture extends RenderTargetTexture {
  46146. private scene;
  46147. /**
  46148. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  46149. * 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.
  46150. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  46151. */
  46152. mirrorPlane: Plane;
  46153. /**
  46154. * Define the blur ratio used to blur the reflection if needed.
  46155. */
  46156. blurRatio: number;
  46157. /**
  46158. * Define the adaptive blur kernel used to blur the reflection if needed.
  46159. * This will autocompute the closest best match for the `blurKernel`
  46160. */
  46161. adaptiveBlurKernel: number;
  46162. /**
  46163. * Define the blur kernel used to blur the reflection if needed.
  46164. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  46165. */
  46166. blurKernel: number;
  46167. /**
  46168. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  46169. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  46170. */
  46171. blurKernelX: number;
  46172. /**
  46173. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  46174. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  46175. */
  46176. blurKernelY: number;
  46177. private _autoComputeBlurKernel;
  46178. protected _onRatioRescale(): void;
  46179. private _updateGammaSpace;
  46180. private _imageProcessingConfigChangeObserver;
  46181. private _transformMatrix;
  46182. private _mirrorMatrix;
  46183. private _savedViewMatrix;
  46184. private _blurX;
  46185. private _blurY;
  46186. private _adaptiveBlurKernel;
  46187. private _blurKernelX;
  46188. private _blurKernelY;
  46189. private _blurRatio;
  46190. /**
  46191. * Instantiates a Mirror Texture.
  46192. * Mirror texture can be used to simulate the view from a mirror in a scene.
  46193. * It will dynamically be rendered every frame to adapt to the camera point of view.
  46194. * You can then easily use it as a reflectionTexture on a flat surface.
  46195. * In case the surface is not a plane, please consider relying on reflection probes.
  46196. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  46197. * @param name
  46198. * @param size
  46199. * @param scene
  46200. * @param generateMipMaps
  46201. * @param type
  46202. * @param samplingMode
  46203. * @param generateDepthBuffer
  46204. */
  46205. constructor(name: string, size: number | {
  46206. width: number;
  46207. height: number;
  46208. } | {
  46209. ratio: number;
  46210. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  46211. private _preparePostProcesses;
  46212. /**
  46213. * Clone the mirror texture.
  46214. * @returns the cloned texture
  46215. */
  46216. clone(): MirrorTexture;
  46217. /**
  46218. * Serialize the texture to a JSON representation you could use in Parse later on
  46219. * @returns the serialized JSON representation
  46220. */
  46221. serialize(): any;
  46222. /**
  46223. * Dispose the texture and release its associated resources.
  46224. */
  46225. dispose(): void;
  46226. }
  46227. }
  46228. declare module BABYLON {
  46229. /**
  46230. * Creation options of the multi render target texture.
  46231. */
  46232. interface IMultiRenderTargetOptions {
  46233. /**
  46234. * Define if the texture needs to create mip maps after render.
  46235. */
  46236. generateMipMaps?: boolean;
  46237. /**
  46238. * Define the types of all the draw buffers we want to create
  46239. */
  46240. types?: number[];
  46241. /**
  46242. * Define the sampling modes of all the draw buffers we want to create
  46243. */
  46244. samplingModes?: number[];
  46245. /**
  46246. * Define if a depth buffer is required
  46247. */
  46248. generateDepthBuffer?: boolean;
  46249. /**
  46250. * Define if a stencil buffer is required
  46251. */
  46252. generateStencilBuffer?: boolean;
  46253. /**
  46254. * Define if a depth texture is required instead of a depth buffer
  46255. */
  46256. generateDepthTexture?: boolean;
  46257. /**
  46258. * Define the number of desired draw buffers
  46259. */
  46260. textureCount?: number;
  46261. /**
  46262. * Define if aspect ratio should be adapted to the texture or stay the scene one
  46263. */
  46264. doNotChangeAspectRatio?: boolean;
  46265. /**
  46266. * Define the default type of the buffers we are creating
  46267. */
  46268. defaultType?: number;
  46269. }
  46270. /**
  46271. * A multi render target, like a render target provides the ability to render to a texture.
  46272. * Unlike the render target, it can render to several draw buffers in one draw.
  46273. * This is specially interesting in deferred rendering or for any effects requiring more than
  46274. * just one color from a single pass.
  46275. */
  46276. class MultiRenderTarget extends RenderTargetTexture {
  46277. private _internalTextures;
  46278. private _textures;
  46279. private _multiRenderTargetOptions;
  46280. /**
  46281. * Get if draw buffers are currently supported by the used hardware and browser.
  46282. */
  46283. readonly isSupported: boolean;
  46284. /**
  46285. * Get the list of textures generated by the multi render target.
  46286. */
  46287. readonly textures: Texture[];
  46288. /**
  46289. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  46290. */
  46291. readonly depthTexture: Texture;
  46292. /**
  46293. * Set the wrapping mode on U of all the textures we are rendering to.
  46294. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  46295. */
  46296. wrapU: number;
  46297. /**
  46298. * Set the wrapping mode on V of all the textures we are rendering to.
  46299. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  46300. */
  46301. wrapV: number;
  46302. /**
  46303. * Instantiate a new multi render target texture.
  46304. * A multi render target, like a render target provides the ability to render to a texture.
  46305. * Unlike the render target, it can render to several draw buffers in one draw.
  46306. * This is specially interesting in deferred rendering or for any effects requiring more than
  46307. * just one color from a single pass.
  46308. * @param name Define the name of the texture
  46309. * @param size Define the size of the buffers to render to
  46310. * @param count Define the number of target we are rendering into
  46311. * @param scene Define the scene the texture belongs to
  46312. * @param options Define the options used to create the multi render target
  46313. */
  46314. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  46315. /** @hidden */
  46316. _rebuild(): void;
  46317. private _createInternalTextures;
  46318. private _createTextures;
  46319. /**
  46320. * Define the number of samples used if MSAA is enabled.
  46321. */
  46322. samples: number;
  46323. /**
  46324. * Resize all the textures in the multi render target.
  46325. * Be carrefull as it will recreate all the data in the new texture.
  46326. * @param size Define the new size
  46327. */
  46328. resize(size: any): void;
  46329. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  46330. /**
  46331. * Dispose the render targets and their associated resources
  46332. */
  46333. dispose(): void;
  46334. /**
  46335. * Release all the underlying texture used as draw buffers.
  46336. */
  46337. releaseInternalTextures(): void;
  46338. }
  46339. }
  46340. declare module BABYLON {
  46341. /**
  46342. * Raw cube texture where the raw buffers are passed in
  46343. */
  46344. class RawCubeTexture extends CubeTexture {
  46345. /**
  46346. * Creates a cube texture where the raw buffers are passed in.
  46347. * @param scene defines the scene the texture is attached to
  46348. * @param data defines the array of data to use to create each face
  46349. * @param size defines the size of the textures
  46350. * @param format defines the format of the data
  46351. * @param type defines the type of the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  46352. * @param generateMipMaps defines if the engine should generate the mip levels
  46353. * @param invertY defines if data must be stored with Y axis inverted
  46354. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  46355. * @param compression defines the compression used (null by default)
  46356. */
  46357. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  46358. /**
  46359. * Updates the raw cube texture.
  46360. * @param data defines the data to store
  46361. * @param format defines the data format
  46362. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  46363. * @param invertY defines if data must be stored with Y axis inverted
  46364. * @param compression defines the compression used (null by default)
  46365. * @param level defines which level of the texture to update
  46366. */
  46367. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  46368. /**
  46369. * Updates a raw cube texture with RGBD encoded data.
  46370. * @param data defines the array of data [mipmap][face] to use to create each face
  46371. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  46372. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  46373. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  46374. * @returns a promsie that resolves when the operation is complete
  46375. */
  46376. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  46377. /**
  46378. * Clones the raw cube texture.
  46379. * @return a new cube texture
  46380. */
  46381. clone(): CubeTexture;
  46382. /** @hidden */
  46383. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  46384. }
  46385. }
  46386. declare module BABYLON {
  46387. /**
  46388. * Raw texture can help creating a texture directly from an array of data.
  46389. * This can be super useful if you either get the data from an uncompressed source or
  46390. * if you wish to create your texture pixel by pixel.
  46391. */
  46392. class RawTexture extends Texture {
  46393. /**
  46394. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  46395. */
  46396. format: number;
  46397. private _engine;
  46398. /**
  46399. * Instantiates a new RawTexture.
  46400. * Raw texture can help creating a texture directly from an array of data.
  46401. * This can be super useful if you either get the data from an uncompressed source or
  46402. * if you wish to create your texture pixel by pixel.
  46403. * @param data define the array of data to use to create the texture
  46404. * @param width define the width of the texture
  46405. * @param height define the height of the texture
  46406. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  46407. * @param scene define the scene the texture belongs to
  46408. * @param generateMipMaps define whether mip maps should be generated or not
  46409. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  46410. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  46411. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  46412. */
  46413. constructor(data: ArrayBufferView, width: number, height: number,
  46414. /**
  46415. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  46416. */
  46417. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  46418. /**
  46419. * Updates the texture underlying data.
  46420. * @param data Define the new data of the texture
  46421. */
  46422. update(data: ArrayBufferView): void;
  46423. /**
  46424. * Creates a luminance texture from some data.
  46425. * @param data Define the texture data
  46426. * @param width Define the width of the texture
  46427. * @param height Define the height of the texture
  46428. * @param scene Define the scene the texture belongs to
  46429. * @param generateMipMaps Define whether or not to create mip maps for the texture
  46430. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  46431. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  46432. * @returns the luminance texture
  46433. */
  46434. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  46435. /**
  46436. * Creates a luminance alpha texture from some data.
  46437. * @param data Define the texture data
  46438. * @param width Define the width of the texture
  46439. * @param height Define the height of the texture
  46440. * @param scene Define the scene the texture belongs to
  46441. * @param generateMipMaps Define whether or not to create mip maps for the texture
  46442. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  46443. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  46444. * @returns the luminance alpha texture
  46445. */
  46446. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  46447. /**
  46448. * Creates an alpha texture from some data.
  46449. * @param data Define the texture data
  46450. * @param width Define the width of the texture
  46451. * @param height Define the height of the texture
  46452. * @param scene Define the scene the texture belongs to
  46453. * @param generateMipMaps Define whether or not to create mip maps for the texture
  46454. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  46455. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  46456. * @returns the alpha texture
  46457. */
  46458. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  46459. /**
  46460. * Creates a RGB texture from some data.
  46461. * @param data Define the texture data
  46462. * @param width Define the width of the texture
  46463. * @param height Define the height of the texture
  46464. * @param scene Define the scene the texture belongs to
  46465. * @param generateMipMaps Define whether or not to create mip maps for the texture
  46466. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  46467. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  46468. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  46469. * @returns the RGB alpha texture
  46470. */
  46471. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  46472. /**
  46473. * Creates a RGBA texture from some data.
  46474. * @param data Define the texture data
  46475. * @param width Define the width of the texture
  46476. * @param height Define the height of the texture
  46477. * @param scene Define the scene the texture belongs to
  46478. * @param generateMipMaps Define whether or not to create mip maps for the texture
  46479. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  46480. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  46481. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  46482. * @returns the RGBA texture
  46483. */
  46484. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  46485. /**
  46486. * Creates a R texture from some data.
  46487. * @param data Define the texture data
  46488. * @param width Define the width of the texture
  46489. * @param height Define the height of the texture
  46490. * @param scene Define the scene the texture belongs to
  46491. * @param generateMipMaps Define whether or not to create mip maps for the texture
  46492. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  46493. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  46494. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  46495. * @returns the R texture
  46496. */
  46497. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  46498. }
  46499. }
  46500. declare module BABYLON {
  46501. /**
  46502. * Class used to store 3D textures containing user data
  46503. */
  46504. class RawTexture3D extends Texture {
  46505. /** Gets or sets the texture format to use */
  46506. format: number;
  46507. private _engine;
  46508. /**
  46509. * Create a new RawTexture3D
  46510. * @param data defines the data of the texture
  46511. * @param width defines the width of the texture
  46512. * @param height defines the height of the texture
  46513. * @param depth defines the depth of the texture
  46514. * @param format defines the texture format to use
  46515. * @param scene defines the hosting scene
  46516. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  46517. * @param invertY defines if texture must be stored with Y axis inverted
  46518. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  46519. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  46520. */
  46521. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  46522. /** Gets or sets the texture format to use */
  46523. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  46524. /**
  46525. * Update the texture with new data
  46526. * @param data defines the data to store in the texture
  46527. */
  46528. update(data: ArrayBufferView): void;
  46529. }
  46530. }
  46531. declare module BABYLON {
  46532. /**
  46533. * Creates a refraction texture used by refraction channel of the standard material.
  46534. * It is like a mirror but to see through a material.
  46535. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  46536. */
  46537. class RefractionTexture extends RenderTargetTexture {
  46538. /**
  46539. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  46540. * 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.
  46541. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  46542. */
  46543. refractionPlane: Plane;
  46544. /**
  46545. * Define how deep under the surface we should see.
  46546. */
  46547. depth: number;
  46548. /**
  46549. * Creates a refraction texture used by refraction channel of the standard material.
  46550. * It is like a mirror but to see through a material.
  46551. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  46552. * @param name Define the texture name
  46553. * @param size Define the size of the underlying texture
  46554. * @param scene Define the scene the refraction belongs to
  46555. * @param generateMipMaps Define if we need to generate mips level for the refraction
  46556. */
  46557. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  46558. /**
  46559. * Clone the refraction texture.
  46560. * @returns the cloned texture
  46561. */
  46562. clone(): RefractionTexture;
  46563. /**
  46564. * Serialize the texture to a JSON representation you could use in Parse later on
  46565. * @returns the serialized JSON representation
  46566. */
  46567. serialize(): any;
  46568. }
  46569. }
  46570. declare module BABYLON {
  46571. /**
  46572. * This Helps creating a texture that will be created from a camera in your scene.
  46573. * It is basically a dynamic texture that could be used to create special effects for instance.
  46574. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  46575. */
  46576. class RenderTargetTexture extends Texture {
  46577. isCube: boolean;
  46578. /**
  46579. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  46580. */
  46581. static readonly REFRESHRATE_RENDER_ONCE: number;
  46582. /**
  46583. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  46584. */
  46585. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  46586. /**
  46587. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  46588. * the central point of your effect and can save a lot of performances.
  46589. */
  46590. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  46591. /**
  46592. * Use this predicate to dynamically define the list of mesh you want to render.
  46593. * If set, the renderList property will be overwritten.
  46594. */
  46595. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  46596. private _renderList;
  46597. /**
  46598. * Use this list to define the list of mesh you want to render.
  46599. */
  46600. renderList: Nullable<Array<AbstractMesh>>;
  46601. private _hookArray;
  46602. /**
  46603. * Define if particles should be rendered in your texture.
  46604. */
  46605. renderParticles: boolean;
  46606. /**
  46607. * Define if sprites should be rendered in your texture.
  46608. */
  46609. renderSprites: boolean;
  46610. /**
  46611. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  46612. */
  46613. coordinatesMode: number;
  46614. /**
  46615. * Define the camera used to render the texture.
  46616. */
  46617. activeCamera: Nullable<Camera>;
  46618. /**
  46619. * Override the render function of the texture with your own one.
  46620. */
  46621. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  46622. /**
  46623. * Define if camera post processes should be use while rendering the texture.
  46624. */
  46625. useCameraPostProcesses: boolean;
  46626. /**
  46627. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  46628. */
  46629. ignoreCameraViewport: boolean;
  46630. private _postProcessManager;
  46631. private _postProcesses;
  46632. private _resizeObserver;
  46633. /**
  46634. * An event triggered when the texture is unbind.
  46635. */
  46636. onBeforeBindObservable: Observable<RenderTargetTexture>;
  46637. /**
  46638. * An event triggered when the texture is unbind.
  46639. */
  46640. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  46641. private _onAfterUnbindObserver;
  46642. /**
  46643. * Set a after unbind callback in the texture.
  46644. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  46645. */
  46646. onAfterUnbind: () => void;
  46647. /**
  46648. * An event triggered before rendering the texture
  46649. */
  46650. onBeforeRenderObservable: Observable<number>;
  46651. private _onBeforeRenderObserver;
  46652. /**
  46653. * Set a before render callback in the texture.
  46654. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  46655. */
  46656. onBeforeRender: (faceIndex: number) => void;
  46657. /**
  46658. * An event triggered after rendering the texture
  46659. */
  46660. onAfterRenderObservable: Observable<number>;
  46661. private _onAfterRenderObserver;
  46662. /**
  46663. * Set a after render callback in the texture.
  46664. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  46665. */
  46666. onAfterRender: (faceIndex: number) => void;
  46667. /**
  46668. * An event triggered after the texture clear
  46669. */
  46670. onClearObservable: Observable<Engine>;
  46671. private _onClearObserver;
  46672. /**
  46673. * Set a clear callback in the texture.
  46674. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  46675. */
  46676. onClear: (Engine: Engine) => void;
  46677. /**
  46678. * Define the clear color of the Render Target if it should be different from the scene.
  46679. */
  46680. clearColor: Color4;
  46681. protected _size: number | {
  46682. width: number;
  46683. height: number;
  46684. };
  46685. protected _initialSizeParameter: number | {
  46686. width: number;
  46687. height: number;
  46688. } | {
  46689. ratio: number;
  46690. };
  46691. protected _sizeRatio: Nullable<number>;
  46692. /** @hidden */
  46693. _generateMipMaps: boolean;
  46694. protected _renderingManager: RenderingManager;
  46695. /** @hidden */
  46696. _waitingRenderList: string[];
  46697. protected _doNotChangeAspectRatio: boolean;
  46698. protected _currentRefreshId: number;
  46699. protected _refreshRate: number;
  46700. protected _textureMatrix: Matrix;
  46701. protected _samples: number;
  46702. protected _renderTargetOptions: RenderTargetCreationOptions;
  46703. /**
  46704. * Gets render target creation options that were used.
  46705. */
  46706. readonly renderTargetOptions: RenderTargetCreationOptions;
  46707. protected _engine: Engine;
  46708. protected _onRatioRescale(): void;
  46709. /**
  46710. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  46711. * It must define where the camera used to render the texture is set
  46712. */
  46713. boundingBoxPosition: Vector3;
  46714. private _boundingBoxSize;
  46715. /**
  46716. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  46717. * When defined, the cubemap will switch to local mode
  46718. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  46719. * @example https://www.babylonjs-playground.com/#RNASML
  46720. */
  46721. boundingBoxSize: Vector3;
  46722. /**
  46723. * In case the RTT has been created with a depth texture, get the associated
  46724. * depth texture.
  46725. * Otherwise, return null.
  46726. */
  46727. depthStencilTexture: Nullable<InternalTexture>;
  46728. /**
  46729. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  46730. * or used a shadow, depth texture...
  46731. * @param name The friendly name of the texture
  46732. * @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)
  46733. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  46734. * @param generateMipMaps True if mip maps need to be generated after render.
  46735. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  46736. * @param type The type of the buffer in the RTT (int, half float, float...)
  46737. * @param isCube True if a cube texture needs to be created
  46738. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  46739. * @param generateDepthBuffer True to generate a depth buffer
  46740. * @param generateStencilBuffer True to generate a stencil buffer
  46741. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  46742. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  46743. */
  46744. constructor(name: string, size: number | {
  46745. width: number;
  46746. height: number;
  46747. } | {
  46748. ratio: number;
  46749. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number);
  46750. /**
  46751. * Creates a depth stencil texture.
  46752. * This is only available in WebGL 2 or with the depth texture extension available.
  46753. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  46754. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  46755. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  46756. */
  46757. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  46758. private _processSizeParameter;
  46759. /**
  46760. * Define the number of samples to use in case of MSAA.
  46761. * It defaults to one meaning no MSAA has been enabled.
  46762. */
  46763. samples: number;
  46764. /**
  46765. * Resets the refresh counter of the texture and start bak from scratch.
  46766. * Could be usefull to regenerate the texture if it is setup to render only once.
  46767. */
  46768. resetRefreshCounter(): void;
  46769. /**
  46770. * Define the refresh rate of the texture or the rendering frequency.
  46771. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  46772. */
  46773. refreshRate: number;
  46774. /**
  46775. * Adds a post process to the render target rendering passes.
  46776. * @param postProcess define the post process to add
  46777. */
  46778. addPostProcess(postProcess: PostProcess): void;
  46779. /**
  46780. * Clear all the post processes attached to the render target
  46781. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  46782. */
  46783. clearPostProcesses(dispose?: boolean): void;
  46784. /**
  46785. * Remove one of the post process from the list of attached post processes to the texture
  46786. * @param postProcess define the post process to remove from the list
  46787. */
  46788. removePostProcess(postProcess: PostProcess): void;
  46789. /** @hidden */
  46790. _shouldRender(): boolean;
  46791. /**
  46792. * Gets the actual render size of the texture.
  46793. * @returns the width of the render size
  46794. */
  46795. getRenderSize(): number;
  46796. /**
  46797. * Gets the actual render width of the texture.
  46798. * @returns the width of the render size
  46799. */
  46800. getRenderWidth(): number;
  46801. /**
  46802. * Gets the actual render height of the texture.
  46803. * @returns the height of the render size
  46804. */
  46805. getRenderHeight(): number;
  46806. /**
  46807. * Get if the texture can be rescaled or not.
  46808. */
  46809. readonly canRescale: boolean;
  46810. /**
  46811. * Resize the texture using a ratio.
  46812. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  46813. */
  46814. scale(ratio: number): void;
  46815. /**
  46816. * Get the texture reflection matrix used to rotate/transform the reflection.
  46817. * @returns the reflection matrix
  46818. */
  46819. getReflectionTextureMatrix(): Matrix;
  46820. /**
  46821. * Resize the texture to a new desired size.
  46822. * Be carrefull as it will recreate all the data in the new texture.
  46823. * @param size Define the new size. It can be:
  46824. * - a number for squared texture,
  46825. * - an object containing { width: number, height: number }
  46826. * - or an object containing a ratio { ratio: number }
  46827. */
  46828. resize(size: number | {
  46829. width: number;
  46830. height: number;
  46831. } | {
  46832. ratio: number;
  46833. }): void;
  46834. /**
  46835. * Renders all the objects from the render list into the texture.
  46836. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  46837. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  46838. */
  46839. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  46840. private _bestReflectionRenderTargetDimension;
  46841. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  46842. private renderToTarget;
  46843. /**
  46844. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  46845. * This allowed control for front to back rendering or reversly depending of the special needs.
  46846. *
  46847. * @param renderingGroupId The rendering group id corresponding to its index
  46848. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  46849. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  46850. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  46851. */
  46852. 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;
  46853. /**
  46854. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  46855. *
  46856. * @param renderingGroupId The rendering group id corresponding to its index
  46857. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  46858. */
  46859. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  46860. /**
  46861. * Clones the texture.
  46862. * @returns the cloned texture
  46863. */
  46864. clone(): RenderTargetTexture;
  46865. /**
  46866. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  46867. * @returns The JSON representation of the texture
  46868. */
  46869. serialize(): any;
  46870. /**
  46871. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  46872. */
  46873. disposeFramebufferObjects(): void;
  46874. /**
  46875. * Dispose the texture and release its associated resources.
  46876. */
  46877. dispose(): void;
  46878. /** @hidden */
  46879. _rebuild(): void;
  46880. /**
  46881. * Clear the info related to rendering groups preventing retention point in material dispose.
  46882. */
  46883. freeRenderingGroups(): void;
  46884. }
  46885. }
  46886. declare module BABYLON {
  46887. /**
  46888. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  46889. * @see http://doc.babylonjs.com/babylon101/materials#texture
  46890. */
  46891. class Texture extends BaseTexture {
  46892. /** nearest is mag = nearest and min = nearest and mip = linear */
  46893. static readonly NEAREST_SAMPLINGMODE: number;
  46894. /** nearest is mag = nearest and min = nearest and mip = linear */
  46895. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  46896. /** Bilinear is mag = linear and min = linear and mip = nearest */
  46897. static readonly BILINEAR_SAMPLINGMODE: number;
  46898. /** Bilinear is mag = linear and min = linear and mip = nearest */
  46899. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  46900. /** Trilinear is mag = linear and min = linear and mip = linear */
  46901. static readonly TRILINEAR_SAMPLINGMODE: number;
  46902. /** Trilinear is mag = linear and min = linear and mip = linear */
  46903. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  46904. /** mag = nearest and min = nearest and mip = nearest */
  46905. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  46906. /** mag = nearest and min = linear and mip = nearest */
  46907. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  46908. /** mag = nearest and min = linear and mip = linear */
  46909. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  46910. /** mag = nearest and min = linear and mip = none */
  46911. static readonly NEAREST_LINEAR: number;
  46912. /** mag = nearest and min = nearest and mip = none */
  46913. static readonly NEAREST_NEAREST: number;
  46914. /** mag = linear and min = nearest and mip = nearest */
  46915. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  46916. /** mag = linear and min = nearest and mip = linear */
  46917. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  46918. /** mag = linear and min = linear and mip = none */
  46919. static readonly LINEAR_LINEAR: number;
  46920. /** mag = linear and min = nearest and mip = none */
  46921. static readonly LINEAR_NEAREST: number;
  46922. /** Explicit coordinates mode */
  46923. static readonly EXPLICIT_MODE: number;
  46924. /** Spherical coordinates mode */
  46925. static readonly SPHERICAL_MODE: number;
  46926. /** Planar coordinates mode */
  46927. static readonly PLANAR_MODE: number;
  46928. /** Cubic coordinates mode */
  46929. static readonly CUBIC_MODE: number;
  46930. /** Projection coordinates mode */
  46931. static readonly PROJECTION_MODE: number;
  46932. /** Inverse Cubic coordinates mode */
  46933. static readonly SKYBOX_MODE: number;
  46934. /** Inverse Cubic coordinates mode */
  46935. static readonly INVCUBIC_MODE: number;
  46936. /** Equirectangular coordinates mode */
  46937. static readonly EQUIRECTANGULAR_MODE: number;
  46938. /** Equirectangular Fixed coordinates mode */
  46939. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  46940. /** Equirectangular Fixed Mirrored coordinates mode */
  46941. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  46942. /** Texture is not repeating outside of 0..1 UVs */
  46943. static readonly CLAMP_ADDRESSMODE: number;
  46944. /** Texture is repeating outside of 0..1 UVs */
  46945. static readonly WRAP_ADDRESSMODE: number;
  46946. /** Texture is repeating and mirrored */
  46947. static readonly MIRROR_ADDRESSMODE: number;
  46948. /**
  46949. * 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
  46950. */
  46951. static UseSerializedUrlIfAny: boolean;
  46952. /**
  46953. * Define the url of the texture.
  46954. */
  46955. url: Nullable<string>;
  46956. /**
  46957. * Define an offset on the texture to offset the u coordinates of the UVs
  46958. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  46959. */
  46960. uOffset: number;
  46961. /**
  46962. * Define an offset on the texture to offset the v coordinates of the UVs
  46963. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  46964. */
  46965. vOffset: number;
  46966. /**
  46967. * Define an offset on the texture to scale the u coordinates of the UVs
  46968. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  46969. */
  46970. uScale: number;
  46971. /**
  46972. * Define an offset on the texture to scale the v coordinates of the UVs
  46973. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  46974. */
  46975. vScale: number;
  46976. /**
  46977. * Define an offset on the texture to rotate around the u coordinates of the UVs
  46978. * @see http://doc.babylonjs.com/how_to/more_materials
  46979. */
  46980. uAng: number;
  46981. /**
  46982. * Define an offset on the texture to rotate around the v coordinates of the UVs
  46983. * @see http://doc.babylonjs.com/how_to/more_materials
  46984. */
  46985. vAng: number;
  46986. /**
  46987. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  46988. * @see http://doc.babylonjs.com/how_to/more_materials
  46989. */
  46990. wAng: number;
  46991. /**
  46992. * Defines the center of rotation (U)
  46993. */
  46994. uRotationCenter: number;
  46995. /**
  46996. * Defines the center of rotation (V)
  46997. */
  46998. vRotationCenter: number;
  46999. /**
  47000. * Defines the center of rotation (W)
  47001. */
  47002. wRotationCenter: number;
  47003. /**
  47004. * Are mip maps generated for this texture or not.
  47005. */
  47006. readonly noMipmap: boolean;
  47007. private _noMipmap;
  47008. /** @hidden */
  47009. _invertY: boolean;
  47010. private _rowGenerationMatrix;
  47011. private _cachedTextureMatrix;
  47012. private _projectionModeMatrix;
  47013. private _t0;
  47014. private _t1;
  47015. private _t2;
  47016. private _cachedUOffset;
  47017. private _cachedVOffset;
  47018. private _cachedUScale;
  47019. private _cachedVScale;
  47020. private _cachedUAng;
  47021. private _cachedVAng;
  47022. private _cachedWAng;
  47023. private _cachedProjectionMatrixId;
  47024. private _cachedCoordinatesMode;
  47025. /** @hidden */
  47026. _samplingMode: number;
  47027. /** @hidden */
  47028. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  47029. private _deleteBuffer;
  47030. protected _format: Nullable<number>;
  47031. private _delayedOnLoad;
  47032. private _delayedOnError;
  47033. /**
  47034. * Observable triggered once the texture has been loaded.
  47035. */
  47036. onLoadObservable: Observable<Texture>;
  47037. protected _isBlocking: boolean;
  47038. /**
  47039. * Is the texture preventing material to render while loading.
  47040. * If false, a default texture will be used instead of the loading one during the preparation step.
  47041. */
  47042. isBlocking: boolean;
  47043. /**
  47044. * Get the current sampling mode associated with the texture.
  47045. */
  47046. readonly samplingMode: number;
  47047. /**
  47048. * Instantiates a new texture.
  47049. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  47050. * @see http://doc.babylonjs.com/babylon101/materials#texture
  47051. * @param url define the url of the picture to load as a texture
  47052. * @param scene define the scene the texture will belong to
  47053. * @param noMipmap define if the texture will require mip maps or not
  47054. * @param invertY define if the texture needs to be inverted on the y axis during loading
  47055. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  47056. * @param onLoad define a callback triggered when the texture has been loaded
  47057. * @param onError define a callback triggered when an error occurred during the loading session
  47058. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  47059. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  47060. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  47061. */
  47062. 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);
  47063. /**
  47064. * Update the url (and optional buffer) of this texture if url was null during construction.
  47065. * @param url the url of the texture
  47066. * @param buffer the buffer of the texture (defaults to null)
  47067. */
  47068. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>): void;
  47069. /**
  47070. * Finish the loading sequence of a texture flagged as delayed load.
  47071. * @hidden
  47072. */
  47073. delayLoad(): void;
  47074. /**
  47075. * Update the sampling mode of the texture.
  47076. * Default is Trilinear mode.
  47077. *
  47078. * | Value | Type | Description |
  47079. * | ----- | ------------------ | ----------- |
  47080. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  47081. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  47082. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  47083. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  47084. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  47085. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  47086. * | 7 | NEAREST_LINEAR | |
  47087. * | 8 | NEAREST_NEAREST | |
  47088. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  47089. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  47090. * | 11 | LINEAR_LINEAR | |
  47091. * | 12 | LINEAR_NEAREST | |
  47092. *
  47093. * > _mag_: magnification filter (close to the viewer)
  47094. * > _min_: minification filter (far from the viewer)
  47095. * > _mip_: filter used between mip map levels
  47096. *@param samplingMode Define the new sampling mode of the texture
  47097. */
  47098. updateSamplingMode(samplingMode: number): void;
  47099. private _prepareRowForTextureGeneration;
  47100. /**
  47101. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  47102. * @returns the transform matrix of the texture.
  47103. */
  47104. getTextureMatrix(): Matrix;
  47105. /**
  47106. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  47107. * @returns The reflection texture transform
  47108. */
  47109. getReflectionTextureMatrix(): Matrix;
  47110. /**
  47111. * Clones the texture.
  47112. * @returns the cloned texture
  47113. */
  47114. clone(): Texture;
  47115. /**
  47116. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  47117. * @returns The JSON representation of the texture
  47118. */
  47119. serialize(): any;
  47120. /**
  47121. * Get the current class name of the texture usefull for serialization or dynamic coding.
  47122. * @returns "Texture"
  47123. */
  47124. getClassName(): string;
  47125. /**
  47126. * Dispose the texture and release its associated resources.
  47127. */
  47128. dispose(): void;
  47129. /**
  47130. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  47131. * @param parsedTexture Define the JSON representation of the texture
  47132. * @param scene Define the scene the parsed texture should be instantiated in
  47133. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  47134. * @returns The parsed texture if successful
  47135. */
  47136. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  47137. /**
  47138. * Creates a texture from its base 64 representation.
  47139. * @param data Define the base64 payload without the data: prefix
  47140. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  47141. * @param scene Define the scene the texture should belong to
  47142. * @param noMipmap Forces the texture to not create mip map information if true
  47143. * @param invertY define if the texture needs to be inverted on the y axis during loading
  47144. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  47145. * @param onLoad define a callback triggered when the texture has been loaded
  47146. * @param onError define a callback triggered when an error occurred during the loading session
  47147. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  47148. * @returns the created texture
  47149. */
  47150. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  47151. /**
  47152. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  47153. * @param data Define the base64 payload without the data: prefix
  47154. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  47155. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  47156. * @param scene Define the scene the texture should belong to
  47157. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  47158. * @param noMipmap Forces the texture to not create mip map information if true
  47159. * @param invertY define if the texture needs to be inverted on the y axis during loading
  47160. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  47161. * @param onLoad define a callback triggered when the texture has been loaded
  47162. * @param onError define a callback triggered when an error occurred during the loading session
  47163. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  47164. * @returns the created texture
  47165. */
  47166. 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;
  47167. }
  47168. }
  47169. declare module BABYLON {
  47170. /**
  47171. * Settings for finer control over video usage
  47172. */
  47173. interface VideoTextureSettings {
  47174. /**
  47175. * Applies `autoplay` to video, if specified
  47176. */
  47177. autoPlay?: boolean;
  47178. /**
  47179. * Applies `loop` to video, if specified
  47180. */
  47181. loop?: boolean;
  47182. /**
  47183. * Automatically updates internal texture from video at every frame in the render loop
  47184. */
  47185. autoUpdateTexture: boolean;
  47186. /**
  47187. * Image src displayed during the video loading or until the user interacts with the video.
  47188. */
  47189. poster?: string;
  47190. }
  47191. /**
  47192. * If you want to display a video in your scene, this is the special texture for that.
  47193. * This special texture works similar to other textures, with the exception of a few parameters.
  47194. * @see https://doc.babylonjs.com/how_to/video_texture
  47195. */
  47196. class VideoTexture extends Texture {
  47197. /**
  47198. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  47199. */
  47200. readonly autoUpdateTexture: boolean;
  47201. /**
  47202. * The video instance used by the texture internally
  47203. */
  47204. readonly video: HTMLVideoElement;
  47205. private _onUserActionRequestedObservable;
  47206. /**
  47207. * Event triggerd when a dom action is required by the user to play the video.
  47208. * This happens due to recent changes in browser policies preventing video to auto start.
  47209. */
  47210. readonly onUserActionRequestedObservable: Observable<Texture>;
  47211. private _generateMipMaps;
  47212. private _engine;
  47213. private _stillImageCaptured;
  47214. private _poster;
  47215. /**
  47216. * Creates a video texture.
  47217. * If you want to display a video in your scene, this is the special texture for that.
  47218. * This special texture works similar to other textures, with the exception of a few parameters.
  47219. * @see https://doc.babylonjs.com/how_to/video_texture
  47220. * @param name optional name, will detect from video source, if not defined
  47221. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  47222. * @param scene is obviously the current scene.
  47223. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  47224. * @param invertY is false by default but can be used to invert video on Y axis
  47225. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  47226. * @param settings allows finer control over video usage
  47227. */
  47228. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  47229. private _getName;
  47230. private _getVideo;
  47231. private _createInternalTexture;
  47232. private reset;
  47233. /**
  47234. * @hidden Internal method to initiate `update`.
  47235. */
  47236. _rebuild(): void;
  47237. /**
  47238. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  47239. */
  47240. update(): void;
  47241. /**
  47242. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  47243. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  47244. */
  47245. updateTexture(isVisible: boolean): void;
  47246. protected _updateInternalTexture: (e?: Event | undefined) => void;
  47247. /**
  47248. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  47249. * @param url New url.
  47250. */
  47251. updateURL(url: string): void;
  47252. /**
  47253. * Dispose the texture and release its associated resources.
  47254. */
  47255. dispose(): void;
  47256. /**
  47257. * Creates a video texture straight from your WebCam video feed.
  47258. * @param scene Define the scene the texture should be created in
  47259. * @param onReady Define a callback to triggered once the texture will be ready
  47260. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  47261. */
  47262. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  47263. minWidth: number;
  47264. maxWidth: number;
  47265. minHeight: number;
  47266. maxHeight: number;
  47267. deviceId: string;
  47268. }): void;
  47269. }
  47270. }
  47271. declare var DracoDecoderModule: any;
  47272. declare var WebAssembly: any;
  47273. declare module BABYLON {
  47274. /**
  47275. * Configuration for Draco compression
  47276. */
  47277. interface IDracoCompressionConfiguration {
  47278. /**
  47279. * Configuration for the decoder.
  47280. */
  47281. decoder?: {
  47282. /**
  47283. * The url to the WebAssembly module.
  47284. */
  47285. wasmUrl?: string;
  47286. /**
  47287. * The url to the WebAssembly binary.
  47288. */
  47289. wasmBinaryUrl?: string;
  47290. /**
  47291. * The url to the fallback JavaScript module.
  47292. */
  47293. fallbackUrl?: string;
  47294. };
  47295. }
  47296. /**
  47297. * Draco compression (https://google.github.io/draco/)
  47298. *
  47299. * This class wraps the Draco module.
  47300. *
  47301. * **Encoder**
  47302. *
  47303. * The encoder is not currently implemented.
  47304. *
  47305. * **Decoder**
  47306. *
  47307. * 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.
  47308. *
  47309. * To update the configuration, use the following code:
  47310. * ```javascript
  47311. * BABYLON.DracoCompression.Configuration = {
  47312. * decoder: {
  47313. * wasmUrl: "<url to the WebAssembly library>",
  47314. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  47315. * fallbackUrl: "<url to the fallback JavaScript library>",
  47316. * }
  47317. * };
  47318. * ```
  47319. *
  47320. * 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.
  47321. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  47322. * Use `BABYLON.DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  47323. *
  47324. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  47325. * ```javascript
  47326. * var dracoCompression = new BABYLON.DracoCompression();
  47327. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  47328. * [BABYLON.VertexBuffer.PositionKind]: 0
  47329. * });
  47330. * ```
  47331. *
  47332. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  47333. */
  47334. class DracoCompression implements IDisposable {
  47335. private static _DecoderModulePromise;
  47336. /**
  47337. * The configuration. Defaults to the following urls:
  47338. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  47339. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  47340. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  47341. */
  47342. static Configuration: IDracoCompressionConfiguration;
  47343. /**
  47344. * Returns true if the decoder is available.
  47345. */
  47346. static readonly DecoderAvailable: boolean;
  47347. /**
  47348. * Constructor
  47349. */
  47350. constructor();
  47351. /**
  47352. * Stop all async operations and release resources.
  47353. */
  47354. dispose(): void;
  47355. /**
  47356. * Decode Draco compressed mesh data to vertex data.
  47357. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  47358. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  47359. * @returns A promise that resolves with the decoded vertex data
  47360. */
  47361. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  47362. [kind: string]: number;
  47363. }): Promise<VertexData>;
  47364. private static _GetDecoderModule;
  47365. private static _LoadScriptAsync;
  47366. private static _LoadFileAsync;
  47367. }
  47368. }
  47369. declare module BABYLON {
  47370. /** @hidden */
  47371. class CannonJSPlugin implements IPhysicsEnginePlugin {
  47372. private _useDeltaForWorldStep;
  47373. world: any;
  47374. name: string;
  47375. private _physicsMaterials;
  47376. private _fixedTimeStep;
  47377. BJSCANNON: any;
  47378. constructor(_useDeltaForWorldStep?: boolean, iterations?: number);
  47379. setGravity(gravity: Vector3): void;
  47380. setTimeStep(timeStep: number): void;
  47381. getTimeStep(): number;
  47382. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  47383. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47384. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47385. generatePhysicsBody(impostor: PhysicsImpostor): void;
  47386. private _processChildMeshes;
  47387. removePhysicsBody(impostor: PhysicsImpostor): void;
  47388. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  47389. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  47390. private _addMaterial;
  47391. private _checkWithEpsilon;
  47392. private _createShape;
  47393. private _createHeightmap;
  47394. private _minus90X;
  47395. private _plus90X;
  47396. private _tmpPosition;
  47397. private _tmpDeltaPosition;
  47398. private _tmpUnityRotation;
  47399. private _updatePhysicsBodyTransformation;
  47400. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  47401. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  47402. isSupported(): boolean;
  47403. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47404. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47405. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47406. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47407. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  47408. getBodyMass(impostor: PhysicsImpostor): number;
  47409. getBodyFriction(impostor: PhysicsImpostor): number;
  47410. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  47411. getBodyRestitution(impostor: PhysicsImpostor): number;
  47412. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  47413. sleepBody(impostor: PhysicsImpostor): void;
  47414. wakeUpBody(impostor: PhysicsImpostor): void;
  47415. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  47416. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  47417. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  47418. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  47419. getRadius(impostor: PhysicsImpostor): number;
  47420. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  47421. dispose(): void;
  47422. private _extendNamespace;
  47423. }
  47424. }
  47425. declare module BABYLON {
  47426. /** @hidden */
  47427. class OimoJSPlugin implements IPhysicsEnginePlugin {
  47428. world: any;
  47429. name: string;
  47430. BJSOIMO: any;
  47431. constructor(iterations?: number);
  47432. setGravity(gravity: Vector3): void;
  47433. setTimeStep(timeStep: number): void;
  47434. getTimeStep(): number;
  47435. private _tmpImpostorsArray;
  47436. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  47437. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47438. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47439. generatePhysicsBody(impostor: PhysicsImpostor): void;
  47440. private _tmpPositionVector;
  47441. removePhysicsBody(impostor: PhysicsImpostor): void;
  47442. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  47443. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  47444. isSupported(): boolean;
  47445. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  47446. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  47447. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47448. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47449. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47450. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47451. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  47452. getBodyMass(impostor: PhysicsImpostor): number;
  47453. getBodyFriction(impostor: PhysicsImpostor): number;
  47454. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  47455. getBodyRestitution(impostor: PhysicsImpostor): number;
  47456. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  47457. sleepBody(impostor: PhysicsImpostor): void;
  47458. wakeUpBody(impostor: PhysicsImpostor): void;
  47459. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  47460. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  47461. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  47462. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  47463. getRadius(impostor: PhysicsImpostor): number;
  47464. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  47465. dispose(): void;
  47466. }
  47467. }
  47468. declare module BABYLON {
  47469. /**
  47470. * Particle emitter emitting particles from the inside of a box.
  47471. * It emits the particles randomly between 2 given directions.
  47472. */
  47473. class BoxParticleEmitter implements IParticleEmitterType {
  47474. /**
  47475. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  47476. */
  47477. direction1: Vector3;
  47478. /**
  47479. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  47480. */
  47481. direction2: Vector3;
  47482. /**
  47483. * 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.
  47484. */
  47485. minEmitBox: Vector3;
  47486. /**
  47487. * 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.
  47488. */
  47489. maxEmitBox: Vector3;
  47490. /**
  47491. * Creates a new instance BoxParticleEmitter
  47492. */
  47493. constructor();
  47494. /**
  47495. * Called by the particle System when the direction is computed for the created particle.
  47496. * @param worldMatrix is the world matrix of the particle system
  47497. * @param directionToUpdate is the direction vector to update with the result
  47498. * @param particle is the particle we are computed the direction for
  47499. */
  47500. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  47501. /**
  47502. * Called by the particle System when the position is computed for the created particle.
  47503. * @param worldMatrix is the world matrix of the particle system
  47504. * @param positionToUpdate is the position vector to update with the result
  47505. * @param particle is the particle we are computed the position for
  47506. */
  47507. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  47508. /**
  47509. * Clones the current emitter and returns a copy of it
  47510. * @returns the new emitter
  47511. */
  47512. clone(): BoxParticleEmitter;
  47513. /**
  47514. * Called by the GPUParticleSystem to setup the update shader
  47515. * @param effect defines the update shader
  47516. */
  47517. applyToShader(effect: Effect): void;
  47518. /**
  47519. * Returns a string to use to update the GPU particles update shader
  47520. * @returns a string containng the defines string
  47521. */
  47522. getEffectDefines(): string;
  47523. /**
  47524. * Returns the string "BoxParticleEmitter"
  47525. * @returns a string containing the class name
  47526. */
  47527. getClassName(): string;
  47528. /**
  47529. * Serializes the particle system to a JSON object.
  47530. * @returns the JSON object
  47531. */
  47532. serialize(): any;
  47533. /**
  47534. * Parse properties from a JSON object
  47535. * @param serializationObject defines the JSON object
  47536. */
  47537. parse(serializationObject: any): void;
  47538. }
  47539. }
  47540. declare module BABYLON {
  47541. /**
  47542. * Particle emitter emitting particles from the inside of a cone.
  47543. * It emits the particles alongside the cone volume from the base to the particle.
  47544. * The emission direction might be randomized.
  47545. */
  47546. class ConeParticleEmitter implements IParticleEmitterType {
  47547. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  47548. directionRandomizer: number;
  47549. private _radius;
  47550. private _angle;
  47551. private _height;
  47552. /**
  47553. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  47554. */
  47555. radiusRange: number;
  47556. /**
  47557. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  47558. */
  47559. heightRange: number;
  47560. /**
  47561. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  47562. */
  47563. emitFromSpawnPointOnly: boolean;
  47564. /**
  47565. * Gets or sets the radius of the emission cone
  47566. */
  47567. radius: number;
  47568. /**
  47569. * Gets or sets the angle of the emission cone
  47570. */
  47571. angle: number;
  47572. private _buildHeight;
  47573. /**
  47574. * Creates a new instance ConeParticleEmitter
  47575. * @param radius the radius of the emission cone (1 by default)
  47576. * @param angles the cone base angle (PI by default)
  47577. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  47578. */
  47579. constructor(radius?: number, angle?: number,
  47580. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  47581. directionRandomizer?: number);
  47582. /**
  47583. * Called by the particle System when the direction is computed for the created particle.
  47584. * @param worldMatrix is the world matrix of the particle system
  47585. * @param directionToUpdate is the direction vector to update with the result
  47586. * @param particle is the particle we are computed the direction for
  47587. */
  47588. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  47589. /**
  47590. * Called by the particle System when the position is computed for the created particle.
  47591. * @param worldMatrix is the world matrix of the particle system
  47592. * @param positionToUpdate is the position vector to update with the result
  47593. * @param particle is the particle we are computed the position for
  47594. */
  47595. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  47596. /**
  47597. * Clones the current emitter and returns a copy of it
  47598. * @returns the new emitter
  47599. */
  47600. clone(): ConeParticleEmitter;
  47601. /**
  47602. * Called by the GPUParticleSystem to setup the update shader
  47603. * @param effect defines the update shader
  47604. */
  47605. applyToShader(effect: Effect): void;
  47606. /**
  47607. * Returns a string to use to update the GPU particles update shader
  47608. * @returns a string containng the defines string
  47609. */
  47610. getEffectDefines(): string;
  47611. /**
  47612. * Returns the string "ConeParticleEmitter"
  47613. * @returns a string containing the class name
  47614. */
  47615. getClassName(): string;
  47616. /**
  47617. * Serializes the particle system to a JSON object.
  47618. * @returns the JSON object
  47619. */
  47620. serialize(): any;
  47621. /**
  47622. * Parse properties from a JSON object
  47623. * @param serializationObject defines the JSON object
  47624. */
  47625. parse(serializationObject: any): void;
  47626. }
  47627. }
  47628. declare module BABYLON {
  47629. /**
  47630. * Particle emitter emitting particles from the inside of a cylinder.
  47631. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  47632. */
  47633. class CylinderParticleEmitter implements IParticleEmitterType {
  47634. /**
  47635. * The radius of the emission cylinder.
  47636. */
  47637. radius: number;
  47638. /**
  47639. * The height of the emission cylinder.
  47640. */
  47641. height: number;
  47642. /**
  47643. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  47644. */
  47645. radiusRange: number;
  47646. /**
  47647. * How much to randomize the particle direction [0-1].
  47648. */
  47649. directionRandomizer: number;
  47650. /**
  47651. * Creates a new instance CylinderParticleEmitter
  47652. * @param radius the radius of the emission cylinder (1 by default)
  47653. * @param height the height of the emission cylinder (1 by default)
  47654. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  47655. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  47656. */
  47657. constructor(
  47658. /**
  47659. * The radius of the emission cylinder.
  47660. */
  47661. radius?: number,
  47662. /**
  47663. * The height of the emission cylinder.
  47664. */
  47665. height?: number,
  47666. /**
  47667. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  47668. */
  47669. radiusRange?: number,
  47670. /**
  47671. * How much to randomize the particle direction [0-1].
  47672. */
  47673. directionRandomizer?: number);
  47674. /**
  47675. * Called by the particle System when the direction is computed for the created particle.
  47676. * @param worldMatrix is the world matrix of the particle system
  47677. * @param directionToUpdate is the direction vector to update with the result
  47678. * @param particle is the particle we are computed the direction for
  47679. */
  47680. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  47681. /**
  47682. * Called by the particle System when the position is computed for the created particle.
  47683. * @param worldMatrix is the world matrix of the particle system
  47684. * @param positionToUpdate is the position vector to update with the result
  47685. * @param particle is the particle we are computed the position for
  47686. */
  47687. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  47688. /**
  47689. * Clones the current emitter and returns a copy of it
  47690. * @returns the new emitter
  47691. */
  47692. clone(): CylinderParticleEmitter;
  47693. /**
  47694. * Called by the GPUParticleSystem to setup the update shader
  47695. * @param effect defines the update shader
  47696. */
  47697. applyToShader(effect: Effect): void;
  47698. /**
  47699. * Returns a string to use to update the GPU particles update shader
  47700. * @returns a string containng the defines string
  47701. */
  47702. getEffectDefines(): string;
  47703. /**
  47704. * Returns the string "CylinderParticleEmitter"
  47705. * @returns a string containing the class name
  47706. */
  47707. getClassName(): string;
  47708. /**
  47709. * Serializes the particle system to a JSON object.
  47710. * @returns the JSON object
  47711. */
  47712. serialize(): any;
  47713. /**
  47714. * Parse properties from a JSON object
  47715. * @param serializationObject defines the JSON object
  47716. */
  47717. parse(serializationObject: any): void;
  47718. }
  47719. /**
  47720. * Particle emitter emitting particles from the inside of a cylinder.
  47721. * It emits the particles randomly between two vectors.
  47722. */
  47723. class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  47724. /**
  47725. * The min limit of the emission direction.
  47726. */
  47727. direction1: Vector3;
  47728. /**
  47729. * The max limit of the emission direction.
  47730. */
  47731. direction2: Vector3;
  47732. /**
  47733. * Creates a new instance CylinderDirectedParticleEmitter
  47734. * @param radius the radius of the emission cylinder (1 by default)
  47735. * @param height the height of the emission cylinder (1 by default)
  47736. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  47737. * @param direction1 the min limit of the emission direction (up vector by default)
  47738. * @param direction2 the max limit of the emission direction (up vector by default)
  47739. */
  47740. constructor(radius?: number, height?: number, radiusRange?: number,
  47741. /**
  47742. * The min limit of the emission direction.
  47743. */
  47744. direction1?: Vector3,
  47745. /**
  47746. * The max limit of the emission direction.
  47747. */
  47748. direction2?: Vector3);
  47749. /**
  47750. * Called by the particle System when the direction is computed for the created particle.
  47751. * @param worldMatrix is the world matrix of the particle system
  47752. * @param directionToUpdate is the direction vector to update with the result
  47753. * @param particle is the particle we are computed the direction for
  47754. */
  47755. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  47756. /**
  47757. * Clones the current emitter and returns a copy of it
  47758. * @returns the new emitter
  47759. */
  47760. clone(): CylinderDirectedParticleEmitter;
  47761. /**
  47762. * Called by the GPUParticleSystem to setup the update shader
  47763. * @param effect defines the update shader
  47764. */
  47765. applyToShader(effect: Effect): void;
  47766. /**
  47767. * Returns a string to use to update the GPU particles update shader
  47768. * @returns a string containng the defines string
  47769. */
  47770. getEffectDefines(): string;
  47771. /**
  47772. * Returns the string "CylinderDirectedParticleEmitter"
  47773. * @returns a string containing the class name
  47774. */
  47775. getClassName(): string;
  47776. /**
  47777. * Serializes the particle system to a JSON object.
  47778. * @returns the JSON object
  47779. */
  47780. serialize(): any;
  47781. /**
  47782. * Parse properties from a JSON object
  47783. * @param serializationObject defines the JSON object
  47784. */
  47785. parse(serializationObject: any): void;
  47786. }
  47787. }
  47788. declare module BABYLON {
  47789. /**
  47790. * Particle emitter emitting particles from the inside of a hemisphere.
  47791. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  47792. */
  47793. class HemisphericParticleEmitter implements IParticleEmitterType {
  47794. /**
  47795. * The radius of the emission hemisphere.
  47796. */
  47797. radius: number;
  47798. /**
  47799. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  47800. */
  47801. radiusRange: number;
  47802. /**
  47803. * How much to randomize the particle direction [0-1].
  47804. */
  47805. directionRandomizer: number;
  47806. /**
  47807. * Creates a new instance HemisphericParticleEmitter
  47808. * @param radius the radius of the emission hemisphere (1 by default)
  47809. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  47810. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  47811. */
  47812. constructor(
  47813. /**
  47814. * The radius of the emission hemisphere.
  47815. */
  47816. radius?: number,
  47817. /**
  47818. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  47819. */
  47820. radiusRange?: number,
  47821. /**
  47822. * How much to randomize the particle direction [0-1].
  47823. */
  47824. directionRandomizer?: number);
  47825. /**
  47826. * Called by the particle System when the direction is computed for the created particle.
  47827. * @param worldMatrix is the world matrix of the particle system
  47828. * @param directionToUpdate is the direction vector to update with the result
  47829. * @param particle is the particle we are computed the direction for
  47830. */
  47831. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  47832. /**
  47833. * Called by the particle System when the position is computed for the created particle.
  47834. * @param worldMatrix is the world matrix of the particle system
  47835. * @param positionToUpdate is the position vector to update with the result
  47836. * @param particle is the particle we are computed the position for
  47837. */
  47838. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  47839. /**
  47840. * Clones the current emitter and returns a copy of it
  47841. * @returns the new emitter
  47842. */
  47843. clone(): HemisphericParticleEmitter;
  47844. /**
  47845. * Called by the GPUParticleSystem to setup the update shader
  47846. * @param effect defines the update shader
  47847. */
  47848. applyToShader(effect: Effect): void;
  47849. /**
  47850. * Returns a string to use to update the GPU particles update shader
  47851. * @returns a string containng the defines string
  47852. */
  47853. getEffectDefines(): string;
  47854. /**
  47855. * Returns the string "HemisphericParticleEmitter"
  47856. * @returns a string containing the class name
  47857. */
  47858. getClassName(): string;
  47859. /**
  47860. * Serializes the particle system to a JSON object.
  47861. * @returns the JSON object
  47862. */
  47863. serialize(): any;
  47864. /**
  47865. * Parse properties from a JSON object
  47866. * @param serializationObject defines the JSON object
  47867. */
  47868. parse(serializationObject: any): void;
  47869. }
  47870. }
  47871. declare module BABYLON {
  47872. /**
  47873. * Particle emitter represents a volume emitting particles.
  47874. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  47875. */
  47876. interface IParticleEmitterType {
  47877. /**
  47878. * Called by the particle System when the direction is computed for the created particle.
  47879. * @param worldMatrix is the world matrix of the particle system
  47880. * @param directionToUpdate is the direction vector to update with the result
  47881. * @param particle is the particle we are computed the direction for
  47882. */
  47883. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  47884. /**
  47885. * Called by the particle System when the position is computed for the created particle.
  47886. * @param worldMatrix is the world matrix of the particle system
  47887. * @param positionToUpdate is the position vector to update with the result
  47888. * @param particle is the particle we are computed the position for
  47889. */
  47890. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  47891. /**
  47892. * Clones the current emitter and returns a copy of it
  47893. * @returns the new emitter
  47894. */
  47895. clone(): IParticleEmitterType;
  47896. /**
  47897. * Called by the GPUParticleSystem to setup the update shader
  47898. * @param effect defines the update shader
  47899. */
  47900. applyToShader(effect: Effect): void;
  47901. /**
  47902. * Returns a string to use to update the GPU particles update shader
  47903. * @returns the effect defines string
  47904. */
  47905. getEffectDefines(): string;
  47906. /**
  47907. * Returns a string representing the class name
  47908. * @returns a string containing the class name
  47909. */
  47910. getClassName(): string;
  47911. /**
  47912. * Serializes the particle system to a JSON object.
  47913. * @returns the JSON object
  47914. */
  47915. serialize(): any;
  47916. /**
  47917. * Parse properties from a JSON object
  47918. * @param serializationObject defines the JSON object
  47919. */
  47920. parse(serializationObject: any): void;
  47921. }
  47922. }
  47923. declare module BABYLON {
  47924. /**
  47925. * Particle emitter emitting particles from a point.
  47926. * It emits the particles randomly between 2 given directions.
  47927. */
  47928. class PointParticleEmitter implements IParticleEmitterType {
  47929. /**
  47930. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  47931. */
  47932. direction1: Vector3;
  47933. /**
  47934. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  47935. */
  47936. direction2: Vector3;
  47937. /**
  47938. * Creates a new instance PointParticleEmitter
  47939. */
  47940. constructor();
  47941. /**
  47942. * Called by the particle System when the direction is computed for the created particle.
  47943. * @param worldMatrix is the world matrix of the particle system
  47944. * @param directionToUpdate is the direction vector to update with the result
  47945. * @param particle is the particle we are computed the direction for
  47946. */
  47947. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  47948. /**
  47949. * Called by the particle System when the position is computed for the created particle.
  47950. * @param worldMatrix is the world matrix of the particle system
  47951. * @param positionToUpdate is the position vector to update with the result
  47952. * @param particle is the particle we are computed the position for
  47953. */
  47954. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  47955. /**
  47956. * Clones the current emitter and returns a copy of it
  47957. * @returns the new emitter
  47958. */
  47959. clone(): PointParticleEmitter;
  47960. /**
  47961. * Called by the GPUParticleSystem to setup the update shader
  47962. * @param effect defines the update shader
  47963. */
  47964. applyToShader(effect: Effect): void;
  47965. /**
  47966. * Returns a string to use to update the GPU particles update shader
  47967. * @returns a string containng the defines string
  47968. */
  47969. getEffectDefines(): string;
  47970. /**
  47971. * Returns the string "PointParticleEmitter"
  47972. * @returns a string containing the class name
  47973. */
  47974. getClassName(): string;
  47975. /**
  47976. * Serializes the particle system to a JSON object.
  47977. * @returns the JSON object
  47978. */
  47979. serialize(): any;
  47980. /**
  47981. * Parse properties from a JSON object
  47982. * @param serializationObject defines the JSON object
  47983. */
  47984. parse(serializationObject: any): void;
  47985. }
  47986. }
  47987. declare module BABYLON {
  47988. /**
  47989. * Particle emitter emitting particles from the inside of a sphere.
  47990. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  47991. */
  47992. class SphereParticleEmitter implements IParticleEmitterType {
  47993. /**
  47994. * The radius of the emission sphere.
  47995. */
  47996. radius: number;
  47997. /**
  47998. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  47999. */
  48000. radiusRange: number;
  48001. /**
  48002. * How much to randomize the particle direction [0-1].
  48003. */
  48004. directionRandomizer: number;
  48005. /**
  48006. * Creates a new instance SphereParticleEmitter
  48007. * @param radius the radius of the emission sphere (1 by default)
  48008. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  48009. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  48010. */
  48011. constructor(
  48012. /**
  48013. * The radius of the emission sphere.
  48014. */
  48015. radius?: number,
  48016. /**
  48017. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  48018. */
  48019. radiusRange?: number,
  48020. /**
  48021. * How much to randomize the particle direction [0-1].
  48022. */
  48023. directionRandomizer?: number);
  48024. /**
  48025. * Called by the particle System when the direction is computed for the created particle.
  48026. * @param worldMatrix is the world matrix of the particle system
  48027. * @param directionToUpdate is the direction vector to update with the result
  48028. * @param particle is the particle we are computed the direction for
  48029. */
  48030. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48031. /**
  48032. * Called by the particle System when the position is computed for the created particle.
  48033. * @param worldMatrix is the world matrix of the particle system
  48034. * @param positionToUpdate is the position vector to update with the result
  48035. * @param particle is the particle we are computed the position for
  48036. */
  48037. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48038. /**
  48039. * Clones the current emitter and returns a copy of it
  48040. * @returns the new emitter
  48041. */
  48042. clone(): SphereParticleEmitter;
  48043. /**
  48044. * Called by the GPUParticleSystem to setup the update shader
  48045. * @param effect defines the update shader
  48046. */
  48047. applyToShader(effect: Effect): void;
  48048. /**
  48049. * Returns a string to use to update the GPU particles update shader
  48050. * @returns a string containng the defines string
  48051. */
  48052. getEffectDefines(): string;
  48053. /**
  48054. * Returns the string "SphereParticleEmitter"
  48055. * @returns a string containing the class name
  48056. */
  48057. getClassName(): string;
  48058. /**
  48059. * Serializes the particle system to a JSON object.
  48060. * @returns the JSON object
  48061. */
  48062. serialize(): any;
  48063. /**
  48064. * Parse properties from a JSON object
  48065. * @param serializationObject defines the JSON object
  48066. */
  48067. parse(serializationObject: any): void;
  48068. }
  48069. /**
  48070. * Particle emitter emitting particles from the inside of a sphere.
  48071. * It emits the particles randomly between two vectors.
  48072. */
  48073. class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  48074. /**
  48075. * The min limit of the emission direction.
  48076. */
  48077. direction1: Vector3;
  48078. /**
  48079. * The max limit of the emission direction.
  48080. */
  48081. direction2: Vector3;
  48082. /**
  48083. * Creates a new instance SphereDirectedParticleEmitter
  48084. * @param radius the radius of the emission sphere (1 by default)
  48085. * @param direction1 the min limit of the emission direction (up vector by default)
  48086. * @param direction2 the max limit of the emission direction (up vector by default)
  48087. */
  48088. constructor(radius?: number,
  48089. /**
  48090. * The min limit of the emission direction.
  48091. */
  48092. direction1?: Vector3,
  48093. /**
  48094. * The max limit of the emission direction.
  48095. */
  48096. direction2?: Vector3);
  48097. /**
  48098. * Called by the particle System when the direction is computed for the created particle.
  48099. * @param worldMatrix is the world matrix of the particle system
  48100. * @param directionToUpdate is the direction vector to update with the result
  48101. * @param particle is the particle we are computed the direction for
  48102. */
  48103. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48104. /**
  48105. * Clones the current emitter and returns a copy of it
  48106. * @returns the new emitter
  48107. */
  48108. clone(): SphereDirectedParticleEmitter;
  48109. /**
  48110. * Called by the GPUParticleSystem to setup the update shader
  48111. * @param effect defines the update shader
  48112. */
  48113. applyToShader(effect: Effect): void;
  48114. /**
  48115. * Returns a string to use to update the GPU particles update shader
  48116. * @returns a string containng the defines string
  48117. */
  48118. getEffectDefines(): string;
  48119. /**
  48120. * Returns the string "SphereDirectedParticleEmitter"
  48121. * @returns a string containing the class name
  48122. */
  48123. getClassName(): string;
  48124. /**
  48125. * Serializes the particle system to a JSON object.
  48126. * @returns the JSON object
  48127. */
  48128. serialize(): any;
  48129. /**
  48130. * Parse properties from a JSON object
  48131. * @param serializationObject defines the JSON object
  48132. */
  48133. parse(serializationObject: any): void;
  48134. }
  48135. }
  48136. declare module BABYLON {
  48137. /**
  48138. * This represents a set of one or more post processes in Babylon.
  48139. * A post process can be used to apply a shader to a texture after it is rendered.
  48140. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  48141. */
  48142. class PostProcessRenderEffect {
  48143. private _postProcesses;
  48144. private _getPostProcesses;
  48145. private _singleInstance;
  48146. private _cameras;
  48147. private _indicesForCamera;
  48148. /**
  48149. * Name of the effect
  48150. * @hidden
  48151. */
  48152. _name: string;
  48153. /**
  48154. * Instantiates a post process render effect.
  48155. * A post process can be used to apply a shader to a texture after it is rendered.
  48156. * @param engine The engine the effect is tied to
  48157. * @param name The name of the effect
  48158. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  48159. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  48160. */
  48161. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  48162. /**
  48163. * Checks if all the post processes in the effect are supported.
  48164. */
  48165. readonly isSupported: boolean;
  48166. /**
  48167. * Updates the current state of the effect
  48168. * @hidden
  48169. */
  48170. _update(): void;
  48171. /**
  48172. * Attaches the effect on cameras
  48173. * @param cameras The camera to attach to.
  48174. * @hidden
  48175. */
  48176. _attachCameras(cameras: Camera): void;
  48177. /**
  48178. * Attaches the effect on cameras
  48179. * @param cameras The camera to attach to.
  48180. * @hidden
  48181. */
  48182. _attachCameras(cameras: Camera[]): void;
  48183. /**
  48184. * Detatches the effect on cameras
  48185. * @param cameras The camera to detatch from.
  48186. * @hidden
  48187. */
  48188. _detachCameras(cameras: Camera): void;
  48189. /**
  48190. * Detatches the effect on cameras
  48191. * @param cameras The camera to detatch from.
  48192. * @hidden
  48193. */
  48194. _detachCameras(cameras: Camera[]): void;
  48195. /**
  48196. * Enables the effect on given cameras
  48197. * @param cameras The camera to enable.
  48198. * @hidden
  48199. */
  48200. _enable(cameras: Camera): void;
  48201. /**
  48202. * Enables the effect on given cameras
  48203. * @param cameras The camera to enable.
  48204. * @hidden
  48205. */
  48206. _enable(cameras: Nullable<Camera[]>): void;
  48207. /**
  48208. * Disables the effect on the given cameras
  48209. * @param cameras The camera to disable.
  48210. * @hidden
  48211. */
  48212. _disable(cameras: Camera): void;
  48213. /**
  48214. * Disables the effect on the given cameras
  48215. * @param cameras The camera to disable.
  48216. * @hidden
  48217. */
  48218. _disable(cameras: Nullable<Camera[]>): void;
  48219. /**
  48220. * Gets a list of the post processes contained in the effect.
  48221. * @param camera The camera to get the post processes on.
  48222. * @returns The list of the post processes in the effect.
  48223. */
  48224. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  48225. }
  48226. }
  48227. declare module BABYLON {
  48228. /**
  48229. * PostProcessRenderPipeline
  48230. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  48231. */
  48232. class PostProcessRenderPipeline {
  48233. private engine;
  48234. private _renderEffects;
  48235. private _renderEffectsForIsolatedPass;
  48236. /**
  48237. * @hidden
  48238. */
  48239. protected _cameras: Camera[];
  48240. /** @hidden */
  48241. _name: string;
  48242. /**
  48243. * Initializes a PostProcessRenderPipeline
  48244. * @param engine engine to add the pipeline to
  48245. * @param name name of the pipeline
  48246. */
  48247. constructor(engine: Engine, name: string);
  48248. /**
  48249. * "PostProcessRenderPipeline"
  48250. * @returns "PostProcessRenderPipeline"
  48251. */
  48252. getClassName(): string;
  48253. /**
  48254. * If all the render effects in the pipeline are support
  48255. */
  48256. readonly isSupported: boolean;
  48257. /**
  48258. * Adds an effect to the pipeline
  48259. * @param renderEffect the effect to add
  48260. */
  48261. addEffect(renderEffect: PostProcessRenderEffect): void;
  48262. /** @hidden */
  48263. _rebuild(): void;
  48264. /** @hidden */
  48265. _enableEffect(renderEffectName: string, cameras: Camera): void;
  48266. /** @hidden */
  48267. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  48268. /** @hidden */
  48269. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  48270. /** @hidden */
  48271. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  48272. /** @hidden */
  48273. _attachCameras(cameras: Camera, unique: boolean): void;
  48274. /** @hidden */
  48275. _attachCameras(cameras: Camera[], unique: boolean): void;
  48276. /** @hidden */
  48277. _detachCameras(cameras: Camera): void;
  48278. /** @hidden */
  48279. _detachCameras(cameras: Nullable<Camera[]>): void;
  48280. /** @hidden */
  48281. _update(): void;
  48282. /** @hidden */
  48283. _reset(): void;
  48284. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  48285. /**
  48286. * Disposes of the pipeline
  48287. */
  48288. dispose(): void;
  48289. }
  48290. }
  48291. declare module BABYLON {
  48292. /**
  48293. * PostProcessRenderPipelineManager class
  48294. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  48295. */
  48296. class PostProcessRenderPipelineManager {
  48297. private _renderPipelines;
  48298. /**
  48299. * Initializes a PostProcessRenderPipelineManager
  48300. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  48301. */
  48302. constructor();
  48303. /**
  48304. * Adds a pipeline to the manager
  48305. * @param renderPipeline The pipeline to add
  48306. */
  48307. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  48308. /**
  48309. * Attaches a camera to the pipeline
  48310. * @param renderPipelineName The name of the pipeline to attach to
  48311. * @param cameras the camera to attach
  48312. * @param unique if the camera can be attached multiple times to the pipeline
  48313. */
  48314. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  48315. /**
  48316. * Detaches a camera from the pipeline
  48317. * @param renderPipelineName The name of the pipeline to detach from
  48318. * @param cameras the camera to detach
  48319. */
  48320. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  48321. /**
  48322. * Enables an effect by name on a pipeline
  48323. * @param renderPipelineName the name of the pipeline to enable the effect in
  48324. * @param renderEffectName the name of the effect to enable
  48325. * @param cameras the cameras that the effect should be enabled on
  48326. */
  48327. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  48328. /**
  48329. * Disables an effect by name on a pipeline
  48330. * @param renderPipelineName the name of the pipeline to disable the effect in
  48331. * @param renderEffectName the name of the effect to disable
  48332. * @param cameras the cameras that the effect should be disabled on
  48333. */
  48334. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  48335. /**
  48336. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  48337. */
  48338. update(): void;
  48339. /** @hidden */
  48340. _rebuild(): void;
  48341. /**
  48342. * Disposes of the manager and pipelines
  48343. */
  48344. dispose(): void;
  48345. }
  48346. }
  48347. declare module BABYLON {
  48348. interface Scene {
  48349. /** @hidden (Backing field) */
  48350. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  48351. /**
  48352. * Gets the postprocess render pipeline manager
  48353. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  48354. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  48355. */
  48356. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  48357. }
  48358. /**
  48359. * Defines the Render Pipeline scene component responsible to rendering pipelines
  48360. */
  48361. class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  48362. /**
  48363. * The component name helpfull to identify the component in the list of scene components.
  48364. */
  48365. readonly name: string;
  48366. /**
  48367. * The scene the component belongs to.
  48368. */
  48369. scene: Scene;
  48370. /**
  48371. * Creates a new instance of the component for the given scene
  48372. * @param scene Defines the scene to register the component in
  48373. */
  48374. constructor(scene: Scene);
  48375. /**
  48376. * Registers the component in a given scene
  48377. */
  48378. register(): void;
  48379. /**
  48380. * Rebuilds the elements related to this component in case of
  48381. * context lost for instance.
  48382. */
  48383. rebuild(): void;
  48384. /**
  48385. * Disposes the component and the associated ressources
  48386. */
  48387. dispose(): void;
  48388. private _gatherRenderTargets;
  48389. }
  48390. }
  48391. declare module BABYLON {
  48392. /**
  48393. * Helper class dealing with the extraction of spherical polynomial dataArray
  48394. * from a cube map.
  48395. */
  48396. class CubeMapToSphericalPolynomialTools {
  48397. private static FileFaces;
  48398. /**
  48399. * Converts a texture to the according Spherical Polynomial data.
  48400. * This extracts the first 3 orders only as they are the only one used in the lighting.
  48401. *
  48402. * @param texture The texture to extract the information from.
  48403. * @return The Spherical Polynomial data.
  48404. */
  48405. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  48406. /**
  48407. * Converts a cubemap to the according Spherical Polynomial data.
  48408. * This extracts the first 3 orders only as they are the only one used in the lighting.
  48409. *
  48410. * @param cubeInfo The Cube map to extract the information from.
  48411. * @return The Spherical Polynomial data.
  48412. */
  48413. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  48414. }
  48415. }
  48416. declare module BABYLON {
  48417. /**
  48418. * Header information of HDR texture files.
  48419. */
  48420. interface HDRInfo {
  48421. /**
  48422. * The height of the texture in pixels.
  48423. */
  48424. height: number;
  48425. /**
  48426. * The width of the texture in pixels.
  48427. */
  48428. width: number;
  48429. /**
  48430. * The index of the beginning of the data in the binary file.
  48431. */
  48432. dataPosition: number;
  48433. }
  48434. /**
  48435. * This groups tools to convert HDR texture to native colors array.
  48436. */
  48437. class HDRTools {
  48438. private static Ldexp;
  48439. private static Rgbe2float;
  48440. private static readStringLine;
  48441. /**
  48442. * Reads header information from an RGBE texture stored in a native array.
  48443. * More information on this format are available here:
  48444. * https://en.wikipedia.org/wiki/RGBE_image_format
  48445. *
  48446. * @param uint8array The binary file stored in native array.
  48447. * @return The header information.
  48448. */
  48449. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  48450. /**
  48451. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  48452. * This RGBE texture needs to store the information as a panorama.
  48453. *
  48454. * More information on this format are available here:
  48455. * https://en.wikipedia.org/wiki/RGBE_image_format
  48456. *
  48457. * @param buffer The binary file stored in an array buffer.
  48458. * @param size The expected size of the extracted cubemap.
  48459. * @return The Cube Map information.
  48460. */
  48461. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  48462. /**
  48463. * Returns the pixels data extracted from an RGBE texture.
  48464. * This pixels will be stored left to right up to down in the R G B order in one array.
  48465. *
  48466. * More information on this format are available here:
  48467. * https://en.wikipedia.org/wiki/RGBE_image_format
  48468. *
  48469. * @param uint8array The binary file stored in an array buffer.
  48470. * @param hdrInfo The header information of the file.
  48471. * @return The pixels data in RGB right to left up to down order.
  48472. */
  48473. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  48474. private static RGBE_ReadPixels_RLE;
  48475. }
  48476. }
  48477. declare module BABYLON {
  48478. /**
  48479. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  48480. */
  48481. interface CubeMapInfo {
  48482. /**
  48483. * The pixel array for the front face.
  48484. * This is stored in format, left to right, up to down format.
  48485. */
  48486. front: Nullable<ArrayBufferView>;
  48487. /**
  48488. * The pixel array for the back face.
  48489. * This is stored in format, left to right, up to down format.
  48490. */
  48491. back: Nullable<ArrayBufferView>;
  48492. /**
  48493. * The pixel array for the left face.
  48494. * This is stored in format, left to right, up to down format.
  48495. */
  48496. left: Nullable<ArrayBufferView>;
  48497. /**
  48498. * The pixel array for the right face.
  48499. * This is stored in format, left to right, up to down format.
  48500. */
  48501. right: Nullable<ArrayBufferView>;
  48502. /**
  48503. * The pixel array for the up face.
  48504. * This is stored in format, left to right, up to down format.
  48505. */
  48506. up: Nullable<ArrayBufferView>;
  48507. /**
  48508. * The pixel array for the down face.
  48509. * This is stored in format, left to right, up to down format.
  48510. */
  48511. down: Nullable<ArrayBufferView>;
  48512. /**
  48513. * The size of the cubemap stored.
  48514. *
  48515. * Each faces will be size * size pixels.
  48516. */
  48517. size: number;
  48518. /**
  48519. * The format of the texture.
  48520. *
  48521. * RGBA, RGB.
  48522. */
  48523. format: number;
  48524. /**
  48525. * The type of the texture data.
  48526. *
  48527. * UNSIGNED_INT, FLOAT.
  48528. */
  48529. type: number;
  48530. /**
  48531. * Specifies whether the texture is in gamma space.
  48532. */
  48533. gammaSpace: boolean;
  48534. }
  48535. /**
  48536. * Helper class usefull to convert panorama picture to their cubemap representation in 6 faces.
  48537. */
  48538. class PanoramaToCubeMapTools {
  48539. private static FACE_FRONT;
  48540. private static FACE_BACK;
  48541. private static FACE_RIGHT;
  48542. private static FACE_LEFT;
  48543. private static FACE_DOWN;
  48544. private static FACE_UP;
  48545. /**
  48546. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  48547. *
  48548. * @param float32Array The source data.
  48549. * @param inputWidth The width of the input panorama.
  48550. * @param inputHeight The height of the input panorama.
  48551. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  48552. * @return The cubemap data
  48553. */
  48554. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  48555. private static CreateCubemapTexture;
  48556. private static CalcProjectionSpherical;
  48557. }
  48558. }
  48559. declare module BABYLON {
  48560. /**
  48561. * 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.
  48562. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  48563. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  48564. */
  48565. class CustomProceduralTexture extends ProceduralTexture {
  48566. private _animate;
  48567. private _time;
  48568. private _config;
  48569. private _texturePath;
  48570. /**
  48571. * Instantiates a new Custom Procedural Texture.
  48572. * 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.
  48573. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  48574. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  48575. * @param name Define the name of the texture
  48576. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  48577. * @param size Define the size of the texture to create
  48578. * @param scene Define the scene the texture belongs to
  48579. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  48580. * @param generateMipMaps Define if the texture should creates mip maps or not
  48581. */
  48582. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  48583. private _loadJson;
  48584. /**
  48585. * Is the texture ready to be used ? (rendered at least once)
  48586. * @returns true if ready, otherwise, false.
  48587. */
  48588. isReady(): boolean;
  48589. /**
  48590. * Render the texture to its associated render target.
  48591. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  48592. */
  48593. render(useCameraPostProcess?: boolean): void;
  48594. /**
  48595. * Update the list of dependant textures samplers in the shader.
  48596. */
  48597. updateTextures(): void;
  48598. /**
  48599. * Update the uniform values of the procedural texture in the shader.
  48600. */
  48601. updateShaderUniforms(): void;
  48602. /**
  48603. * Define if the texture animates or not.
  48604. */
  48605. animate: boolean;
  48606. }
  48607. }
  48608. declare module BABYLON {
  48609. /**
  48610. * Class used to generate noise procedural textures
  48611. */
  48612. class NoiseProceduralTexture extends ProceduralTexture {
  48613. private _time;
  48614. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  48615. brightness: number;
  48616. /** Defines the number of octaves to process */
  48617. octaves: number;
  48618. /** Defines the level of persistence (0.8 by default) */
  48619. persistence: number;
  48620. /** Gets or sets animation speed factor (default is 1) */
  48621. animationSpeedFactor: number;
  48622. /**
  48623. * Creates a new NoiseProceduralTexture
  48624. * @param name defines the name fo the texture
  48625. * @param size defines the size of the texture (default is 256)
  48626. * @param scene defines the hosting scene
  48627. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  48628. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  48629. */
  48630. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  48631. private _updateShaderUniforms;
  48632. protected _getDefines(): string;
  48633. /** Generate the current state of the procedural texture */
  48634. render(useCameraPostProcess?: boolean): void;
  48635. /**
  48636. * Serializes this noise procedural texture
  48637. * @returns a serialized noise procedural texture object
  48638. */
  48639. serialize(): any;
  48640. /**
  48641. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  48642. * @param parsedTexture defines parsed texture data
  48643. * @param scene defines the current scene
  48644. * @param rootUrl defines the root URL containing noise procedural texture information
  48645. * @returns a parsed NoiseProceduralTexture
  48646. */
  48647. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): NoiseProceduralTexture;
  48648. }
  48649. }
  48650. declare module BABYLON {
  48651. /**
  48652. * 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.
  48653. * This is the base class of any Procedural texture and contains most of the shareable code.
  48654. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  48655. */
  48656. class ProceduralTexture extends Texture {
  48657. isCube: boolean;
  48658. /**
  48659. * Define if the texture is enabled or not (disabled texture will not render)
  48660. */
  48661. isEnabled: boolean;
  48662. /**
  48663. * Define if the texture must be cleared before rendering (default is true)
  48664. */
  48665. autoClear: boolean;
  48666. /**
  48667. * Callback called when the texture is generated
  48668. */
  48669. onGenerated: () => void;
  48670. /**
  48671. * Event raised when the texture is generated
  48672. */
  48673. onGeneratedObservable: Observable<ProceduralTexture>;
  48674. /** @hidden */
  48675. _generateMipMaps: boolean;
  48676. /** @hidden **/
  48677. _effect: Effect;
  48678. /** @hidden */
  48679. _textures: {
  48680. [key: string]: Texture;
  48681. };
  48682. private _size;
  48683. private _currentRefreshId;
  48684. private _refreshRate;
  48685. private _vertexBuffers;
  48686. private _indexBuffer;
  48687. private _uniforms;
  48688. private _samplers;
  48689. private _fragment;
  48690. private _floats;
  48691. private _ints;
  48692. private _floatsArrays;
  48693. private _colors3;
  48694. private _colors4;
  48695. private _vectors2;
  48696. private _vectors3;
  48697. private _matrices;
  48698. private _fallbackTexture;
  48699. private _fallbackTextureUsed;
  48700. private _engine;
  48701. private _cachedDefines;
  48702. private _contentUpdateId;
  48703. private _contentData;
  48704. /**
  48705. * Instantiates a new procedural texture.
  48706. * 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.
  48707. * This is the base class of any Procedural texture and contains most of the shareable code.
  48708. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  48709. * @param name Define the name of the texture
  48710. * @param size Define the size of the texture to create
  48711. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  48712. * @param scene Define the scene the texture belongs to
  48713. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  48714. * @param generateMipMaps Define if the texture should creates mip maps or not
  48715. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  48716. */
  48717. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  48718. /**
  48719. * The effect that is created when initializing the post process.
  48720. * @returns The created effect corrisponding the the postprocess.
  48721. */
  48722. getEffect(): Effect;
  48723. /**
  48724. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  48725. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  48726. */
  48727. getContent(): Nullable<ArrayBufferView>;
  48728. private _createIndexBuffer;
  48729. /** @hidden */
  48730. _rebuild(): void;
  48731. /**
  48732. * Resets the texture in order to recreate its associated resources.
  48733. * This can be called in case of context loss
  48734. */
  48735. reset(): void;
  48736. protected _getDefines(): string;
  48737. /**
  48738. * Is the texture ready to be used ? (rendered at least once)
  48739. * @returns true if ready, otherwise, false.
  48740. */
  48741. isReady(): boolean;
  48742. /**
  48743. * Resets the refresh counter of the texture and start bak from scratch.
  48744. * Could be usefull to regenerate the texture if it is setup to render only once.
  48745. */
  48746. resetRefreshCounter(): void;
  48747. /**
  48748. * Set the fragment shader to use in order to render the texture.
  48749. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  48750. */
  48751. setFragment(fragment: any): void;
  48752. /**
  48753. * Define the refresh rate of the texture or the rendering frequency.
  48754. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  48755. */
  48756. refreshRate: number;
  48757. /** @hidden */
  48758. _shouldRender(): boolean;
  48759. /**
  48760. * Get the size the texture is rendering at.
  48761. * @returns the size (texture is always squared)
  48762. */
  48763. getRenderSize(): number;
  48764. /**
  48765. * Resize the texture to new value.
  48766. * @param size Define the new size the texture should have
  48767. * @param generateMipMaps Define whether the new texture should create mip maps
  48768. */
  48769. resize(size: number, generateMipMaps: boolean): void;
  48770. private _checkUniform;
  48771. /**
  48772. * Set a texture in the shader program used to render.
  48773. * @param name Define the name of the uniform samplers as defined in the shader
  48774. * @param texture Define the texture to bind to this sampler
  48775. * @return the texture itself allowing "fluent" like uniform updates
  48776. */
  48777. setTexture(name: string, texture: Texture): ProceduralTexture;
  48778. /**
  48779. * Set a float in the shader.
  48780. * @param name Define the name of the uniform as defined in the shader
  48781. * @param value Define the value to give to the uniform
  48782. * @return the texture itself allowing "fluent" like uniform updates
  48783. */
  48784. setFloat(name: string, value: number): ProceduralTexture;
  48785. /**
  48786. * Set a int in the shader.
  48787. * @param name Define the name of the uniform as defined in the shader
  48788. * @param value Define the value to give to the uniform
  48789. * @return the texture itself allowing "fluent" like uniform updates
  48790. */
  48791. setInt(name: string, value: number): ProceduralTexture;
  48792. /**
  48793. * Set an array of floats in the shader.
  48794. * @param name Define the name of the uniform as defined in the shader
  48795. * @param value Define the value to give to the uniform
  48796. * @return the texture itself allowing "fluent" like uniform updates
  48797. */
  48798. setFloats(name: string, value: number[]): ProceduralTexture;
  48799. /**
  48800. * Set a vec3 in the shader from a Color3.
  48801. * @param name Define the name of the uniform as defined in the shader
  48802. * @param value Define the value to give to the uniform
  48803. * @return the texture itself allowing "fluent" like uniform updates
  48804. */
  48805. setColor3(name: string, value: Color3): ProceduralTexture;
  48806. /**
  48807. * Set a vec4 in the shader from a Color4.
  48808. * @param name Define the name of the uniform as defined in the shader
  48809. * @param value Define the value to give to the uniform
  48810. * @return the texture itself allowing "fluent" like uniform updates
  48811. */
  48812. setColor4(name: string, value: Color4): ProceduralTexture;
  48813. /**
  48814. * Set a vec2 in the shader from a Vector2.
  48815. * @param name Define the name of the uniform as defined in the shader
  48816. * @param value Define the value to give to the uniform
  48817. * @return the texture itself allowing "fluent" like uniform updates
  48818. */
  48819. setVector2(name: string, value: Vector2): ProceduralTexture;
  48820. /**
  48821. * Set a vec3 in the shader from a Vector3.
  48822. * @param name Define the name of the uniform as defined in the shader
  48823. * @param value Define the value to give to the uniform
  48824. * @return the texture itself allowing "fluent" like uniform updates
  48825. */
  48826. setVector3(name: string, value: Vector3): ProceduralTexture;
  48827. /**
  48828. * Set a mat4 in the shader from a MAtrix.
  48829. * @param name Define the name of the uniform as defined in the shader
  48830. * @param value Define the value to give to the uniform
  48831. * @return the texture itself allowing "fluent" like uniform updates
  48832. */
  48833. setMatrix(name: string, value: Matrix): ProceduralTexture;
  48834. /**
  48835. * Render the texture to its associated render target.
  48836. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  48837. */
  48838. render(useCameraPostProcess?: boolean): void;
  48839. /**
  48840. * Clone the texture.
  48841. * @returns the cloned texture
  48842. */
  48843. clone(): ProceduralTexture;
  48844. /**
  48845. * Dispose the texture and release its asoociated resources.
  48846. */
  48847. dispose(): void;
  48848. }
  48849. }
  48850. declare module BABYLON {
  48851. interface AbstractScene {
  48852. /**
  48853. * The list of procedural textures added to the scene
  48854. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  48855. */
  48856. proceduralTextures: Array<ProceduralTexture>;
  48857. }
  48858. /**
  48859. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  48860. * in a given scene.
  48861. */
  48862. class ProceduralTextureSceneComponent implements ISceneComponent {
  48863. /**
  48864. * The component name helpfull to identify the component in the list of scene components.
  48865. */
  48866. readonly name: string;
  48867. /**
  48868. * The scene the component belongs to.
  48869. */
  48870. scene: Scene;
  48871. /**
  48872. * Creates a new instance of the component for the given scene
  48873. * @param scene Defines the scene to register the component in
  48874. */
  48875. constructor(scene: Scene);
  48876. /**
  48877. * Registers the component in a given scene
  48878. */
  48879. register(): void;
  48880. /**
  48881. * Rebuilds the elements related to this component in case of
  48882. * context lost for instance.
  48883. */
  48884. rebuild(): void;
  48885. /**
  48886. * Disposes the component and the associated ressources.
  48887. */
  48888. dispose(): void;
  48889. private _beforeClear;
  48890. }
  48891. }
  48892. declare module BABYLON {
  48893. }
  48894. declare module BABYLON {
  48895. }
  48896. declare module BABYLON {
  48897. }
  48898. declare module BABYLON {
  48899. }
  48900. declare module BABYLON {
  48901. /**
  48902. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  48903. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  48904. */
  48905. class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  48906. private _scene;
  48907. private _camerasToBeAttached;
  48908. /**
  48909. * ID of the sharpen post process,
  48910. */
  48911. private readonly SharpenPostProcessId;
  48912. /**
  48913. * @ignore
  48914. * ID of the image processing post process;
  48915. */
  48916. readonly ImageProcessingPostProcessId: string;
  48917. /**
  48918. * @ignore
  48919. * ID of the Fast Approximate Anti-Aliasing post process;
  48920. */
  48921. readonly FxaaPostProcessId: string;
  48922. /**
  48923. * ID of the chromatic aberration post process,
  48924. */
  48925. private readonly ChromaticAberrationPostProcessId;
  48926. /**
  48927. * ID of the grain post process
  48928. */
  48929. private readonly GrainPostProcessId;
  48930. /**
  48931. * Sharpen post process which will apply a sharpen convolution to enhance edges
  48932. */
  48933. sharpen: SharpenPostProcess;
  48934. private _sharpenEffect;
  48935. private bloom;
  48936. /**
  48937. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  48938. */
  48939. depthOfField: DepthOfFieldEffect;
  48940. /**
  48941. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  48942. */
  48943. fxaa: FxaaPostProcess;
  48944. /**
  48945. * Image post processing pass used to perform operations such as tone mapping or color grading.
  48946. */
  48947. imageProcessing: ImageProcessingPostProcess;
  48948. /**
  48949. * Chromatic aberration post process which will shift rgb colors in the image
  48950. */
  48951. chromaticAberration: ChromaticAberrationPostProcess;
  48952. private _chromaticAberrationEffect;
  48953. /**
  48954. * Grain post process which add noise to the image
  48955. */
  48956. grain: GrainPostProcess;
  48957. private _grainEffect;
  48958. /**
  48959. * Glow post process which adds a glow to emmisive areas of the image
  48960. */
  48961. private _glowLayer;
  48962. /**
  48963. * Animations which can be used to tweak settings over a period of time
  48964. */
  48965. animations: Animation[];
  48966. private _imageProcessingConfigurationObserver;
  48967. private _sharpenEnabled;
  48968. private _bloomEnabled;
  48969. private _depthOfFieldEnabled;
  48970. private _depthOfFieldBlurLevel;
  48971. private _fxaaEnabled;
  48972. private _imageProcessingEnabled;
  48973. private _defaultPipelineTextureType;
  48974. private _bloomScale;
  48975. private _chromaticAberrationEnabled;
  48976. private _grainEnabled;
  48977. private _buildAllowed;
  48978. /**
  48979. * Enable or disable the sharpen process from the pipeline
  48980. */
  48981. sharpenEnabled: boolean;
  48982. private _resizeObserver;
  48983. private _hardwareScaleLevel;
  48984. private _bloomKernel;
  48985. /**
  48986. * Specifies the size of the bloom blur kernel, relative to the final output size
  48987. */
  48988. bloomKernel: number;
  48989. /**
  48990. * Specifies the weight of the bloom in the final rendering
  48991. */
  48992. private _bloomWeight;
  48993. /**
  48994. * Specifies the luma threshold for the area that will be blurred by the bloom
  48995. */
  48996. private _bloomThreshold;
  48997. private _hdr;
  48998. /**
  48999. * The strength of the bloom.
  49000. */
  49001. bloomWeight: number;
  49002. /**
  49003. * The strength of the bloom.
  49004. */
  49005. bloomThreshold: number;
  49006. /**
  49007. * The scale of the bloom, lower value will provide better performance.
  49008. */
  49009. bloomScale: number;
  49010. /**
  49011. * Enable or disable the bloom from the pipeline
  49012. */
  49013. bloomEnabled: boolean;
  49014. private _rebuildBloom;
  49015. /**
  49016. * If the depth of field is enabled.
  49017. */
  49018. depthOfFieldEnabled: boolean;
  49019. /**
  49020. * Blur level of the depth of field effect. (Higher blur will effect performance)
  49021. */
  49022. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  49023. /**
  49024. * If the anti aliasing is enabled.
  49025. */
  49026. fxaaEnabled: boolean;
  49027. private _samples;
  49028. /**
  49029. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  49030. */
  49031. samples: number;
  49032. /**
  49033. * If image processing is enabled.
  49034. */
  49035. imageProcessingEnabled: boolean;
  49036. /**
  49037. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  49038. */
  49039. glowLayerEnabled: boolean;
  49040. /**
  49041. * Enable or disable the chromaticAberration process from the pipeline
  49042. */
  49043. chromaticAberrationEnabled: boolean;
  49044. /**
  49045. * Enable or disable the grain process from the pipeline
  49046. */
  49047. grainEnabled: boolean;
  49048. /**
  49049. * @constructor
  49050. * @param name - The rendering pipeline name (default: "")
  49051. * @param hdr - If high dynamic range textures should be used (default: true)
  49052. * @param scene - The scene linked to this pipeline (default: the last created scene)
  49053. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  49054. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  49055. */
  49056. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  49057. /**
  49058. * Force the compilation of the entire pipeline.
  49059. */
  49060. prepare(): void;
  49061. private _hasCleared;
  49062. private _prevPostProcess;
  49063. private _prevPrevPostProcess;
  49064. private _setAutoClearAndTextureSharing;
  49065. private _depthOfFieldSceneObserver;
  49066. private _buildPipeline;
  49067. private _disposePostProcesses;
  49068. /**
  49069. * Adds a camera to the pipeline
  49070. * @param camera the camera to be added
  49071. */
  49072. addCamera(camera: Camera): void;
  49073. /**
  49074. * Removes a camera from the pipeline
  49075. * @param camera the camera to remove
  49076. */
  49077. removeCamera(camera: Camera): void;
  49078. /**
  49079. * Dispose of the pipeline and stop all post processes
  49080. */
  49081. dispose(): void;
  49082. /**
  49083. * Serialize the rendering pipeline (Used when exporting)
  49084. * @returns the serialized object
  49085. */
  49086. serialize(): any;
  49087. /**
  49088. * Parse the serialized pipeline
  49089. * @param source Source pipeline.
  49090. * @param scene The scene to load the pipeline to.
  49091. * @param rootUrl The URL of the serialized pipeline.
  49092. * @returns An instantiated pipeline from the serialized object.
  49093. */
  49094. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  49095. }
  49096. }
  49097. declare module BABYLON {
  49098. /**
  49099. * BABYLON.JS Chromatic Aberration GLSL Shader
  49100. * Author: Olivier Guyot
  49101. * Separates very slightly R, G and B colors on the edges of the screen
  49102. * Inspired by Francois Tarlier & Martins Upitis
  49103. */
  49104. class LensRenderingPipeline extends PostProcessRenderPipeline {
  49105. /**
  49106. * @ignore
  49107. * The chromatic aberration PostProcess id in the pipeline
  49108. */
  49109. LensChromaticAberrationEffect: string;
  49110. /**
  49111. * @ignore
  49112. * The highlights enhancing PostProcess id in the pipeline
  49113. */
  49114. HighlightsEnhancingEffect: string;
  49115. /**
  49116. * @ignore
  49117. * The depth-of-field PostProcess id in the pipeline
  49118. */
  49119. LensDepthOfFieldEffect: string;
  49120. private _scene;
  49121. private _depthTexture;
  49122. private _grainTexture;
  49123. private _chromaticAberrationPostProcess;
  49124. private _highlightsPostProcess;
  49125. private _depthOfFieldPostProcess;
  49126. private _edgeBlur;
  49127. private _grainAmount;
  49128. private _chromaticAberration;
  49129. private _distortion;
  49130. private _highlightsGain;
  49131. private _highlightsThreshold;
  49132. private _dofDistance;
  49133. private _dofAperture;
  49134. private _dofDarken;
  49135. private _dofPentagon;
  49136. private _blurNoise;
  49137. /**
  49138. * @constructor
  49139. *
  49140. * Effect parameters are as follow:
  49141. * {
  49142. * chromatic_aberration: number; // from 0 to x (1 for realism)
  49143. * edge_blur: number; // from 0 to x (1 for realism)
  49144. * distortion: number; // from 0 to x (1 for realism)
  49145. * grain_amount: number; // from 0 to 1
  49146. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  49147. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  49148. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  49149. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  49150. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  49151. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  49152. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  49153. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  49154. * }
  49155. * Note: if an effect parameter is unset, effect is disabled
  49156. *
  49157. * @param name The rendering pipeline name
  49158. * @param parameters - An object containing all parameters (see above)
  49159. * @param scene The scene linked to this pipeline
  49160. * @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)
  49161. * @param cameras The array of cameras that the rendering pipeline will be attached to
  49162. */
  49163. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  49164. /**
  49165. * Sets the amount of blur at the edges
  49166. * @param amount blur amount
  49167. */
  49168. setEdgeBlur(amount: number): void;
  49169. /**
  49170. * Sets edge blur to 0
  49171. */
  49172. disableEdgeBlur(): void;
  49173. /**
  49174. * Sets the amout of grain
  49175. * @param amount Amount of grain
  49176. */
  49177. setGrainAmount(amount: number): void;
  49178. /**
  49179. * Set grain amount to 0
  49180. */
  49181. disableGrain(): void;
  49182. /**
  49183. * Sets the chromatic aberration amount
  49184. * @param amount amount of chromatic aberration
  49185. */
  49186. setChromaticAberration(amount: number): void;
  49187. /**
  49188. * Sets chromatic aberration amount to 0
  49189. */
  49190. disableChromaticAberration(): void;
  49191. /**
  49192. * Sets the EdgeDistortion amount
  49193. * @param amount amount of EdgeDistortion
  49194. */
  49195. setEdgeDistortion(amount: number): void;
  49196. /**
  49197. * Sets edge distortion to 0
  49198. */
  49199. disableEdgeDistortion(): void;
  49200. /**
  49201. * Sets the FocusDistance amount
  49202. * @param amount amount of FocusDistance
  49203. */
  49204. setFocusDistance(amount: number): void;
  49205. /**
  49206. * Disables depth of field
  49207. */
  49208. disableDepthOfField(): void;
  49209. /**
  49210. * Sets the Aperture amount
  49211. * @param amount amount of Aperture
  49212. */
  49213. setAperture(amount: number): void;
  49214. /**
  49215. * Sets the DarkenOutOfFocus amount
  49216. * @param amount amount of DarkenOutOfFocus
  49217. */
  49218. setDarkenOutOfFocus(amount: number): void;
  49219. /**
  49220. * Creates a pentagon bokeh effect
  49221. */
  49222. enablePentagonBokeh(): void;
  49223. /**
  49224. * Disables the pentagon bokeh effect
  49225. */
  49226. disablePentagonBokeh(): void;
  49227. /**
  49228. * Enables noise blur
  49229. */
  49230. enableNoiseBlur(): void;
  49231. /**
  49232. * Disables noise blur
  49233. */
  49234. disableNoiseBlur(): void;
  49235. /**
  49236. * Sets the HighlightsGain amount
  49237. * @param amount amount of HighlightsGain
  49238. */
  49239. setHighlightsGain(amount: number): void;
  49240. /**
  49241. * Sets the HighlightsThreshold amount
  49242. * @param amount amount of HighlightsThreshold
  49243. */
  49244. setHighlightsThreshold(amount: number): void;
  49245. /**
  49246. * Disables highlights
  49247. */
  49248. disableHighlights(): void;
  49249. /**
  49250. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  49251. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  49252. */
  49253. dispose(disableDepthRender?: boolean): void;
  49254. private _createChromaticAberrationPostProcess;
  49255. private _createHighlightsPostProcess;
  49256. private _createDepthOfFieldPostProcess;
  49257. private _createGrainTexture;
  49258. }
  49259. }
  49260. declare module BABYLON {
  49261. /**
  49262. * Render pipeline to produce ssao effect
  49263. */
  49264. class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  49265. /**
  49266. * @ignore
  49267. * The PassPostProcess id in the pipeline that contains the original scene color
  49268. */
  49269. SSAOOriginalSceneColorEffect: string;
  49270. /**
  49271. * @ignore
  49272. * The SSAO PostProcess id in the pipeline
  49273. */
  49274. SSAORenderEffect: string;
  49275. /**
  49276. * @ignore
  49277. * The horizontal blur PostProcess id in the pipeline
  49278. */
  49279. SSAOBlurHRenderEffect: string;
  49280. /**
  49281. * @ignore
  49282. * The vertical blur PostProcess id in the pipeline
  49283. */
  49284. SSAOBlurVRenderEffect: string;
  49285. /**
  49286. * @ignore
  49287. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  49288. */
  49289. SSAOCombineRenderEffect: string;
  49290. /**
  49291. * The output strength of the SSAO post-process. Default value is 1.0.
  49292. */
  49293. totalStrength: number;
  49294. /**
  49295. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  49296. */
  49297. maxZ: number;
  49298. /**
  49299. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  49300. */
  49301. minZAspect: number;
  49302. private _samples;
  49303. /**
  49304. * Number of samples used for the SSAO calculations. Default value is 8
  49305. */
  49306. samples: number;
  49307. private _textureSamples;
  49308. /**
  49309. * Number of samples to use for antialiasing
  49310. */
  49311. textureSamples: number;
  49312. /**
  49313. * Ratio object used for SSAO ratio and blur ratio
  49314. */
  49315. private _ratio;
  49316. /**
  49317. * Dynamically generated sphere sampler.
  49318. */
  49319. private _sampleSphere;
  49320. /**
  49321. * Blur filter offsets
  49322. */
  49323. private _samplerOffsets;
  49324. private _expensiveBlur;
  49325. /**
  49326. * If bilateral blur should be used
  49327. */
  49328. expensiveBlur: boolean;
  49329. /**
  49330. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  49331. */
  49332. radius: number;
  49333. /**
  49334. * The base color of the SSAO post-process
  49335. * The final result is "base + ssao" between [0, 1]
  49336. */
  49337. base: number;
  49338. /**
  49339. * Support test.
  49340. */
  49341. static readonly IsSupported: boolean;
  49342. private _scene;
  49343. private _depthTexture;
  49344. private _normalTexture;
  49345. private _randomTexture;
  49346. private _originalColorPostProcess;
  49347. private _ssaoPostProcess;
  49348. private _blurHPostProcess;
  49349. private _blurVPostProcess;
  49350. private _ssaoCombinePostProcess;
  49351. private _firstUpdate;
  49352. /**
  49353. * @constructor
  49354. * @param name The rendering pipeline name
  49355. * @param scene The scene linked to this pipeline
  49356. * @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 }
  49357. * @param cameras The array of cameras that the rendering pipeline will be attached to
  49358. */
  49359. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  49360. /**
  49361. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  49362. */
  49363. dispose(disableGeometryBufferRenderer?: boolean): void;
  49364. private _createBlurPostProcess;
  49365. /** @hidden */
  49366. _rebuild(): void;
  49367. private _bits;
  49368. private _radicalInverse_VdC;
  49369. private _hammersley;
  49370. private _hemisphereSample_uniform;
  49371. private _generateHemisphere;
  49372. private _createSSAOPostProcess;
  49373. private _createSSAOCombinePostProcess;
  49374. private _createRandomTexture;
  49375. /**
  49376. * Serialize the rendering pipeline (Used when exporting)
  49377. * @returns the serialized object
  49378. */
  49379. serialize(): any;
  49380. /**
  49381. * Parse the serialized pipeline
  49382. * @param source Source pipeline.
  49383. * @param scene The scene to load the pipeline to.
  49384. * @param rootUrl The URL of the serialized pipeline.
  49385. * @returns An instantiated pipeline from the serialized object.
  49386. */
  49387. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  49388. }
  49389. }
  49390. declare module BABYLON {
  49391. /**
  49392. * Render pipeline to produce ssao effect
  49393. */
  49394. class SSAORenderingPipeline extends PostProcessRenderPipeline {
  49395. /**
  49396. * @ignore
  49397. * The PassPostProcess id in the pipeline that contains the original scene color
  49398. */
  49399. SSAOOriginalSceneColorEffect: string;
  49400. /**
  49401. * @ignore
  49402. * The SSAO PostProcess id in the pipeline
  49403. */
  49404. SSAORenderEffect: string;
  49405. /**
  49406. * @ignore
  49407. * The horizontal blur PostProcess id in the pipeline
  49408. */
  49409. SSAOBlurHRenderEffect: string;
  49410. /**
  49411. * @ignore
  49412. * The vertical blur PostProcess id in the pipeline
  49413. */
  49414. SSAOBlurVRenderEffect: string;
  49415. /**
  49416. * @ignore
  49417. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  49418. */
  49419. SSAOCombineRenderEffect: string;
  49420. /**
  49421. * The output strength of the SSAO post-process. Default value is 1.0.
  49422. */
  49423. totalStrength: number;
  49424. /**
  49425. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  49426. */
  49427. radius: number;
  49428. /**
  49429. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  49430. * Must not be equal to fallOff and superior to fallOff.
  49431. * Default value is 0.975
  49432. */
  49433. area: number;
  49434. /**
  49435. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  49436. * Must not be equal to area and inferior to area.
  49437. * Default value is 0.0
  49438. */
  49439. fallOff: number;
  49440. /**
  49441. * The base color of the SSAO post-process
  49442. * The final result is "base + ssao" between [0, 1]
  49443. */
  49444. base: number;
  49445. private _scene;
  49446. private _depthTexture;
  49447. private _randomTexture;
  49448. private _originalColorPostProcess;
  49449. private _ssaoPostProcess;
  49450. private _blurHPostProcess;
  49451. private _blurVPostProcess;
  49452. private _ssaoCombinePostProcess;
  49453. private _firstUpdate;
  49454. /**
  49455. * @constructor
  49456. * @param name - The rendering pipeline name
  49457. * @param scene - The scene linked to this pipeline
  49458. * @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 }
  49459. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  49460. */
  49461. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  49462. /**
  49463. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  49464. */
  49465. dispose(disableDepthRender?: boolean): void;
  49466. private _createBlurPostProcess;
  49467. /** @hidden */
  49468. _rebuild(): void;
  49469. private _createSSAOPostProcess;
  49470. private _createSSAOCombinePostProcess;
  49471. private _createRandomTexture;
  49472. }
  49473. }
  49474. declare module BABYLON {
  49475. /**
  49476. * Standard rendering pipeline
  49477. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  49478. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  49479. */
  49480. class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  49481. /**
  49482. * Public members
  49483. */
  49484. /**
  49485. * Post-process which contains the original scene color before the pipeline applies all the effects
  49486. */
  49487. originalPostProcess: Nullable<PostProcess>;
  49488. /**
  49489. * Post-process used to down scale an image x4
  49490. */
  49491. downSampleX4PostProcess: Nullable<PostProcess>;
  49492. /**
  49493. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  49494. */
  49495. brightPassPostProcess: Nullable<PostProcess>;
  49496. /**
  49497. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  49498. */
  49499. blurHPostProcesses: PostProcess[];
  49500. /**
  49501. * Post-process array storing all the vertical blur post-processes used by the pipeline
  49502. */
  49503. blurVPostProcesses: PostProcess[];
  49504. /**
  49505. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  49506. */
  49507. textureAdderPostProcess: Nullable<PostProcess>;
  49508. /**
  49509. * Post-process used to create volumetric lighting effect
  49510. */
  49511. volumetricLightPostProcess: Nullable<PostProcess>;
  49512. /**
  49513. * Post-process used to smooth the previous volumetric light post-process on the X axis
  49514. */
  49515. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  49516. /**
  49517. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  49518. */
  49519. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  49520. /**
  49521. * Post-process used to merge the volumetric light effect and the real scene color
  49522. */
  49523. volumetricLightMergePostProces: Nullable<PostProcess>;
  49524. /**
  49525. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  49526. */
  49527. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  49528. /**
  49529. * Base post-process used to calculate the average luminance of the final image for HDR
  49530. */
  49531. luminancePostProcess: Nullable<PostProcess>;
  49532. /**
  49533. * Post-processes used to create down sample post-processes in order to get
  49534. * the average luminance of the final image for HDR
  49535. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  49536. */
  49537. luminanceDownSamplePostProcesses: PostProcess[];
  49538. /**
  49539. * Post-process used to create a HDR effect (light adaptation)
  49540. */
  49541. hdrPostProcess: Nullable<PostProcess>;
  49542. /**
  49543. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  49544. */
  49545. textureAdderFinalPostProcess: Nullable<PostProcess>;
  49546. /**
  49547. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  49548. */
  49549. lensFlareFinalPostProcess: Nullable<PostProcess>;
  49550. /**
  49551. * Post-process used to merge the final HDR post-process and the real scene color
  49552. */
  49553. hdrFinalPostProcess: Nullable<PostProcess>;
  49554. /**
  49555. * Post-process used to create a lens flare effect
  49556. */
  49557. lensFlarePostProcess: Nullable<PostProcess>;
  49558. /**
  49559. * Post-process that merges the result of the lens flare post-process and the real scene color
  49560. */
  49561. lensFlareComposePostProcess: Nullable<PostProcess>;
  49562. /**
  49563. * Post-process used to create a motion blur effect
  49564. */
  49565. motionBlurPostProcess: Nullable<PostProcess>;
  49566. /**
  49567. * Post-process used to create a depth of field effect
  49568. */
  49569. depthOfFieldPostProcess: Nullable<PostProcess>;
  49570. /**
  49571. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  49572. */
  49573. fxaaPostProcess: Nullable<FxaaPostProcess>;
  49574. /**
  49575. * Represents the brightness threshold in order to configure the illuminated surfaces
  49576. */
  49577. brightThreshold: number;
  49578. /**
  49579. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  49580. */
  49581. blurWidth: number;
  49582. /**
  49583. * Sets if the blur for highlighted surfaces must be only horizontal
  49584. */
  49585. horizontalBlur: boolean;
  49586. /**
  49587. * Sets the overall exposure used by the pipeline
  49588. */
  49589. exposure: number;
  49590. /**
  49591. * Texture used typically to simulate "dirty" on camera lens
  49592. */
  49593. lensTexture: Nullable<Texture>;
  49594. /**
  49595. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  49596. */
  49597. volumetricLightCoefficient: number;
  49598. /**
  49599. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  49600. */
  49601. volumetricLightPower: number;
  49602. /**
  49603. * Used the set the blur intensity to smooth the volumetric lights
  49604. */
  49605. volumetricLightBlurScale: number;
  49606. /**
  49607. * Light (spot or directional) used to generate the volumetric lights rays
  49608. * The source light must have a shadow generate so the pipeline can get its
  49609. * depth map
  49610. */
  49611. sourceLight: Nullable<SpotLight | DirectionalLight>;
  49612. /**
  49613. * For eye adaptation, represents the minimum luminance the eye can see
  49614. */
  49615. hdrMinimumLuminance: number;
  49616. /**
  49617. * For eye adaptation, represents the decrease luminance speed
  49618. */
  49619. hdrDecreaseRate: number;
  49620. /**
  49621. * For eye adaptation, represents the increase luminance speed
  49622. */
  49623. hdrIncreaseRate: number;
  49624. /**
  49625. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  49626. */
  49627. lensColorTexture: Nullable<Texture>;
  49628. /**
  49629. * The overall strengh for the lens flare effect
  49630. */
  49631. lensFlareStrength: number;
  49632. /**
  49633. * Dispersion coefficient for lens flare ghosts
  49634. */
  49635. lensFlareGhostDispersal: number;
  49636. /**
  49637. * Main lens flare halo width
  49638. */
  49639. lensFlareHaloWidth: number;
  49640. /**
  49641. * Based on the lens distortion effect, defines how much the lens flare result
  49642. * is distorted
  49643. */
  49644. lensFlareDistortionStrength: number;
  49645. /**
  49646. * Lens star texture must be used to simulate rays on the flares and is available
  49647. * in the documentation
  49648. */
  49649. lensStarTexture: Nullable<Texture>;
  49650. /**
  49651. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  49652. * flare effect by taking account of the dirt texture
  49653. */
  49654. lensFlareDirtTexture: Nullable<Texture>;
  49655. /**
  49656. * Represents the focal length for the depth of field effect
  49657. */
  49658. depthOfFieldDistance: number;
  49659. /**
  49660. * Represents the blur intensity for the blurred part of the depth of field effect
  49661. */
  49662. depthOfFieldBlurWidth: number;
  49663. /**
  49664. * For motion blur, defines how much the image is blurred by the movement
  49665. */
  49666. motionStrength: number;
  49667. /**
  49668. * List of animations for the pipeline (IAnimatable implementation)
  49669. */
  49670. animations: Animation[];
  49671. /**
  49672. * Private members
  49673. */
  49674. private _scene;
  49675. private _currentDepthOfFieldSource;
  49676. private _basePostProcess;
  49677. private _hdrCurrentLuminance;
  49678. private _floatTextureType;
  49679. private _ratio;
  49680. private _bloomEnabled;
  49681. private _depthOfFieldEnabled;
  49682. private _vlsEnabled;
  49683. private _lensFlareEnabled;
  49684. private _hdrEnabled;
  49685. private _motionBlurEnabled;
  49686. private _fxaaEnabled;
  49687. private _motionBlurSamples;
  49688. private _volumetricLightStepsCount;
  49689. private _samples;
  49690. /**
  49691. * @ignore
  49692. * Specifies if the bloom pipeline is enabled
  49693. */
  49694. BloomEnabled: boolean;
  49695. /**
  49696. * @ignore
  49697. * Specifies if the depth of field pipeline is enabed
  49698. */
  49699. DepthOfFieldEnabled: boolean;
  49700. /**
  49701. * @ignore
  49702. * Specifies if the lens flare pipeline is enabed
  49703. */
  49704. LensFlareEnabled: boolean;
  49705. /**
  49706. * @ignore
  49707. * Specifies if the HDR pipeline is enabled
  49708. */
  49709. HDREnabled: boolean;
  49710. /**
  49711. * @ignore
  49712. * Specifies if the volumetric lights scattering effect is enabled
  49713. */
  49714. VLSEnabled: boolean;
  49715. /**
  49716. * @ignore
  49717. * Specifies if the motion blur effect is enabled
  49718. */
  49719. MotionBlurEnabled: boolean;
  49720. /**
  49721. * Specifies if anti-aliasing is enabled
  49722. */
  49723. fxaaEnabled: boolean;
  49724. /**
  49725. * Specifies the number of steps used to calculate the volumetric lights
  49726. * Typically in interval [50, 200]
  49727. */
  49728. volumetricLightStepsCount: number;
  49729. /**
  49730. * Specifies the number of samples used for the motion blur effect
  49731. * Typically in interval [16, 64]
  49732. */
  49733. motionBlurSamples: number;
  49734. /**
  49735. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  49736. */
  49737. samples: number;
  49738. /**
  49739. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  49740. * @constructor
  49741. * @param name The rendering pipeline name
  49742. * @param scene The scene linked to this pipeline
  49743. * @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)
  49744. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  49745. * @param cameras The array of cameras that the rendering pipeline will be attached to
  49746. */
  49747. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  49748. private _buildPipeline;
  49749. private _createDownSampleX4PostProcess;
  49750. private _createBrightPassPostProcess;
  49751. private _createBlurPostProcesses;
  49752. private _createTextureAdderPostProcess;
  49753. private _createVolumetricLightPostProcess;
  49754. private _createLuminancePostProcesses;
  49755. private _createHdrPostProcess;
  49756. private _createLensFlarePostProcess;
  49757. private _createDepthOfFieldPostProcess;
  49758. private _createMotionBlurPostProcess;
  49759. private _getDepthTexture;
  49760. private _disposePostProcesses;
  49761. /**
  49762. * Dispose of the pipeline and stop all post processes
  49763. */
  49764. dispose(): void;
  49765. /**
  49766. * Serialize the rendering pipeline (Used when exporting)
  49767. * @returns the serialized object
  49768. */
  49769. serialize(): any;
  49770. /**
  49771. * Parse the serialized pipeline
  49772. * @param source Source pipeline.
  49773. * @param scene The scene to load the pipeline to.
  49774. * @param rootUrl The URL of the serialized pipeline.
  49775. * @returns An instantiated pipeline from the serialized object.
  49776. */
  49777. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  49778. /**
  49779. * Luminance steps
  49780. */
  49781. static LuminanceSteps: number;
  49782. }
  49783. }